Skip to Content
InterviewDesign Patterns

Design Patterns Interview Questions

Design Patterns Fundamentals

  1. What are design patterns? What is their purpose?
  2. What are the categories of design patterns?
  3. What are creational patterns, structural patterns, and behavioral patterns?
  4. What are the six principles of design patterns?
  5. What is the Single Responsibility Principle (SRP)?
  6. What is the Open-Closed Principle (OCP)?
  7. What is the Liskov Substitution Principle (LSP)?
  8. What is the Dependency Inversion Principle (DIP)?
  9. What is the Interface Segregation Principle (ISP)?
  10. What is the Law of Demeter (LoD)?

Creational Patterns

Singleton Pattern

  1. What is the Singleton pattern? What are its application scenarios?
  2. What are the implementation methods of Singleton pattern?
  3. What is eager initialization Singleton? What are its pros and cons?
  4. What is lazy initialization Singleton? How to make it thread-safe?
  5. What is Double-Checked Locking (DCL) Singleton? Why use volatile?
  6. What is static inner class Singleton?
  7. What is enum Singleton? Why is enum recommended for implementing Singleton?
  8. How to prevent Singleton pattern from being broken by reflection?
  9. How to prevent Singleton pattern from being broken by serialization?
  10. Is Spring’s Singleton Bean thread-safe?

Factory Pattern

  1. What is Simple Factory pattern? What are its pros and cons?
  2. What is Factory Method pattern? What are the differences from Simple Factory?
  3. What is Abstract Factory pattern? What are the differences from Factory Method?
  4. What are the application scenarios of Factory pattern?
  5. Where does Spring use Factory pattern?

Builder Pattern

  1. What is Builder pattern? What is its purpose?
  2. What are the differences between Builder pattern and Factory pattern?
  3. What are the application scenarios of Builder pattern?
  4. What design pattern does StringBuilder use?

Prototype Pattern

  1. What is Prototype pattern? What is its purpose?
  2. What are shallow copy and deep copy?
  3. How to implement deep copy?
  4. What are the application scenarios of Prototype pattern?
  5. Is Object’s clone() method shallow copy or deep copy?

Structural Patterns

Proxy Pattern

  1. What is Proxy pattern? What is its purpose?
  2. What are the categories of Proxy pattern?
  3. What is static proxy? What are its pros and cons?
  4. What is dynamic proxy? What are the implementation methods?
  5. What is the implementation principle of JDK dynamic proxy?
  6. What is the implementation principle of CGLIB dynamic proxy?
  7. What are the differences between JDK dynamic proxy and CGLIB proxy?
  8. What design pattern does Spring AOP use?
  9. What are the application scenarios of Proxy pattern?

Adapter Pattern

  1. What is Adapter pattern? What is its purpose?
  2. What are the categories of Adapter pattern?
  3. What are the differences between Adapter pattern and Decorator pattern?
  4. What are the application scenarios of Adapter pattern?
  5. What pattern does HandlerAdapter in Spring MVC use?

Decorator Pattern

  1. What is Decorator pattern? What is its purpose?
  2. What are the differences between Decorator pattern and inheritance?
  3. What are the application scenarios of Decorator pattern?
  4. What design pattern does Java I/O stream use?

Bridge Pattern

  1. What is Bridge pattern? What is its purpose?
  2. What are the application scenarios of Bridge pattern?
  3. What design pattern does JDBC driver use?

Facade Pattern

  1. What is Facade pattern? What is its purpose?
  2. What are the application scenarios of Facade pattern?
  3. What are the pros and cons of Facade pattern?

Composite Pattern

  1. What is Composite pattern? What is its purpose?
  2. What are the application scenarios of Composite pattern?
  3. What design pattern does file system use?

Flyweight Pattern

  1. What is Flyweight pattern? What is its purpose?
  2. How does Flyweight pattern reduce memory usage?
  3. What are the application scenarios of Flyweight pattern?
  4. What design pattern does String constant pool use?
  5. What design pattern does Integer cache use?

Behavioral Patterns

Template Method Pattern

  1. What is Template Method pattern? What is its purpose?
  2. What are the application scenarios of Template Method pattern?
  3. What design pattern does AbstractList use?
  4. Where does Spring use Template Method pattern?

Strategy Pattern

  1. What is Strategy pattern? What is its purpose?
  2. What are the differences between Strategy pattern and Simple Factory pattern?
  3. What are the application scenarios of Strategy pattern?
  4. How to eliminate if-else?
  5. What design pattern does Comparator use?

Observer Pattern

  1. What is Observer pattern? What is its purpose?
  2. What are the roles in Observer pattern?
  3. What are the application scenarios of Observer pattern?
  4. What design pattern does Spring’s event mechanism use?
  5. What design pattern is used in MVC pattern?

Chain of Responsibility Pattern

  1. What is Chain of Responsibility pattern? What is its purpose?
  2. What are the application scenarios of Chain of Responsibility pattern?
  3. What design pattern does Servlet’s Filter use?
  4. What design pattern does Spring’s interceptor use?

Iterator Pattern

  1. What is Iterator pattern? What is its purpose?
  2. What are the application scenarios of Iterator pattern?
  3. What design pattern does Java Collections Framework use?

Command Pattern

  1. What is Command pattern? What is its purpose?
  2. What are the application scenarios of Command pattern?
  3. What design pattern does Runnable interface use?

State Pattern

  1. What is State pattern? What is its purpose?
  2. What are the differences between State pattern and Strategy pattern?
  3. What are the application scenarios of State pattern?
  4. What design pattern can be used for order status transitions?

Memento Pattern

  1. What is Memento pattern? What is its purpose?
  2. What are the application scenarios of Memento pattern?
  3. How to implement undo and redo functionality?

Mediator Pattern

  1. What is Mediator pattern? What is its purpose?
  2. What are the application scenarios of Mediator pattern?
  3. What design pattern concept does MQ message queue use?

Visitor Pattern

  1. What is Visitor pattern? What is its purpose?
  2. What are the application scenarios of Visitor pattern?

Interpreter Pattern

  1. What is Interpreter pattern? What is its purpose?
  2. What are the application scenarios of Interpreter pattern?
  3. What design pattern does Spring’s EL expression use?

Comprehensive Questions

  1. Which design patterns have you used in real projects?
  2. How to choose appropriate design patterns?
  3. What problems can overuse of design patterns cause?
  4. What are the differences between design patterns and architectural patterns?
  5. What design patterns are used in the Spring framework?
Last updated on