Show the output of running the class Test in the following code lines:

Show the output of running the class Test in the following code lines:


interface A {
}

class 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");
  }
}

class D extends C {
}
   
A. Nothing.
B. b is an instance of A.
C. b is an instance of C.
D. b is an instance of A followed by b is an instance of C.

The correct answer is D


Java

Learn More Multiple Choice Question :