In Object oriented programming, we can create a class by inheriting the structure of another class. This is known as inheritance. Here newly created class is known as child class and the class from which it creates is known as Parent class.
Note: Child classes are also known as Base class or super class.
Note: Child classes are also known as derived class or sub class.
Note: In java we use extends as a keyword to implement the concept of inheritance.
There are 5 types of inheritance are possible
class Human
{
....
....
....
}
class Indian extends Human
{
....
....
....
}
class Human
{
....
....
....
}
class Indian extends Human
{
....
....
....
}
class Bengali extends Indian
{
....
....
....
}
class Human
{
....
....
....
}
class Indian extends Human
{
....
....
....
}
class Bangladeshi extends Human
{
....
....
....
}
class Pakistani extends Human
{
....
....
....
}
Note: Multiple and Hybride Inheritances are not supported in java by class. We can implement it by the interface.
Note: We can Alter Or Add any propery of Super class in sub class but can not delete any property.