0% found this document useful (0 votes)
7 views1 page

Inheritance Type

Inheritance is a mechanism in object-oriented programming where a new class derives properties and features from an existing class. In Java, the 'extends' keyword is used for inheritance, which promotes code reusability, although private members of the superclass cannot be accessed. There are various types of inheritance including single, multilevel, multiple, hierarchical, and hybrid inheritance, with multiple inheritance being restricted for classes due to ambiguity issues.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views1 page

Inheritance Type

Inheritance is a mechanism in object-oriented programming where a new class derives properties and features from an existing class. In Java, the 'extends' keyword is used for inheritance, which promotes code reusability, although private members of the superclass cannot be accessed. There are various types of inheritance including single, multilevel, multiple, hierarchical, and hybrid inheritance, with multiple inheritance being restricted for classes due to ambiguity issues.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

What is inheritance ?

when we construct a new class from a existing class in a such way that the new
class access all the features
& properties of existing class called inheritance.

key points :-
✅ in java extends keyword is used to perform inheritance
✅ its provides code reusability
✅ we can't access private members of class through inheritance.
✅ A sub class contains all the features of super class so we should create the
object of sub class
✅ Method overriding only possibel through inheritance
Types of inheritance
1. singel inheritance
super-->sub
[Link] inheritance
super-->sub1-->sub2-->sub3-->subn
[Link] inheritance
super1,super2-->sub
(not allowed in the case of classes due tu embiguaty essues but possible through
interfaces)
[Link] inheritance
super-->sub1 super-->sub2
[Link] inheritance
super1-->super2-->sub1 super2-->sub2 super2-->sub3

You might also like