Qus: Why is Inheritance used in Java?
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.