What is the main benefit of Inheritance?
Short Answer
Views 14
Answer:
Inheritance allows a class (child/subclass) to acquire the properties and methods of another class (parent/superclass).
This provides:
-
Code reusability
-
Faster development
-
Avoiding duplication
-
Easy maintenance
-
Ability to create hierarchical relationships
Example:
A Car class and a SportsCar class. SportsCar inherits features from Car but can add its own features.
Related Articles:
This section is dedicated exclusively to Questions & Answers. For an in-depth exploration of Java Programming Language, click the links and dive deeper into this subject.
Join Our telegram group to ask Questions
Click below button to join our groups.