A)
->a package is a grouping mechanism which related class files are grouped and made available to other applications or other part of the same application.
->a package creates a namespace (logical container, we can’t have 2 files with same name).
->directory also holds files like package, but difference is ‘directory’ can’t be made available to either applications where as package can do it. Directory is a name given to the os files system terminology where as package is a java terminology.
->a package provides the fallowing
1) Some level of security in the application.
2) Provides namespace (logical container) when no 2 class files have the same name.
3) Grouping of related class files and there by easy maintenance
4) Making the class files available to other applications and other part of same allocation.
Note:
no class files exists in java which doesn’t belong to a package.
no class files exists in java which doesn’t belong to a package.
->available in missing with default package. I.e. The package where the class files store in a folder only.
Packages are 2 types
1) Pre defined (built-in) package (library class files)
2) User defined package
->in built in packages library class files are grouped.
->In user defined package applications, user defined class files are grouped.
->in java, we have 2 kinds of built in packages.
1) Core packages
2) Extension packages
Jar –xf rt.jaràun zipping g
Core packages
->for every application by default package is java.long package. It is implicitly available.
->library inclusion in c is static i.e. the header files contribute to the size of the program.
->library inclusion in java is dynamic i.e. all does not contribute to size of object. Only particular one contributes.
->indicates availability of class files in a package but sub package class files are not available.
->in a java application, if we use library class without import it then we get compilation error. if that class belongs to other than long package.
->we include util package into a java application as fallows
import java.util.*;
-> ’*’ indicates that it does not represent sub package class files of util package. The above syntax does not package into current java applications process space. It makes all the class files of util package available to java application? At run time which library class files of that package we use in the applications. Those class files only be loaded into memory. This is known as “library inclusion is dynamic in java”.
->in ‘c’ whether we use the library in the program or not. Entire is contributed to size of program. Whenever in java it is not like that only particular one is contributed to size of program.
->if we ‘import’ out of the class does not mean violation of encapsulation. Because we are not programming any data, we are making many encapsulated units available to the application.
Comments
Post a Comment