go to previous page   go to home page   go to next page

Answer:

No.

Only One Class Hierarchy

hierarchy starts with object

Think about the answer a bit. If you define a class that does not explicitly extend another class, then it automatically extends Object. If you define the class so that it extends a class other than Object, then that class either extends another class or extends Object. Now that class in turn must either extend another class or extend Object. There is no way to end the chain except by (ultimately) extending Object.

You might cleverly try to have class A extend class B, and have class B extend class A. But this (and other loops) is not allowed.

Ultimately, every Java object inherits its object-like behavior from the class Object. When an object is constructed a chain of constructors is invoked starting with the one in Object and ending with the one in the requested class. The fundamental parts of the object are put together by the constructor in Object, then additional parts are added down the chain until the requested class is reached.

Construction starts with the constructor in Object because each constructor (except Object's constructor) starts by invoking its super() constructor (with or without arguments).


QUESTION 23:

Does a parent class have to be recompiled each time a new child class is derived from it?