This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
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

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » This Site » Ranch Office
Bookmark "beta round up question 19" Watch "beta round up question 19" New topic

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
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
[ September 14, 2003: Message edited by: Donald R. Cossitt ]

Jim Yingst

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
I agree. Here's the link:
subject: beta round up question 19
It's not a secret anymore!