Skip to content
Related Articles

Related Articles

Java | Operators | Question 6
  • Last Updated : 07 Feb, 2014




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

(A) true
(B) false


Answer: (A)

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

Quiz of this Question

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :