Turn Desktop View Off
 
 
 
by Dinesh Thakur

The packages are used for categorization of the same type of classes and interface in a single unit. There is no core or in-built classes that belong to unnamed default package. To use any classes or interface in other class, we need to use it with their fully qualified type name. But some time, we've the need to use all or not all the classes or interface of a package then it's a tedious job to use in such a way discussed. Java supports imports statement to bring entire package, or certain classes into visibility. It provides flexibility to the programmer to save a lot of time just by importing the classes in his/her program, instead of rewriting them.



 
by Dinesh Thakur

Access modifiers define the scope of the class and its members (data and methods). For example, private members are accessible within the same class members (methods). Java provides many levels of security that provides the visibility of members (variables and methods) within the classes, subclasses, and packages.



 
by Dinesh Thakur
  1. The programmer can easily find them, by knowing their position with their set of task. The common types of classes and interfaces are placed in the same package.
  2. The type name (class or interface) must not conflict with other package type name, because at the same time if both packages are in use, compiler must not confuse.
  3. There must not be any restriction to access any type from another type within the same package. But assign the restricted access from types outside the package.