Inheritance Example
public class Person
{
public Person()
{}

    public void work()
     {getWorkDetail(this);
        this.printTest();
    }
        
   public void getWorkDetail(Employee e)
    {System.out.println("This person is an employee");
    }
                    
     public void getWorkDetail(Person p)
      {System.out.println("This person is not an employee");
        }
     
        public void printTest()
        {System.out.println("Here in person");
           }      
   }
_______________________________________________
public class Employee extends Person
{public Employee()
      {super(); 
      }
     
  public void printTest()
             {System.out.println("Here in Employee");
                }  
    }
________________________________

Employee e1 = new Employee();
e1.work();
In this example the this seems to function in 2 different ways. In the work() method the parameter this is of Person type, in the next line this.printTest() (it works the same way without the this) the this is of Employee class type.

I think it works like this. e1 is an employee but when you are in Person class this would be a Person, because that is the class you are in. But when you call printTest, you are an employee. So the parameter and object use of this is different.