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.
- A. public
Why not A: “public” is not correct. 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 ste
- B. private ✓
- C. protected
Why not C: “protected” is not correct. 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 ste
- D. default
Why not D: “default” is not correct. 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 ste
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
- What does Variable refer to?
- What is the name for a programming construct that repeats a block of code while a condition is true?
- Which of the following best describes Loop?
- Identify the correct concept described as: a reusable block of code that performs a specific task and can be c...
- Function is best defined as which of the following?
- A technique where a function calls itself to solve smaller instances of a problem. What is this concept called...