posted 22 years ago
Hello Everyone,
This question is from J2 Cert Guide, final exam question 40:
Which of the following is/are true?
A. A static method may be overridden by a static
method.
b. A static method may be overridden by a non-
static method.
c. A non-static method may be overridden by a
static method.
d. A non-static method may be overridden by a
final non-static method.
The book answer is D.
I want to make sure I am understanding why A & B are not true.
Is it because static means that it belongs to the class, therefore if you subclass you do not get that static method unless you use it through a parent class reference. Now if you overide the static method in your code, your not really overriding it, you are merely making a new static method for the child class, because the parent classes stays with the parent.
True?
Thanks,
-Matt
Here is some code, to hopefully proove my theory:
-Matt<br /> SCJP2<br /> SCJD