Writing a good multiple-choice question is one of the highest-leverage things you can do before an exam — it forces you to understand not just the fact, but everything it's confused with.
A weak question has obviously-silly wrong answers. A strong one uses the adjacent concept — the thing this fact is genuinely confused with. So the recipe is:
Spring is full of these paired confusions. Keep a running "confusion bank" — this is your distractor goldmine:
| The fact | Its favourite confusion (→ your distractor) |
|---|---|
| CGLIB proxy (subclass) | JDK dynamic proxy (needs an interface) |
ApplicationContext (eager singletons) | BeanFactory (lazy) |
DispatcherServlet (front controller) | ApplicationContext (the container) |
singleton (one shared) | prototype (new each time) |
${...} (property placeholder) | #{...} (SpEL expression) |
@PostConstruct (init) | @PreDestroy (destroy) |
| Checked exceptions (no rollback by default) | Unchecked / RuntimeException (rolls back) |
REQUIRED (join or start) | REQUIRES_NEW (always new) |
@BeanName, ValuePopulator) as distractors — the exam does exactly this.STEM: <one precise question, one idea>
TYPE: single | select-all
KEY: <letter(s)>
OPTS: A) key
B) adjacent-concept distractor
C) plausible-fake distractor
D) common-misconception distractor
WHY: <key is right because…; best distractor is wrong because…>
SOURCE: <docs section / book page>
Fact: Spring uses a JDK dynamic proxy when the bean implements an interface, and a CGLIB proxy when it doesn't.
Mine the distractors — what's this confused with? Which proxy is which; whether CGLIB needs an
interface (it doesn't — that's JDK); whether final matters (it does for CGLIB).
Stem: A Spring bean class implements no interface but must be advised by an aspect. Which proxying strategy does Spring use, and what does it require?
A) A CGLIB proxy; the class and advised methods must not be final ← key
B) A JDK dynamic proxy; the class must implement an interface (adjacent-concept distractor)
C) A ReflectionProxy; no constraints apply (plausible-fake distractor)
D) No proxy is possible without an interface (common-misconception distractor)
Why: With no interface, Spring falls back to CGLIB, which proxies by subclassing — so final
classes/methods can't be advised. Needing an interface (B/D) describes JDK proxies. Source: Core docs §Proxying mechanisms.
Take this fact and build a question with the template before revealing my version:
singleton — one shared instance per container, created eagerly at startup.Stem: What is the default scope of a Spring bean, and how many instances does the container create?
A) singleton — one shared instance per container ← key
B) prototype — a new instance on every request (adjacent scope)
C) request — one instance per HTTP request (real-but-wrong scope)
D) default — one instance per injection point (plausible-fake scope)
Why: singleton is the default — one shared instance per container. B/C are real scopes but not the default; default (D) isn't a scope name at all. Source: Core docs §Bean Scopes.
Notice all four options are similar length and all name a scope — no giveaway.
Now flip roles — grade these questions. Each has one problem a good author would fix.