Qus:    Why is Inheritance used in Java?
Feb 25, 2021 10:04 1 Answers Views: 418 JOSHUA
Prev Next
Answers (1)
SANJAY Feb 26, 2021 10:07
Answer:   There are various advantages of using inheritance in Java that is given below.
o Inheritance provides code reusability. The derived class does not need to redefine the method of base class unless it needs to provide the specific implementation of the method.
o Runtime polymorphism cannot be achieved without using inheritance.
o We can simulate the inheritance of classes with the real-time objects which makes OOPs more realistic.
o Inheritance provides data hiding. The base class can hide some data from the derived class by making it private.
o Method overriding cannot be achieved without inheritance. By method overriding, we can give a specific implementation of some basic method contained by the base class.

Post Your Answer
Guest User

Not sure what course is right for you?

Choose the right course for you.
Get the help of our experts and find a course that best suits your needs.

Let`s Connect