Which of the following keywords are used to control access to a class member? (A) default (B) abstract (C) protected (D) interface (E) public

  1. All of these

  2. (A), (C) & (E)

  3. (C) & (E)

  4. (B), (C) & (E)


Correct Option: D

AI Explanation

To answer this question, we need to understand the keywords used to control access to class members in object-oriented programming.

Let's go through each option to understand which keywords are used to control access to a class member:

Option A) All of these - This option suggests that all of the given keywords are used to control access to a class member. However, this is not correct as not all of the keywords listed are used for access control.

Option B) (A), (C) & (E) - This option suggests that the keywords "default", "protected", and "public" are used to control access to a class member. This is partially correct, as "protected" and "public" are indeed access modifiers in Java, but "default" is not used specifically for access control.

Option C) (C) & (E) - This option suggests that only the keywords "protected" and "public" are used to control access to a class member. This is partially correct, as "protected" and "public" are indeed access modifiers in Java.

Option D) (B), (C) & (E) - This option suggests that the keywords "abstract", "protected", and "public" are used to control access to a class member. This is the correct answer. "protected" and "public" are access modifiers in Java, and "abstract" is used to define abstract methods or classes, which can also control access to class members indirectly.

Therefore, the correct answer is D) (B), (C) & (E) because the keywords "abstract", "protected", and "public" are used to control access to a class member.

Find more quizzes: