• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RHE mock question bonus1 q49

 
Rick Reumann
Ranch Hand
Posts: 281
  • Mark post as helpful
  • send pies
  • 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
 
Manish Hatwalne
Ranch Hand
Posts: 2596
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • 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).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic