by Dinesh Thakur

 

class superclass

           {
               String s= "This is the super class";
               void display(String s)
                  {
                      System.out.println("Superclass Message: "+s);
                  }
           }
                   class subclass extends superclass
                     {
                         String s = "This is the sub class";
                         public static void main(String[] args)
                              {
                                 new subclass();
                              }
                                  void display(String s)
                             {
                                         System.out.println("Sublass message: "+s);
                                     }
                                 subclass()
                                   {
                                       display(this.s);
                                               display(super.s);
                                               this.display(s);
                                       super.display(s);
                                   }
                     }

Example of this Pointer in Java