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..."?
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 ]
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.