1.4.1. Access modifiers
Let’s start with an example. Examine the definitions of the classes House and Book in the following code and the UML representation shown in figure 1.20.
Figure 1.20. The nonpublic class Book can’t be accessed outside the package library.
package building; class House {} package library; class Book {}
With the current class definitions, the class House can’t access the class Book. Can you make the necessary changes (in terms of the access modifiers) to make the class Book accessible to the class House?
This one shouldn’t be difficult. From the discussion of class declarations in section 1.1, you know that a top-level class ...
Get OCA Java SE 8 Programmer I Certification Guide 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.