Multiple Choice Question

Quiz Guidelines



Given the following classes and declarations, which of these statements about //1 and //2 are true?

class A{
private int i = 10;
public void f(){}
public void g(){}
}class B extends A{
public int i = 20;
public void g(){}
}public class C{
A a = new A();//1
A b = new B();//2  }    

Select 1 option

A. System.out.println(b.i); will print 10.
B. The statement b.f( ); will give compile time error..
C. System.out.println(b.i); will print 20
D. All the above are correct.
E. None of the above statements is correct.+

Q&A Set: