Java Question class A { public int f() {return 0;} public int g() {return 3;} } class B extends A{ public int f() {return 1;} public int g() {return f();} } class C extends B { public int f() {return...


Java Question


class A {


public int f() {return 0;}


public int g() {return 3;}


}


class B extends A{


public int f() {return 1;}


public int g() {return f();}


}


class C extends B {


public int f() {return 2;}


}


A ref1 = new C();


B ref2 = (B) ref1;


System.out.println(ref2.g());


What is the answer?


1) The program will fail to compile


2) The program will compile without error and print 0 when run


3)The program will compile without error and print 1 when run


4)The program will compile without error and print 2 when run


5)The program will compile without error and print 3 when run



May 17, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here