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