Question:

Which of the following is \underline{NOT an access specifier?}

Show Hint

In Java, \textbf{public}, \textbf{private}, and \textbf{protected} are explicit access specifier keywords. If nothing is written, it becomes \textbf{default} or \textbf{package-private} access.
  • private
  • protected
  • package
  • public
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is C

Solution and Explanation

Step 1: Understand what an access specifier is.
An access specifier controls the visibility or accessibility of classes, methods, variables, and constructors in object-oriented programming. It decides from where a member can be accessed.
Step 2: Recall the common access specifiers in Java.
In Java, the commonly used access specifiers are:
  • public -- accessible from everywhere.
  • private -- accessible only within the same class.
  • protected -- accessible within the same package and also in subclasses.
  • default -- when no access specifier is written, it is called default or package-private access.
Step 3: Compare the given options.
  • (A) private: This is a valid access specifier.
  • (B) protected: This is also a valid access specifier.
  • (C) package: This is not an actual keyword used as an access specifier. The correct term is default access or package-private access, but package itself is not an access specifier keyword.
  • (D) public: This is a valid access specifier.
Step 4: Conclusion.
Therefore, the option which is \underline{NOT} an access specifier is package.
Final Answer:package.
Was this answer helpful?
0
0

Questions Asked in ICSE Class X board exam

View More Questions