MCQ Single Best Answer Not Set

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

ID: #2277 Java Interfaces And Abstract Classes MCQ 2,533 views
Question Info
#2277Q ID
Not SetDifficulty
Java Interfaces And Abstract Classes MCQTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • 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.
Correct Answer: Option D

Explanation

b is an instance of A followed by b is an instance of C.

Share This Question

Challenge a friend or share with your study group.