Inner Classes Questions and Answers
Practice ModeShowing 10 of 27 questions
Q21
Which of the following is true about anonymous inner classes?
Answer: Option D
Explanation: Anonymous inner classes can extend one class or implement one interface, but not both.
Q22
What is the bytecode file name for a member inner class?
Answer: Option C
Explanation: Member inner classes have bytecode files named OuterClass$InnerClass.class
Q23
Can we have static methods in a member inner class?
Answer: Option B
Explanation: Member inner classes cannot have static methods because they are associated with outer class instance.
Q24
Which inner class is commonly used for event handling in GUI?
Answer: Option D
Explanation: Anonymous inner classes are widely used for event handlers in GUI programming.
Q25
Can an outer class access private members of inner class?
Answer: Option B
Explanation: Outer classes can access all members of inner classes, including private ones.
Q26
What happens if you declare an inner class as final?
Answer: Option B
Explanation: Final inner classes cannot be extended, same as regular final classes.
Q27
Which of the following is NOT a type of inner class in Java?
Answer: Option C
Explanation: Abstract classes are a type of class, not a category of inner class.