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.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Java quizzes
Sign Up Now
or Subscribe for future quizzes