1.3 Inheritance in Java - Part 1-OOPS concept|Types of Inheritance| imp points| diagrams| examples
1.OOPS Concept - What is Inheritance using java with example simple program
Types of Inheritance - Single,Multilevel,Hierarchical,Multiple - extends keyword
1.3 Inheritance in JAVA Part 1 - Third Video of Core Java Series
Videos:
Part 1 : Overview of Inheritance and types of inheritance with simple diagrams.
Part 2 : Coding examples on types of inheritance using eclipse.
Part 3 : Why Multiple Inheritance is not supported in Java and how we can tackle this problem to achieve multiple inheritance.
Inheritance is a mechanism that allows the class to use the states and behaviours of another class. i.e a class derives variables and methods from another class.
Derived class in inheritance is called sub class (also called derived class or child class) and the class from which it is derived is called super class (also called base class or a parent class).
A super class can have any number of sub classes in inheritance but sub class can only extend one super class.
Inheritance achieved by deriving a new class from existing class using extends keyword. Example: class Child extends Parent.
In Inheritance by default all data members and member functions of a parent class are available to child class if they are not private.
Types of Inheritance:
1.Single Inheritance : In Single inheritance one class is derived from one parent class.
2.Multilevel Inheritance : In multilevel inheritance there is a concept of grand parent class.
3.Hierarchical Inheritance : In Hierarchical inheritance more than one sub classes is derived from a single parent class.
4.Multiple Inheritance : One derived class try to extend more than one parent class.
Importance Of Inheritance:
Re-usability of code: It is one of the important feature of inheritance. It is a good way to reuse the already existing code rather than creating the same code again and again. This feature not only saves time and money as we are reusing the properties but it also increase reliability of code.
Method Overriding: With the help of inheritance, it is possible to override the methods of base class so that base class method is easily used in derived class.