Multiple Choice Question

Quiz Guidelines

 

QID: 
391
Question: 

Which letters will be printed when the following program is run?

public class TestClass{
public static void main(String args[]){
B b = new C();
A a = b;
if (a instanceof A) System.out.println("A");
if (a instanceof B) System.out.println("B");
if (a instanceof C) System.out.println("C");
if (a instanceof D) System.out.println("D");
}
}class A { }
class B extends A { }
class C extends B { }
class D extends C { }

Select 3 options

A. A will be printed.
B. B will be printed.
C. C will be printed.
D. D will be printed.

Q&A Set: 

Search the Web

Custom Search

Searches whole web. Use the search in the right sidebar to search only within javajee.com!!!