Super Keyword

     

  • Refer to this code sample.

       class Monkey {
       Monkey(){
       }
       }
       class Man extends Monkey{
       Man(){
       Super();
       }
       }

      Super = Super class
      
  •  The keyword super is used to call the constructor in the super class when you are in   the sub class.

  • When we are using the super keyword in a constructor of the sub class, the constructor of super class will run in the constructor of the sub class.

  • We can access methods and variables in the super class using the keyword super.
-(7th Article)        
                                                                                                    


Thank You!
                                                                                                           


                                                                                                            
                     
                                                                                                       -Article about Java by Hirun Yapa


      


Comments

Popular posts from this blog

Interfaces

Abstract Classes