Type Here to Get Search Results !

Write a JAVA program to give the example for ‘super’ keyword.

 class Superclass { 

 public void printMethod() { 

 System.out.println("Printed in Superclass."); 

 } 

//Here is a subclass, called Subclass, that overrides printMethod(): public class Subclass extends Superclass { 

 // overrides printMethod in Superclass 

 public void printMethod() { 

 super.printMethod(); 

 System.out.println("Printed in Subclass"); 

 } 

 public static void main(String[] args) { 

 Subclass s = new Subclass(); 

 s.printMethod();  

 } 


Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.

Featured post

M

M