Skip to content

Programming Concepts

Which Java access modifier allows visibility only within the same class?

Difficulty: Easy

About this MCQ

This Easy Programming Concepts MCQ checks one syllabus fact.

The question is: “Which Java access modifier allows visibility only within the same class?”

The accepted answer is B. private. private is the person, body, or term that satisfies “Which Java access modifier allows visibility only within the same class” (option B). Option A (“public”) does not match the stem; it is a near-miss used to catch incomplete recall of private. Option C (“protected”) does not match the stem; it is a near-miss used to catch incomplete recall of private. Remaining alternatives (default) fall outside the same rule and should be eliminated once private is identified. Programming Concepts questions of this type reward precise definitions rather than approximate associations. Programming Concepts recall of this distinction is a regular item in FPSC, PPSC, NTS, and CSS papers.

Correct answer

B. private

Explanation

private is the person, body, or term that satisfies “Which Java access modifier allows visibility only within the same class” (option B). Option A (“public”) does not match the stem; it is a near-miss used to catch incomplete recall of private. Option C (“protected”) does not match the stem; it is a near-miss used to catch incomplete recall of private. Remaining alternatives (default) fall outside the same rule and should be eliminated once private is identified. Programming Concepts questions of this type reward precise definitions rather than approximate associations. Programming Concepts recall of this distinction is a regular item in FPSC, PPSC, NTS, and CSS papers.

Source: Java Language Specification

Tags: java, oop, access modifiers

Submitted by: MCQsHub Editorial

Related MCQs

More Programming Concepts MCQs