Computer Applications
The access specifier that gives least accessibility is:
- package
- public
- protected
- private
Encapsulation & Inheritance in Java
ICSE 2024
18 Likes
Answer
private
Reason ā In Java, access specifiers determine the visibility or accessibility of classes, methods, and variables. The three main access specifiers are:
public: Accessible from anywhere in the program.protected: Accessible within the same package and by subclasses even if they are in different packages.private: Accessible only within the same class.
private gives least accessibility as it provides the most restricted access.
Answered By
9 Likes