posted 10 years ago
The following question is from a Whizlabs exam.
I emailed the author of this question and did not receive a response.
----------
50. When a class is extended by another class then the subclass can,
A. All methods of super class can be used directly as they are located in subclass.
B. All fields of super class can be used directly as they are located in subclass.
C. We can hide the static methods of super class by overriding static methods in the subclass.
D. All.
E. None.
Answer :C
Option C is correct because we can hide static methods of the super class by overriding them in the subclass.
Options A and B are incorrect because a subclass can not use the private fields and methods of the super class directly.
---------------
My thoughts on this question:
Although options A and B are false because they do not apply to
a) private methods and
b) private fields,
the phrasing for option C) should not be
"We can hide the static methods of super class by overriding static methods in the subclass. "
Correct phrasing for option C should be
"We can hide a static method of the parent class by using a static method in the subclass."
This is an example of a static method hiding another static method.
Please confirm.