Access Modifier
Access Modifier
1) PUBLIC
The Public access modifier is specified using the keyword PUBLIC.
Access level of public modifier with class , outside the class &within package &outside the
package.
2) PRIVATE
The private access modifier is specified using the keyword PRIVATE
Access level of private modifier is onlywithin the class it can not access outside the class.
3) PROTECTED
The protected access modifier is specified using keyword PROTECED.
Access level of protected modifier os within the package and outside the package through the
child class.it can not access through outside package
4) DEFAULT
When no access modifier is specified for class, method ,or data member it is said to be having
default access modifier.
Access lavel of default modifier is only within the ackage it can not access from outside the
package.
Package
A package in java is used to group realted classes.we use package to avoid name conflits, and to
Write the better code package are divied into two categiroes
1.Built-in package
2.User-defined package
-The package java.lang contains classes and interfaces that are essential to the Java
language. These include:
1) Final variable-a value of final variable become constant through out the program
2) Final method-final method declared final can not overridden
3) Final class-class which declare as final which can not inherited
-java application obtain object in memory as Garbage collector the task of garbage collector in spm is to
automatically determine what memory is no longer being in java application and recycle the memory for
the suser