0% found this document useful (0 votes)
27 views

Access Modifier

The document discusses different access modifiers in Java including public, private, protected and default. It also discusses packages, the java.lang package and the significance of classes within it. It explains the final keyword and how it can be used for variables, methods and classes. It provides an overview of the garbage collector and its role in reclaiming unused memory in Java applications.

Uploaded by

Divya Patil
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Access Modifier

The document discusses different access modifiers in Java including public, private, protected and default. It also discusses packages, the java.lang package and the significance of classes within it. It explains the final keyword and how it can be used for variables, methods and classes. It provides an overview of the garbage collector and its role in reclaiming unused memory in Java applications.

Uploaded by

Divya Patil
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

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

What is the significance of java lang package?

-The package java.lang contains classes and interfaces that are essential to the Java
language. These include:

 Object, the ultimate superclass of all classes in Java


 Thread, the class that controls each thread in a multithreaded program
 Throwable, the superclass of all error and exception classes in Java
 Classes that encapsulate the primitive data types in Java
 Classes for accessing system resources and other low-level entities
 Math, a class that provides standard mathematical methods
 String, the class that is used to represent strings
Because the classes in the java.lang package are so essential, the java.lang package is implicitly
imported by every Java source file. In other words, you can refer to all of the classes and
interfaces in java.lang using their simple names.

Explain the final keyword!!

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

Explain the concept of garbage collector!!

-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

You might also like