Difficulty: Medium
Correct Answer: It can be marked abstract.
Explanation:
Introduction / Context:
This question verifies which modifiers are legal for a class declared within a method (a method-local inner class). These rules differ from those for member and top-level classes.
Given Data / Assumptions:
Concept / Approach:
Method-local inner classes cannot use access modifiers (public, private, protected) or static. They are implicitly non-static. However, they may be declared abstract or final (depending on design). The important takeaway: abstract is allowed; public and static are not.
Step-by-Step Reasoning:
Verification / Alternative check:
Try compiling examples with each modifier to see which are accepted by the Java compiler.
Why Other Options Are Wrong:
Common Pitfalls:
Assuming all inner classes can be static or use access modifiers; the rules depend on where the class is declared.
Final Answer:
It can be marked abstract.
Discussion & Comments