advertisement
Premier Club Log In/Registration
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   SKILLBUILDING  |   TIP BANK  |   SOURCEBANK  |   FORUMS  |   NEWSLETTERS
Browse DevX
Partners & Affiliates
advertisement
advertisement
Tip of the Day
Average Rating: 4/5 | Rate this item | 3 users have rated this item.
Expertise: Beginner
Language: Java
January 20, 1999
Inheriting From the Object Class
The Object class in Java is a superclass for all other classes defined in Java's class libraries, as well as for user-defined Java classes. In object-oriented terms, an object is an instance of a class. Note the distinction between the "Object class" and a Java "object": A Java object is an instance of any class derived from the Object class.

Normally, when a class is defined in Java, the inheritance from the Object class is implicit. Therefore, the following two declarations of class "MyClass" are equivalent:

 
public class MyClass
{
}

public class MyClass extends Object
{
}
In fact, the second class declaration is redundant and shouldn't be used. Note that inheriting from the Object class is the only exception to Java's rule for single inheritance. Java's inheritance mechanism allows a class to extend from only one superclass (although it may implement several interfaces). However, the following statement is valid, even though it implies that MyClass extends from two Java classes (the "Object" class and "Superclass"):
 
public class MyClass extends SuperClass
{
}
Ajit Sagar
If you have a hot tip and we publish it, we'll pay you. However, due to accounting overhead we no longer pay $10 for a single tip submission. You must accumulate 10 acceptable tips to receive payment. Be sure to include a clear explanation of what the technique does and why it's useful. If it includes code, limit it to 20 lines if possible. Submit your tip here.
Please rate this item (5=best)
 1  2  3  4  5
advertisement
advertisement
Advertising Info  |   Member Services  |   Permissions  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs