Consider the following case of inheritance:
public class Parent {
public Parent() {
getValue();
}
public void getValue() {
}
}
public class Child extends Parent {
private final Integer integer;
public Child() {
integer = new Integer(888);
}
@Override
public void getValue() {
System.out.println(integer);
}
}
Question: What would the following program print, why?
public class Test {
public static void main(String[] args) {
Child child = new Child();
child.getValue();
}
}
Lets assume that getValue() implementation in Child class was changed to:
@Override
public void getValue() {
System.out.println(integer.toString());
}
Question: What would the output of the Test class be now, why?