class A {}
class B extends A{}
A objectX = new B();
What does the last line mean? Is it a object of class A or Is it a object of class B.
Does instance and object have same meaning ? Is objectX instance of A or is it an instance of B?
When we run objectX.SomeMethod. What will compiler check? Or method will be checked at run time?
  class A{}
  class B extends A{}
  public class Main{
  public static void main(String[] args){  
  A objectX =  new B(); 
  System.out.println(objectX instanceof B);//line 1
  System.out.println(objectX instanceof A);//line 2
  }
  }
If i run the above code why is it giving me true for line 1 and line 2.objectX is pointing to B.How come objectX is an instance of A.?
 
     
    