← All interview questions

Skill Zuno · skillzunos.com · Fullstack

Java Design Patterns interview questions

Prepare for Java Design Patterns interviews on Skill Zuno. This practice book covers Java Design Patterns interview questions across New, Easy, Medium, Hard, and Diff levels so you can work through real interview-style problems on skillzunos.com.

Open Java Design Patterns on Skill Zuno

Also see the Java Design Patterns tutorial.

Design patterns in Java are shown everywhere in the JDK and in Spring. Builder, factory, proxy, template method and observer are all at work in the standard library and frameworks, while enums, interfaces and lambdas give simpler versions of others. Interviews test Gang of Four patterns, SOLID principles and where patterns appear in Java libraries.

Sample Java Design Patterns interview questions

What is the best way to write a singleton in Java?

A single-element enum: enum Config { INSTANCE; }. The JVM guarantees one instance, it is thread-safe, and it is safe against reflection and serialisation, which break most other approaches.

When should you use the builder pattern?

When a class has many parameters, especially optional ones. A builder replaces long telescoping constructors with readable named steps and can produce an immutable object once build() validates it.

Where is the decorator pattern used in the JDK?

In java.io. new BufferedReader(new InputStreamReader(inputStream)) wraps one stream in another, each adding behaviour such as buffering or character decoding while keeping the same interface.

How do lambdas change the strategy pattern?

A strategy is often a single-method interface, so it can be passed as a lambda or method reference, such as list.sort(Comparator.comparing(Person::getAge)), with no separate strategy class.

Which patterns does Spring use?

Dependency injection and the factory pattern (BeanFactory), singleton scope for beans, proxies for @Transactional and AOP, template method in JdbcTemplate and RestTemplate, and observer through application events.

What you can practice

  • Java Design Patterns interview questions for beginners and experienced developers
  • Level-based practice: New, Easy, Medium, Hard, and Diff
  • Fullstack topics alongside Java Design Patterns on skillzunos.com

More Fullstack interview questions

All interview questions