*
The moose likes Ranch Office and the fly likes beta round up question 19 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » This Site » Ranch Office
Bookmark "beta round up question 19" Watch "beta round up question 19" New topic
Author

beta round up question 19

Steve Lovelace
Ranch Hand

Joined: Sep 03, 2003
Posts: 125
Question #19 states: "methods which are marked protected can be called on any subclass of the class in which the method is declared." and expects an answer of true. That says to me that the following should work:
Of course, the protected method clearChanged() is not visible outside of B, so this won't compile. Shouldn't the question say "can be called in any subclass..."?


The Inner that is named is not the true Inner.
Donald R. Cossitt
buckaroo
Ranch Hand

Joined: Jan 31, 2003
Posts: 401

can be called in any subclass...?

From page 200 Beginning Java 2, Horton
Protected can be used from any class in the same package and from any sub-class anywhere . So either question should produce true.
Why do you say "the protected method clearChanged() is not visible outside of B" ? Just went through the Beta Test and was not presented with question #19. I got #18, #75, ... Guess I'm a hood ornament
:roll:
[ September 14, 2003: Message edited by: Donald R. Cossitt ]

doco
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
No I think Steve is correct. His objection is to the use of "called on any subclass" rather than "called in any subclass".
Why do you say "the protected method clearChanged() is not visible outside of B"
Well, it would be visible in any subclass of B too, but his point is that it's not visible from A. "Called on any subclass" implies that you can perform the call from some other, outside class, such as A - and that's not true. Using "in" would imply calling from inside B, which is possible, and is evidently what the question was intended to ask.


"I'm not back." - Bill Harding, Twister
 
GeeCON Prague 2014
 
subject: beta round up question 19