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

Accesos Java

The document discusses Java access modifiers - public, private, protected, and default. It explains that public allows access from any class, private only within the same class, and protected allows access through inheritance from any package. Default allows access for any other class in the same package by inheritance or reference.

Uploaded by

Carlos Peñaloza
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Accesos Java

The document discusses Java access modifiers - public, private, protected, and default. It explains that public allows access from any class, private only within the same class, and protected allows access through inheritance from any package. Default allows access for any other class in the same package by inheritance or reference.

Uploaded by

Carlos Peñaloza
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

JAVA:

Access modifiers:
- public
All other classes can access it no mater which packages they are
, it can be accessed through inheritance and also by reference.
- private
It can just be accessed into the same class in which the member
was declared
- protected
It can be accessed through inheritance from any package, the acc
ess made through reference it's not allowed.
- default
It can be accessed for any other class into the same package by
inheritance as well as by reference
_______________________________________________________________________
#######################################################################
#
VISIBILITY
# PUBLIC # PROTECTED # DEFAULT # PRIVATE #
#___________________________#________#___________#__________#_________#
#######################################################################
#
From the same Class # Yes #
Yes
#
Yes # Yes #
#######################################################################
#
From any class in the # Yes #
Yes
#
Yes #
NO #
#
same package
#
#
#
#
#
#######################################################################
# From a subclass in the # Yes #
Yes
#
Yes #
NO #
#
same package
#
#
#
#
#
#######################################################################
# From a subclass outside # Yes #Yes using #
NO #
NO #
# the same package
#
#inheritance#
#
#
#######################################################################
#From any no-subclass class # Yes #
NO
#
NO
#
NO #
# outside the package
#
#
#
#
#
#######################################################################
Access control:
- Class Access
default: Only seen for other classes into the same package.
Non-Access modifiers:
strictfp
final
abstract

You might also like