public class F { protected int a=0, b=0; public F() { a = 2; b = 2; } public void increase() { upA(); } public void upA() { a = a + 1; } public String toString() { return a+" "+b; } } public class G extends F { public void increase() { super.increase(); upB(); } public void upA() { a = a + a; } public void upB() { b = b + 1; } } What is printed in the Output window by the following Java fragment?
G g = new G(); g.increase(); System.out.println(g); Can someone explain to me why the answer is 4,3
(ie. the subclass method is called even though I have called super.increase() which calls the upA method in the superclass?)