Chapter 7: Inheritance
1. Does a superclass have access to the members of a subclass? Does a subclass have access to the members of a superclass?
No, a superclass has no knowledge of its subclasses. Yes, a subclass has access to all nonprivate members of its superclass.
2. Create a subclass of TwoDShape called Circle. Include an area( ) method that computes the area of the circle and a constructor that uses super to initialize the TwoDShape portion.
3. How do you prevent a subclass from having access to a member of a superclass?
To prevent a subclass from having access to a superclass member, declare that member as private.
4. Describe the purpose ...
Get Java, A Beginner's Guide, 5th Edition, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.