The Java. Lang. Object Class

Source: Internet
Author: User
The Java language API between des a special class named object that is the root
Class of the entire Java hierarchy. The object class, found in the Java. lang package,
Is the parent of every Java class, either directly (meaning the class is
Immediate Child of object) or indirectly (meaning object is an ancestor further
Up the inheritance tree ).
For example, consider the following employee class that does not declare
Parent class.
Public class employee
{
// Class definition
}

Because this employee does not explicitly extend another class, it implicitly
Extends object. In fact, we cocould have added the extends keyword as follows:
Public class employee extends object
{
// Class definition
}
If you write a class and do not explain itly extend another class,
Compiler adds "extends object" to your class declaration. if you write
Class that extends another class besides object, the class still is a child
Object, since eventually one of its ancestors must have extended object.
Suppose that a salary class is written that extends employee:
Public class salary extends employee
{
// Class definition
}
The salary class extends employee, and because a Java class can only have
One parent class, salary does not extend object directly. Because Employee
Extends object, however, the salary class is an indirect child of the object class.
Note that the compiler does not add "extends object" to a Child class that
Already extends another class.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.