Question 172Asked in DSSSB TGT Computer Science, 25 Jun 2023, Shift 2 (12:30 PM)

Identify the descending order of strict access protection.

  1. APublic, protected, private, package
  2. BPrivate, protected, package, public
  3. CPublic, private, protected, package
  4. DPrivate, package, protected, public
Show answerHide answer

Correct answer: (B) Private, protected, package, public

Explanation

Note: the answer key gives (B), but in Java the order from most to least restrictive is private, package (default), protected, public (D). Protected is less strict than package access because it also allows subclasses in other packages.

From DSSSB TGT Computer Science PYQ, 25 Jun 2023, Shift 2 (12:30 PM)

This is question 172 of DSSSB TGT Computer Science PYQ, 25 Jun 2023, Shift 2 (12:30 PM). See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.