Skip to main content

Posts

Showing posts with the label Inheritance in Java | Java Inheritance | Inheritance | How to use Inheritance in Java | Implementation of Inheritance in Java.

Inheritance In Java

  Inheritance Inheritance is a process or a mechanism where one class acquire the properties which include methods and fields of another class. With the use of this concept the information is made manageable in a hierarchical order. The class which inherits the properties of another class is known as subclass  or derived class or child class . and the class whose properties are inherited is called as base class or parent class . In java inheritance cannot be achieved until we use extends keyword. Reason to use Inheritance 1 For Method overriding 2 For code reusability  Syntax: class abc { ......... ......... } class xyz extends abc { ......... ......... } ---------------------------------------------------------------------------------------------------------------------------- Example //WAP to Demonstrate Inheritance............. import java.io.*; class Superclass { BufferedReader r=new BufferedReader(new InputStreamReader(System.in)); Double num1,num2; void get() { try