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
Biology,
2 months ago
Sociology,
2 months ago
India Languages,
5 months ago
Math,
5 months ago
Biology,
10 months ago