Inheritance in Java >
- it is the machanism in which one object acquire the properties(data
members)
and behaviour(functionalities/methods) of another object
- the purpose of inheritance to reusability of code.
child class : the class that extends the feature of another class called as
sub class or derived class
parent class : the class whose properties and functionalities used by another
class
is known as super class or base class
- to inherit 'extends' keyword is used
Syntax :
class A{
void demo(){
//......a
}
}
class B extends A{
A
+
demo(){
//......b
}
}
class C extends B{
}
C obj = new C();
[Link]();
// this feature will be used in interface
Types of inheritence:
1. single
2. multilevel
3. multiple //ambiguity(confusion)
4. hierarchical
5. hybrid
// for image
[Link]