Open In App

Java | Operators | Question 6

Last Updated : 28 Jun, 2021
Like Article
Like
Save
Share
Report




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


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads