concept same package in category java

This is an excerpt from Manning's book Java SE 11 Programmer I Certification Guide MEAP V03.
All the classes and interfaces defined in a Java source code file will be defined in the same package. There is no way to package classes and interfaces defined within the same Java source code file in different packages.
Class House doesn’t enjoy any advantages by being defined in the same package or being a derived class.
You can see how classes from the same package and separate packages, derived classes, and unrelated classes access the class Book and its members (the variable issueCount and the method issueHistory) in figure 9.9.
Figure 9.9 Access of members with default access to the class Book in unrelated and derived classes from the same and separate packages
![]()
Because the classes CourseBook and Librarian are defined in the same package as the class Book, they can access the variables issueCount and issueHistory. Because the classes House and StoryBook don’t reside in the same package as the class Book, they can’t access the variables issueCount and issueHistory. The class StoryBook throws the following compilation error message:

This is an excerpt from Manning's book The Java Module System.
When different artifacts contain classes in the same package (exported or not), they’re said to split the package. If at least one of the modular JARs doesn’t export the package, this is also called a concealed package conflict. The artifacts may contain classes with the same fully qualified name, in which case the splits overlap; or the classes may have different names and only share the package name prefix. Regardless of whether split packages are concealed and whether they overlap, the effects discussed in this section are the same. Figure 7.2 shows a split and concealed package.
Figure 7.2 When two modules contain types in the same package, they split the package.
![]()

This is an excerpt from Manning's book OCA Java SE 8 Programmer I Certification Guide.
Classes and interfaces in the same package can use each other without prefixing their names with the package name. But to use a class or an interface from another package, you must use its fully qualified name, that is, packageName.anySubpackageName.ClassName. For example, the fully qualified name of class String is java.lang.String. Because using fully qualified names can be tedious and can make your code difficult to read, you can use the import statement to use the simple name of a class or interface in your code.
Figure 1.23. Classes that can access a public class and its members
![]()