A

Admin • 831K Points
Coach

Q. Determine output of the following code.
interface A { }

class C { }

class D extends C { }

class B extends D implements A { }

public class Test extends Thread{
public static void main(String[] args){
B b = new B();
if (b instanceof A)
System.out.println("b is an instance of A");
if (b instanceof C)
System.out.println("b is an instance of C");
}
}

  • (A) Nothing.
  • (B) This code will not compile, because class Dog must implement method doYourJob() from interface Guard.
  • (C) ---
  • (D) ---
  • Correct Answer - Option(D)
  • Views: 16
  • Filed under category Java
  • Hashtags:

No solution found for this question.
Add Solution and get +2 points.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.