![]() |
![]() |
![]() |
![]() |
![]() |
|
A particular class's protected instance variables and instance methods are accessible from instance methods defined in the same class or in any subclass of that class.
Thus, the protected minutes instance variable is available not only to
methods defined in the Attraction class definition, but also to
methods defined in the Movie and Symphony classes, because
those classes are subclasses of the Attraction class.
If you mark the minutes instance variable with the protected
keyword, all the instance methods defined in the Movie,
Symphony, and Attraction classes can assign values to the
minutes instance variable, as well as can obtain a value from it.