What is Inheritance?

A class inherits state and behavior from its super class. Inheritance provides a powerful and natural mechanism for organizing and structuring software programs. Benefit of inheritance is that subclasses provide specialized behaviors from the basis of common elements provided by the super class. Through the use of inheritance, programmers can reuse the code in the super class many times.

Inheritance extends the concept of Classes and Objects more to facilitate representation of types based on their similarities. Java uses the keywords ‘extends’ and ‘implements’ for applying inheritance. In the example the Class Tool is super class to class ScrewDriver and Saws. The inheriting classes acquire the properties of the super class.



 
Class Tool{
	String color;
	float price;
}
Class ScrewDriver extends Tool {
String handleType;
String tipType;
}
Class Saws extends Tool {
String bladeSize;	
}


FAQ Home

 
Printer friendly version of the FAQ-JAVA-What-Is-Inheritance page


Sponsored links

Build IT Knowledge with Current & Trusted Content
Helps Employees Develop & Hone New Technical Programming Skills. Sign Up & Get Full Access.
Check Out IT Certification Preparation Materials
Sign Up With SkillSoft & Get Access to Training Materials for Over 50 Professional Certifications.
SFTP components for .NET
Add complete SSH and SFTP support to your .NET framework application
Virtual File System SDK
Create your own file systems in Windows and .NET applications
PureCM Software Configuration Management
Version control and integrated issue tracking - powerful and easy to use. Get your FREE trial now!

Advertisement



Free Magazine

Free Magazines
eWeek The essential technology information source for builders of e-business.... subscribe now

Newsletter | Submit Content | About | Advertising | Awards | Contact Us | Link to us |
© 1996-2008 Community Networks Ltd All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Synchron Data - .NET development.