What is Observer pattern?

  • A design pattern in which an object, called the composite, is composed of one-to-many other objects, in a tree-like structure, allowing the client to interact with individual objects and compositions of objects uniformly
  • A design pattern in which an object, called the decorator, adds or overrides behavior of an existing object, dynamically
  • A design pattern in which an object, called the proxy, acts as an intermediary between a client and a target object, forwarding requests from the client to the target object and vice versa
  • A design pattern in which an object, called the subject, maintains a list of its dependents and notifies them automatically of any changes to its state
The Observer pattern is a design pattern in which an object, called the subject, maintains a list of its dependents and notifies them automatically of any changes to its state. The Observer pattern is used to implement a publish/subscribe mechanism, allowing the subject to be decoupled from its dependents, and allowing multiple dependents to be notified of changes to the subject's state. The Observer pattern is used to implement event-driven systems.

What are the differences between a static class and a singleton class?

  • A singleton class can be extended, while a static class cannot be extended
  • A singleton class can have multiple instances, while a static class can only have one instance
  • A static class can be extended, while a singleton class cannot be extended
  • A static class can have multiple instances, while a singleton class can only have one instance
A static class can have multiple instances, while a singleton class can only have one instance. A static class is a class that is declared as static and can only access static variables and methods. A singleton class is a class that ensures that only one instance of the class exists in the JVM.

What is the Command and Query Responsibility Segregation (CQRS) Pattern?

  • A pattern in which read and write operations are separated into separate models.
  • A pattern that helps to avoid race conditions and deadlocks in multithreaded applications.
  • A pattern used to implement inter-process communication.
  • A pattern used to improve database performance by caching results in memory.
CQRS is a pattern that separates the responsibilities of querying data (read) from modifying data (write) into separate models, improving scalability and maintainability of the application.

What is Null Object pattern?

  • A design pattern in which a special object, called the null object, is used to represent the absence of a value, avoiding the need for explicit checks for null values
  • A design pattern in which an object, called the context, holds a reference to an instance of one of several possible concrete state objects, each of which represents a distinct state of the context and implements a common state interface
  • A design pattern in which an object, called the decorator, adds or overrides behavior of an existing object, dynamically
  • A design pattern in which an object, called the prototype, is used as a template to create new objects, without specifying their concrete classes
The Null Object pattern is a design pattern in which a special object, called the null object, is used to represent the absence of a value, avoiding the need for explicit checks for null values. The Null Object pattern is used to provide a default implementation of an interface, reducing the amount of error-prone null checks in the code. The Null Object pattern can also be used to simplify the code and reduce coupling by eliminating the need for explicit checks for null values.

What is the difference between the Decorator and Flyweight patterns?

  • The Decorator pattern is used to dynamically add or override behavior of an object, while the Flyweight pattern is used to reduce the number of objects created by sharing objects that are costly to create.
  • The Decorator pattern is used to dynamically add or override behavior of an object, while the Flyweight pattern is used to share objects that are costly to create.
  • The Decorator pattern is used to reduce the number of objects created by sharing objects that are costly to create, while the Flyweight pattern is used to dynamically add or override behavior of an object.
  • The Decorator pattern is used to share objects that are costly to create, while the Flyweight pattern is used to dynamically add or override behavior of an object.
The Decorator pattern is used to dynamically add or override behavior of an object, while the Flyweight pattern is used to share objects that are costly to create.

What is the purpose of the Decorator design pattern?

  • To attach additional responsibilities to an object dynamically.
  • To create objects that are interchangeable with their base classes.
  • To ensure that a class has only one instance and provide a global point of access to that instance.
  • To manage the flow of control between objects in a complex system.
The Decorator design pattern is used to attach additional responsibilities to an object dynamically. This allows for greater flexibility and modularity in the design of a system, as well as the ability to add or remove responsibilities as needed.

What does program to interfaces, not implementations mean?

  • This means that when designing software, the focus should be on defining the behavior of the components, rather than the specific implementations of those components.
  • This means that when designing software, the focus should be on defining the data structures and algorithms used by the components, rather than the specific implementations of those components.
  • This means that when designing software, the focus should be on defining the input and output of the components, rather than the specific implementations of those components.
  • This means that when designing software, the focus should be on defining the interfaces between different components, rather than the specific implementations of those components. This makes the code more flexible and easier to maintain, as it reduces the amount of coupling between components.
This means that when designing software, the focus should be on defining the interfaces between different components, rather than the specific implementations of those components. This makes the code more flexible and easier to maintain, as it reduces the amount of coupling between components.

What is the Null Object pattern?

  • A creational design pattern that provides a way to instantiate an object in a superclass, but allow subclasses to alter the type of objects that will be created.
  • A design pattern used to ensure a class has only one instance, while providing a global access point to this instance for the entire system.
  • A software design pattern that enables an object to be passed around as a value.
  • The Null Object pattern is a behavioral design pattern that provides a default object as a representative of "null" in the context of design patterns.
The Null Object pattern is a behavioral design pattern that provides a default object as a representative of "null" in the context of design patterns.

What is Command pattern?

  • A design pattern that converts a request into a standalone object, allowing the client to parametrize objects with different requests, queue a request, or log requests
  • A design pattern that passes a request through a chain of objects, allowing the objects in the chain to either handle the request or pass it on to the next object in the chain
  • A design pattern that provides a simplified interface to a complex system, allowing the client to interact with the system through a single, unified interface
  • A design pattern that uses shared objects to support large numbers of similar objects efficiently
Command pattern is a design pattern that converts a request into a standalone object, allowing the client to parametrize objects with different requests, queue a request, or log requests. The pattern involves creating a command class that encapsulates the request as an object, and passes the request to the invoker object. The invoker object then executes the command. This pattern can be useful in situations where you want to decouple the client from the receiver of the request, and where you want to provide a unified interface for undo and redo operations.

What is the difference between the State and Strategy patterns?

  • None of the above
  • The State and Strategy patterns are the same
  • The State pattern allows an object to alter its behavior when its internal state changes, while the Strategy pattern allows an object to change its behavior based on the context it is in
  • The State pattern allows an object to change its behavior based on the context it is in, while the Strategy pattern allows an object to alter its behavior when its internal state changes
The State pattern allows an object to alter its behavior when its internal state changes, while the Strategy pattern allows an object to change its behavior based on the context it is in