Books Related to Java Technology

Saturday, December 27, 2008

What is Inheritance?

Inheritance provides a powerful and natural mechanism for organizing and structuring your software. It is the capability of a class to use the properties and methods of another class while adding its own functionality. Object-oriented programming allows classes to inherit commonly used state and behavior from other classes by the "extends" keyword. In the image we see 'duck', 'cuckoo' and 'ostrich' inherit the all properties of 'bird' which is the super class and the 'duck', 'cuckoo' and 'ostrich' are the sub class. For Example:
public class duck extends bird
public class cuckoo extends bird
public class ostrich extends bird

No comments:

Post a Comment