Which access modifier allows a member to be accessed from within its own class only?
- default (no modifier)
- private
- protected
- public
In Java, the private access modifier restricts access to the member to within the same class only. It is used to encapsulate the implementation details and hide them from external classes. The other options allow varying degrees of access to the member from outside the class.
Loading...
Related Quiz
- Consider a scenario where you are required to store a large number of decimal values with high precision for a financial application. Which data type would be preferable and why?
- If you do not specify any access level modifier, the default access level will be ________.
- To avoid an infinite loop, the condition within the ________ loop must eventually be false.
- Deadlock occurs when two or more threads are blocked forever, each waiting for the other to ________.
- The @FunctionalInterface annotation is used to indicate that an interface is to be used with ________.