0% found this document useful (0 votes)
14 views

Inheritance

Inheritance in Java allows one class to inherit properties and behaviors from another parent class, creating a parent-child relationship where the subclass inherits and can extend what is defined in the superclass. It provides code reusability and allows for method overriding to achieve runtime polymorphism, where a subclass can specialize a superclass by adding its own unique elements to those inherited from the parent.

Uploaded by

Ammu Mole
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Inheritance

Inheritance in Java allows one class to inherit properties and behaviors from another parent class, creating a parent-child relationship where the subclass inherits and can extend what is defined in the superclass. It provides code reusability and allows for method overriding to achieve runtime polymorphism, where a subclass can specialize a superclass by adding its own unique elements to those inherited from the parent.

Uploaded by

Ammu Mole
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Inheritance in Java

Inheritance in java is a mechanism in which one object acquires all the properties and behaviors of parent
object.
The idea behind inheritance in java is that you can create new classes that are built upon existing classes.
When you inherit from an existing class, you can reuse methods and fields of parent class, and you can add
new methods and fields also.
Inheritance represents the IS-A relationship, also known as parent-child relationship.
Why use inheritance in java
For Method Overriding (so runtime polymorphism can be achieved).
For Code Reusability.
In the terminology of Java, a class that is inherited is called a superclass. The class that does the inheriting
is called a subclass. Therefore, a subclass is a specialized version of a superclass. It inherits all of the
instance variables and methods defined by the superclass and adds its own, unique elements.

You might also like