what is the need of inheritance in java
Answers
Answered by
1
Inheritance is a process of defining a new class based on an existing class by extending its common data members and methods. Inheritance allows us to reuse of code, it improves reusability in your java application.
pls mark as brainlist
Answered by
2
Answer:
In Java, we use the extends keyword to inherit from a class. Here, we have inherited the Dog class from the Animal class. The Animal is the superclass (parent class or base class), and the Dog is a subclass (child class or derived class). The subclass inherits the fields and methods of the superclass.
Similar questions
Science,
3 months ago
Hindi,
3 months ago
India Languages,
7 months ago
Math,
7 months ago
Biology,
11 months ago