Inheritance:
"Inheritance is process by which object of one class acquire the property of object of another class."
In other words:"The mechanism of deriving a new class from an old once this concept is called Inheritance".
Inheritance is most commonly used concept of Oops. There are basically five types of inheritance these are
(a)Single Inheritance
(b)Multilevel Inheritance
(c)Multiple Inheritance
(d)Hierarchical Inheritance
(e)Hybrid Inheritance
we can not use Multiple Inheritance in java because ambiguity problem occurs in our program.This problem is also called diamond problem.In which compiler does not know which super class method will be executed.
Inheritance provides/Need of Inheritance:
(a)Re usability
(c)Transitive Nature
(d)Readability
Single Inheritance:
In this type of inheritance one class is derived from one another class. Derived class is known as child class and another class is known as parent class.
Single inheritance consists 1:1 relationship.
Consider an example to understand the concept more clear.
Multilevel Inheritance:
Multiple Inheritance is a feature of object oriented concept, where a class can inherit properties of more than one parent class. The problem occurs when there exist methods with same signature in both the super classes and subclass. On calling the method, the compiler cannot determine which class method to be called and even on calling which class method gets the priority.
This diagram shows the concept of multilevel inheritance.
"Inheritance is process by which object of one class acquire the property of object of another class."
In other words:"The mechanism of deriving a new class from an old once this concept is called Inheritance".
Inheritance is most commonly used concept of Oops. There are basically five types of inheritance these are
(a)Single Inheritance
(b)Multilevel Inheritance
(c)Multiple Inheritance
(d)Hierarchical Inheritance
(e)Hybrid Inheritance
we can not use Multiple Inheritance in java because ambiguity problem occurs in our program.This problem is also called diamond problem.In which compiler does not know which super class method will be executed.
Inheritance provides/Need of Inheritance:
(a)Re usability
(c)Transitive Nature
(d)Readability
Single Inheritance:
In this type of inheritance one class is derived from one another class. Derived class is known as child class and another class is known as parent class.
Single inheritance consists 1:1 relationship.
Consider an example to understand the concept more clear.
Multilevel Inheritance:
Multiple Inheritance is a feature of object oriented concept, where a class can inherit properties of more than one parent class. The problem occurs when there exist methods with same signature in both the super classes and subclass. On calling the method, the compiler cannot determine which class method to be called and even on calling which class method gets the priority.
This diagram shows the concept of multilevel inheritance.
0 Comments