Mastering Java 2025 – 400 Free Practice Questions to Pass the 'Thinking in Java' Exam

Question: 1 / 510

Can inner classes be declared private or protected?

Yes

Inner classes can be declared with any access modifier, including private and protected. However, it is common practice to declare inner classes as private so that they cannot be accessed or instantiated by other classes. Protected inner classes can be accessed by subclasses, but it is not commonly used. Therefore, options B, C, and D are incorrect as they imply that inner classes cannot have certain access modifiers. The correct answer is option A, as it acknowledges that inner classes can be declared with any access modifier.

Get further explanation with Examzify DeepDiveBeta

No

Only private

Only protected

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy