by Dinesh Thakur Category: Introduction to Java

 

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



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.