0% found this document useful (0 votes)
59 views4 pages

Access Modifier

Java provides four access modifiers to control the visibility and accessibility of classes, variables, methods and constructors: public (visible to the world), private (visible to the class only), protected (visible to the package and subclasses), and the default which is package-private with no explicit modifier needed. The document also discusses final which applies restrictions to classes, methods and variables to prevent inheritance, overriding or reassignment, and finally and finalize which are used for exception handling and garbage collection cleanup processing.

Uploaded by

Pranay Kinra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views4 pages

Access Modifier

Java provides four access modifiers to control the visibility and accessibility of classes, variables, methods and constructors: public (visible to the world), private (visible to the class only), protected (visible to the package and subclasses), and the default which is package-private with no explicit modifier needed. The document also discusses final which applies restrictions to classes, methods and variables to prevent inheritance, overriding or reassignment, and finally and finalize which are used for exception handling and garbage collection cleanup processing.

Uploaded by

Pranay Kinra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Access Modifiers in Java

Access Modifiers in
java Modifiers in Java
Access

Access Control Modifiers:


Java provides a number of access modifiers to set
access levels for classes, variables, methods and
constructors. The four access levels are:
Visible to
needed.
Visible to
Visible to
Visible to

the package, the default. No modifiers are


the class only (private).
the world (public).
the package and all subclasses(protected).

Final
Final is used to apply restrictions on class,
method and variable. Final class can't be
inherited, final method can't be overridden
and final variable value can't be changed.
Final is a keyword.
Finally
Finally is used to place important code, it
will be executed whether exception is
handled or not.
Finally is a block.
Finalize
Finalize is used to perform clean up
processing just before object is garbage

You might also like