Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Incorrect phrasing for option (whizlabs exam)?

 
Thomas Hauck
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Overriding can indeed only be applied on instance methods, not on static (class) methods. So indeed the phrasing of option C is poor.

Your phrasing for option C is also incorrect. Reason: in the following code snippet I'm using a static method in the subclass, but there is no static (class) method hiding at all.


The correct phrase for option C would be: We can hide a static (class) method of the parent class by defining a static (class) method with the same signature in a subclass.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic