120 questions for “Design Patterns in Java”

Found in 1 field. Select a question to see its full answer.

Information Technology

120 questions in 6 technologies

#QuestionTechnologyTopicLevel
1What is the difference between composition and inheritance as ways to reuse code, and why does the design principle "favor composition over inheritance" generally guide modern Java design (including many design patterns themselves)? Java › Design Patterns in JavaJavaDesign Patterns in JavaIntermediate
2What is the Strategy pattern, and how do Java 8's functional interfaces and lambdas make implementing it significantly more concise than the traditional interface-plus-implementation-classes approach? Java › Design Patterns in JavaJavaDesign Patterns in JavaIntermediate
3What is the Adapter pattern, and when would you use it to make an existing class compatible with an interface it wasn't originally designed to implement? Java › Design Patterns in JavaJavaDesign Patterns in JavaIntermediate
4How would you implement the Visitor pattern in Java to add new operations to an existing class hierarchy without modifying those classes, and how do Java's sealed classes and pattern matching (switch expressions) provide a modern alternative? Java › Design Patterns in JavaJavaDesign Patterns in JavaAdvanced
5What is the Singleton pattern, and how would you implement a thread-safe Singleton in Java? Java › Design Patterns in JavaJavaDesign Patterns in JavaBeginner
6How would you implement the Observer pattern in Java, and how does it compare to using the built-in PropertyChangeSupport or a reactive streams library? Java › Design Patterns in JavaJavaDesign Patterns in JavaAdvanced
7How would you implement the Decorator pattern in Java, and how does java.io's InputStream/OutputStream class hierarchy exemplify this pattern in the JDK itself? Java › Design Patterns in JavaJavaDesign Patterns in JavaAdvanced
8How would you implement the Proxy pattern to add lazy initialization to an expensive-to-create object, and how does this differ structurally from the Decorator pattern despite both wrapping an object behind a shared interface? Java › Design Patterns in JavaJavaDesign Patterns in JavaAdvanced
9What is the Factory Method pattern's simplest form -- a basic static factory returning different subtype instances based on input -- and why might you prefer it over exposing constructors directly? Java › Design Patterns in JavaJavaDesign Patterns in JavaBeginner
10What is the Template Method pattern, and how is it used to define the skeleton of an algorithm while letting subclasses customize specific steps? Java › Design Patterns in JavaJavaDesign Patterns in JavaIntermediate