• 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

RHE mock question bonus1 q49

 
Ranch Hand
Posts: 281
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This mock question asks:
public class Parent {
final void zzz() { }
}
Which of the following methods may appear in a subclass of Parent, when the subclass is in a different package from Parent?
Choose all correct options.
A) void zzz() { }
B) void zzz(int j) { }
C) final void zzz(float f) { }
D) public final void zzz(double d) { }
The answer says:
Correct selection is: B, C, D
A final method may not be overridden; thus A is illegal. The methods in B, C, and D have different argument lists from the superclass version of the method, so B, C, and D are not examples of overriding; they are all legal.
>>> I think, though, that answer A is also valid since the question asks when you are in a different "package" from the parent. If you were in a different package wouldn't you not even be able to have access to the final void method since it isn't protected and thus you could declare your own void zzz() method since it wouldn't even see the final method in the other package?
Am I wrong in my thinking here?
thanks,
Rick
 
Ranch Hand
Posts: 2596
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are right A is correct, it's mentioned in the RHE errata. Have a look at this.
HTH,
- Manish

[This message has been edited by Manish Hatwalne (edited October 24, 2001).]
 
I am not a spy. Definitely. Definitely not a spy. Not me. No way. But this tiny ad ...
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic