Java | Operators | Question 6

filter_none

edit
close

play_arrow

link
brightness_4
code

class Base {}
  
class Derived extends Base {
   public static void main(String args[]){
      Base a = new Derived();
      System.out.println(a instanceof Derived);
   }
}

chevron_right


(A) true
(B) false


Answer: (A)

Explanation: The instanceof operator works even when the reference is of base class type.

Quiz of this Question



My Personal Notes arrow_drop_up