Home           J2EE Concepts           JMS           Java Language           Contact           Back           Next           Bookmark this Page          










Some useful tips related to:
 - health & fitness
 - vehicle care
 - cooking
 - misc household tasks

Inheritance Overview


To understand Inheritance in Java, just think about its literal meaning. Inheritance is all about having some traits common between parent and children.

Java provides mechanism to create hierarchical classifications. You can create a general class that caters to some generic requirements (have common methods & properties) and specific classes can inherit this generic class. The class that is inherited (i.e. parent class) is called a superclass, and the child class is known as subclass.
Keyword extend is used to facilitate inheritance. Properties & methods of superclass are available to subclasses.

For example, you can create a generic class "Human" as parent class, and then "Student", "Employee" can be created as children classes.
Pseudo code for above example is shown below:

class Human{
  String name;
  int age;
}

class Student extends Human{
  int RollNo;
}

class Employee extends Human{
  int EmployeeNo;
}