Can anyone please explain this to me. Im trying to understand the diffrence between invoking instanace methods on an object and accessing members of an object. I thought member access using a refrence was determined by the type of refrence not the class of the current object denoted by the refrence.

But when i run this the output is 10 then 5, but if this was the case then the output should be 10 then 10 since Test is now denoted by the t1 refrence.

Code:
class Test{
    public int i = 5;    
      
  }

  class Test1 extends Test{
    public int i = 10;      
  }

 public class Test2 extends Test1{
    public static void main(String[] args){
         
    Test1 t1 = new Test1();  
     System.out.println(t1.i); // 10 
       
    Test t = t1; // member access using a refrence is determined by 
         // the type of refrence not the class of the current object 
 // denoted by the refrence.  
  
    
   System.out.println(t.i);  // 5