Javatpoint Logo

inheritance

By: monica*** On: Fri Feb 03 23:28:14 IST 2017     Question Reputation0 Answer Reputation0 Quiz Belt Series Points0  0Blank User
i need a useful example of inheritance.Up0Down

 
The Process of deriving new class from existing class.This is called Inheritance.
New Class is called Child Class
Existing Class is called Parent Class

taking example of door
A door to your home
A door to neighbor's home
A door to a temple
A door to a company
All are different door look wise but derived from an existing class Door
Taking example.....

class Faculty
{
float salary=30000;
}
class Science extends Faculty
{
float bonous=2000;
public static void main(String args[])
{
Science obj=new Science();
System.out.println("Salary is:"+obj.salary);
System.out.println("Bonous is:"+obj.bonous);
}
}
Image Created0Down

By: [email protected] On: Sat Feb 04 15:02:21 IST 2017 Question Reputation0 Answer Reputation0 Belt Series Points0 0User Image
Are You Satisfied :0Yes0No