Today
Today our trainer took the topic inheritance in java
basically means one parent class and child class like that it has 5 types....
Inheritance:
- extends keyword is used for inheritance in Java.
- extends keyword make an bond between the child class and the parent class.
- It enables the subclass to inherit the fields and methods of the superclass.
1.Single:
- sub-class is derived from only one super class.
- It inherits the properties and behavior of a single-parent class.
2.Multilevel:
- Derived class will be inheriting a base class.
- Derived class acts like base class for other classes.
3.Hierarchical:
- It has more than one subclass is inherited from a single base class.
- More than one derived class is created from a single base class. For example, cars and buses both are vehicle.
4.Multiple:
- one class can have more than one superclass
- Inherit features from all parent classes.
5.Hybrid:
- It is a mix of two or more of other inheritance.
- we can achieve hybrid inheritance only through Interfaces
Ref: https://www.geeksforgeeks.org/java/inheritance-in-java/
Git:https://gitlab.com/ajayraja1817-group/javabeginers.git
I did some programs for some of the inheritance.
Top comments (0)