“Which design patterns have you used?” is one of the most common senior Java questions, and the follow-ups are where people struggle. Here are the patterns asked about most in 2026, what to say about each, and the classic “abstract class vs Abstract Factory” trap.
Abstract class vs Abstract Factory
An abstract class is a Java feature: a class you can't instantiate, which may have abstract methods that subclasses must implement. The Abstract Factory is a creational pattern: an interface that creates families of related objects (a button and a checkbox for one theme) without naming their concrete classes. A factory is often written with an abstract class or interface, which is where the confusion comes from.
interface Button { void render(); }
interface Checkbox { void render(); }
interface UiFactory {
Button button();
Checkbox checkbox();
}
class DarkFactory implements UiFactory {
public Button button() { return () -> System.out.println("dark button"); }
public Checkbox checkbox() { return () -> System.out.println("dark checkbox"); }
}
// The screen only knows UiFactory: switch themes by passing a different factory.
class Screen {
Screen(UiFactory ui) { ui.button().render(); ui.checkbox().render(); }
}
Factory Method vs Abstract Factory
Factory Method: one method that subclasses override to decide which single object to create. Abstract Factory: an object with several creation methods for a family of products that must match.
Singleton
One instance for the whole application. Say how you'd make it thread-safe: an enum singleton or the
holder-class idiom, and mention that in Spring, beans are singletons by default, so you rarely write one by hand.
Follow-up: singletons make testing harder because they hide dependencies.
Builder
For objects with many optional fields: readable construction and immutable results instead of long constructors.
Lombok's @Builder and StringBuilder-style APIs are everyday examples.
Strategy
Swap an algorithm at run time behind one interface: payment providers, discount rules, sorting. In Spring, inject
all implementations as a Map<String, PaymentStrategy> and pick by key, which removes long
if-else chains.
Observer
Notify many listeners when something changes. Spring's ApplicationEvent and Kafka-style
publish/subscribe are the modern versions.
Decorator and Proxy
Decorator adds behaviour by wrapping (Java I/O streams). Proxy controls access to an object: Spring's
@Transactional and @Cacheable work through proxies, which is why calling such a method from
inside the same class skips them.
How to answer “which patterns have you used?”
Name two or three, each with a sentence about where: “Strategy for our payment providers, Builder for API request objects, and Spring's proxies whenever we use @Transactional.” Then stop and let them pick one to go deeper.
Practise design pattern questions
Pick Java → System design or OOP in our AI mock interview and answer out loud, 30 seconds each.
Related: the Iris Software interview where this was asked and Java interview questions 2026.