Inheritance in Java.
Inheritance is a process in which one object acquires all the properties & behavior of a parent object. When you inherit from an existing class, you can reuse methods & fields of the parent class. Inheritance represent IS-A relationship which is also known as a parent-child relationship.
superclass (parent) - the class being inherited from.
subclass (child) - the class that inherit from another class.
Use of Inheritance in java.
For method overloading (to achieve polymorphism at runtime).
For code Reusability (to avoid code repeatedly).
To inherit from a class extends keyword is used.
Syntax.
Class Subclass-name extends Superclass-name {
// methods
}
Types of Inheritance
Single
Multilevel
Hierarchical
Multiple (not used in Java)
Hybrid.