Friday, September 9, 2011

Quiz of the day | OCPJP (4)

Given:

2. class A { }
3. public class B extends A {
4. public static void main(String[] args) {
5. A a = new A();
6. B b = new B();
7. // insert code here
8. }
9. }

Which, inserted independently at line 7, compile? (Choose all that apply.)

A. if(b instanceof a) System.out.print("a ");
B. if(b.instanceof(a)) System.out.print("b ");
C. if(b instanceof A) System.out.print("c ");
D. if(b instanceOf A) System.out.print("d ");
E. if(b.instanceof(A)) System.out.print("e ");


DOWNLOAD the answer

0 comments: