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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!