Java Programming - Declarations and Access Control - Discussion

Discussion Forum : Declarations and Access Control - General Questions (Q.No. 6)
6.
What is the most restrictive access modifier that will allow members of one class to have access to members of another class in the same package?
public
abstract
protected
synchronized
default access
Answer: Option
Explanation:

default access is the "package oriented" access modifier.

Option A and C are wrong because public and protected are less restrictive. Option B and D are wrong because abstract and synchronized are not access modifiers.

Discussion:
4 comments Page 1 of 1.

Shubham said:   6 years ago
Default access specifier is more restrictive and have access in same.

Pinkesh baghel said:   1 decade ago
Public - we can access anywhere.
Protected - we can access out of package.
Default - we can access in same package anywhere.

Due to this default is correct.

Ram said:   1 decade ago
But default access id public only.

Jaz said:   1 decade ago
Why? anyone can explain.

Post your comments here:

Your comments will be displayed after verification.