• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Incorrect phrasing for option (whizlabs exam)?

 
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic