What is inheritance ?

What is inheritance ?

Inheritance is the mechanism of using the features of one class into another class.

 The class which acquire the properties of another class (super class)is called subclass or drived class. 

Java provides the keyword \'extends\' to support the Inheritance.

 Example:

package p1; public class SuperClass{ void show(){ System.out.println(\"Super class\"); } } class SubClass extends SuperClass{ public static void main(String[] args){ SubClass s=new SubClass(); s.show(); } }

By:Jalees
Date:2012-01-09 00:00:00

Inheritance is the mechanism of using the features of one class into another class.

 The class which acquire the properties of another class (super class)is called subclass or drived class. 

Java provides the keyword \'extends\' to support the Inheritance.

 Example:

package p1; public class SuperClass{ void show(){ System.out.println(\"Super class\"); } } class SubClass extends SuperClass{ public static void main(String[] args){ SubClass s=new SubClass(); s.show(); } }

By:Sumit Tripathi
Date:2019-05-15 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related Java Subjective Links

Java Subjective interview questions and answers for experienced and fresher