Multiple Choice Question

Quiz Guidelines

 

QID: 
389
Question: 

Given:

interface I { }
class A implements I{
    public String toString(){ return "in a"; }
}
class B extends A{
    public String toString(){ return "in b"; }
}
public class TestClass {
    public static void main(String[] args) {
        B b = new B();
        A a = b;
        I i = a;
        
        System.out.println(i);
        System.out.println((B)a);
        System.out.println(b);
        
    }
}

What will be printed when the above code is compiled and run?

Select 1 option

A. in i
in a
in b
B. I
A
in b
C. in a
in a
in b
D. in a
in b
in b
E. in b
in b
in b

Q&A Set: