CodesJava

Easy learning with example program codes

what is inheritance in java?


Inheritance is a way to implement IS-A relationship i.e. parent child relationship. Subclass inherits the super class properties like data member, methods. Inheritance is the way of re-usability of code. Let us take the example of parent and child. A child inherits the properties of its parent.

Why inheritance is used?

  1. Code re-usability.
  2. Run-time polymorphism.

 Syntax:

class subclass extends superclass{

   //subclass code

}

Java nterview questions on inheritance



Copyright © 2018 CodesJava DMCA.com Protection Status SiteMap