Exercises
8.2 (Based on Section8.14 ) Explain the notion of package access in Java. Explain the negative aspects of package access.
8.3 What happens when a return type, even
void, is specified for a constructor?8.4 (Rectangle Class) Create a class
Rectanglewith attributeslengthandwidth, each of which defaults to 1. Provide methods that calculate the rectangle’s perimeter and area. It has set and get methods for bothlengthandwidth. The set methods should verify thatlengthandwidthare each floating-point numbers larger than 0.0 and less than 20.0. Write a program to test classRectangle.8.5 (Modifying the Internal Data Representation of a Class) It would be perfectly reasonable for the
Time2class of Fig.8.5 to represent the time ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access