Tuesday, March 10, 2009

Java Access Control

Access Levels
Modifier Class Package Subclass World
public Y Y Y Y
protected Y Y Y N
no modifier Y Y N N
private Y N N N

Public – access allowed to public. E.g., constants
Protected – allow child to access parent.
No modifier – allow package member to access only.
Private – non-accessible.


Static Initialize
- init static constant variables or object
- loaded before class is loaded
- prevents lock scenario

static
{
*action
}

No comments:

Post a Comment