Question: Consider the following two classes: public class SuperClass{ public int A(){ return A() + 3; } public int B(){ return 7; } } public class
Consider the following two classes:
public class SuperClass{
public int A(){
return A() + 3;
}
public int B(){
return 7;
}
}
public class SubClass extends SuperClass{
public int A(){
return super.B() + 2;
}
public int B(){
return super.A() + 5;
}
public int C(){
return super.A();
}
}
Assume that the following declaration appears in a client program:
SuperClass x = new SubClass();
What is printed as a result of the call to System.out.print(x.B())?
(A) 8
(B) 12
(C) 15
(D) 17
(E) Nothing is printed because of infinite recursion.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
