Grokking Java Interview Questions
0% completed
Access Modifiers and Packages
| Modifier | Same class | Same package | Subclass in another package | Any other class |
|---|---|---|---|---|
private | Yes | No | No | No |
| none | Yes | Yes | No | No |
protected | Yes | Yes | Yes, with a condition | No |
public | Yes | Yes | Yes | Yes |
This table summarizes who can use a field, a method, or a constructor of a public class. Three of its cells need an explanation: the "No" for a subclass in the second row, the condition in the third row, and the "Yes" at the end.
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%