What will be the result of execution of the following code?

public class Parent {
    protected String value = "parent";

    public static void main(String[] args) {
        Parent parent = new Child();
        Child child = new Child();

class Child extends Parent {
    protected String value = "child";
Fields of a class are not overridden as a result of inheritance. Therefore in every case the value of the field of an instance of a class will be printed out.

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Продолжайте изучать
тесты по Java
Зарегистрируйся сейчас
или Подпишись на будущие тесты