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

What is the Visitor pattern?

  • A behavioral design pattern that lets you pass requests along a dynamic chain of receivers until one of them handles it.
  • A behavioral design pattern that separates an algorithm from an object structure on which it operates. The pattern allows you to define a new operation without changing the classes of the objects on which it operates.
  • A creational design pattern that uses factory methods to deal with the problem of creating objects without specifying the exact class of object that will be created.
  • A structural design pattern that allows you to compose objects into tree structures to represent part-whole hierarchies.
A behavioral design pattern that separates an algorithm from an object structure on which it operates. The pattern allows you to define a new operation without changing the classes of the objects on which it operates.

Name some of the design patterns used in JDK library.

  • Abstract Factory, Builder, Factory Method, Singleton
  • Adapter, Facade, Observer, Prototype
  • Chain of Responsibility, Command, Interpreter, Iterator
  • Decorator, Mediator, State, Strategy
Some of the design patterns used in the JDK library include Decorator, Mediator, State, and Strategy. These patterns are used in various classes and APIs of the Java Standard Library to provide a clean and efficient implementation of common design problems.

How can you create Singleton class in Java?

  • By declaring a private constructor and a public static method that returns the only instance of the class
  • By declaring all of its variables and methods as final
  • By declaring all of its variables and methods as static
  • By implementing the Cloneable interface
A Singleton class in Java can be created by declaring a private constructor and a public static method that returns the only instance of the class. This ensures that there is only one instance of the class in the JVM and that it can be easily accessed by other objects in the system.

What is the purpose of the MVC pattern?

  • The Model-View-Controller (MVC) pattern is used to create a modular and scalable code structure. The Model represents the data, the View displays the data, and the Controller handles user interactions and updates the Model.
  • The Model-View-Controller (MVC) pattern is used to create a simple, flexible and reusable code structure. The Model represents the data, the View displays the data, and the Controller handles user interactions and updates the Model.
  • The Model-View-Controller (MVC) pattern is used to provide a common interface for accessing application data. The Model represents the data, the View displays the data, and the Controller manages the flow of data between the Model and the View.
  • The Model-View-Controller (MVC) pattern is used to separate application logic from presentation logic and data management. The Model represents the data, the View displays the data, and the Controller manages the flow of data between the Model and the View.
The MVC pattern separates application logic into three distinct components, the Model, View and Controller, in order to create a flexible, reusable and scalable code structure.

What is the Deadly Diamond of Death?

  • The Deadly Diamond of Death is a situation in which a class has too many responsibilities and becomes overly complex.
  • The Deadly Diamond of Death is a situation in which a class inherits from two classes with conflicting attributes.
  • The Deadly Diamond of Death is a situation in which a class inherits from two classes with conflicting implementations of a method.
  • The Deadly Diamond of Death is a situation in which multiple inheritance results in ambiguity and complexity in the inheritance hierarchy of a system.
The Deadly Diamond of Death is a situation in which multiple inheritance results in ambiguity and complexity in the inheritance hierarchy of a system. This can lead to difficulty in maintaining the system and understanding its behavior.

What is the difference between the Bridge and Filter patterns?

  • The Bridge pattern allows for loose coupling between the sender of a request and its receivers, while the Filter pattern provides a unified interface to a set of interfaces in a subsystem.
  • The Bridge pattern decouples an abstraction from its implementation, allowing the two to vary independently. The Filter pattern provides a way to filter requests that pass through a set of handlers.
  • The Bridge pattern is used to create objects based on a blueprint, while the Filter pattern provides a way to convert the interface of a class into another interface clients expect.
  • The Bridge pattern is used to filter requests that pass through a set of handlers, while the Filter pattern decouples an abstraction from its implementation.
The Bridge pattern decouples an abstraction from its implementation, allowing the two to vary independently, while the Filter pattern provides a way to filter requests that pass through a set of handlers.

What is Prototype pattern?

  • A design pattern that creates objects by cloning existing objects, rather than creating new instances from scratch
  • A design pattern that creates objects in a step-by-step manner, allowing for more control over the object creation process
  • A design pattern that helps to reduce the number of objects in the system, making it more efficient
  • A design pattern that promotes the loose coupling between objects, making the system easier to maintain and extend
Prototype pattern is a design pattern that creates objects by cloning existing objects, rather than creating new instances from scratch. This pattern involves implementing a prototype interface, which is used to create a new instance of the object. The new instance is a copy of the existing object, with any changes made to the copy not affecting the original.