0

.NET Best Practices and Design Patterns

Description: This test has the basic question related to Design pattern in .NET. This test is useful for CS, GATE and other aspirants.
Number of Questions: 15
Created by:
Tags: dot net design pattern cs gate Programming
Attempted 0/15 Correct 0 Score 0

Which of the following statements is incorrect about 'Repository' pattern?

  1. This pattern virtualises storage of entities in a persistent medium.

  2. It uses encapsulation technique to store the data.

  3. It allows the use of a common set of methods in the application.

  4. Its instance lifetime is that of the application domain.

  5. The repository uses a series of providers to connect to the source data.


Correct Option: D
Explanation:

There is no instance creation in this pattern and the instance creation is performed in Singleton pattern.

Which of the following statements is false about 'Singleton' design pattern?

  1. This pattern specifies the class creation for a particular object only.

  2. It is useful for exposing read-only data.

  3. This pattern virtualises storage of entities in a persistent medium.

  4. The static methods do not rely on instance data.

  5. If this is the first call to the method that returns the instance, the Singleton creates an instance, populates it with any required data and returns that instance.


Correct Option: C
Explanation:

Singleton pattern does not store entities for the persistence medium.

Which of the following statements is incorrect about 'Chain of Responsibility' design pattern?

  1. There is less coupling during the request sent to the receiver.

  2. There is a chaining process to manage the request for the objects.

  3. The several linked objects respond to a request or hand it off to the object next in line.

  4. The frequency of chained objects propagates from high to low.

  5. This pattern encapsulates a request as an object.


Correct Option: E
Explanation:

It does not encapsulate the request.

Which of the following is a correct statement about 'Interpreter' design pattern?

  1. It represents and interprets the component behaviour.

  2. It encapsulates a request as an object.

  3. It avoids coupling the sender of a request to its receiver.

  4. It defines the creation of a class for which only a single instance can exist.

  5. It virtualises storage of entities in a persistent medium.


Correct Option: A
Explanation:

This pattern defines a representation along with an interpreter that uses the representation to interpret the behaviour of the components of the application.

Which of the following is a false statement about 'Model-View-Controller' patterns?

  1. These provide reusability to the business logic in the application components.

  2. The model has information about the data in the application.

  3. The controller or presenter links the model and the view.

  4. These patterns have a series of providers to connect to the source data.

  5. The user interaction with the view raises events in the controller, which updates the model.


Correct Option: D
Explanation:

MVC patterns have only single providers to connect the data.

Which of the following is a correct statement about 'Bridge' design pattern?

  1. It declares an interface to receive and act in extrinsic state.

  2. It is used to make an independent implementation for the abstract view.

  3. It separates the construction of a complex object from its representation.

  4. It specifies an abstract interface for creating parts of a product object.

  5. It constructs an object using the builder interface.


Correct Option: B
Explanation:

This pattern decouples an abstraction from its implementation, so that the two can vary independently.

Which of the following is a correct statement about 'Iterator' design pattern?

  1. It is used to specify the objects with their underlying representation.

  2. It encapsulates a request as an object.

  3. It avoids coupling the sender of a request to its receiver.

  4. It defines the creation of a class for which only a single instance can exist.

  5. It virtualises storage of entities in a persistent medium.


Correct Option: A
Explanation:

This pattern provides a way to access the elements of an aggregate object sequentially without exposing its underlying representation.

Which of the following is an incorrect statement about 'Proxy' pattern?

  1. It falls under 'Structural' pattern.

  2. It maintains a reference to an object of type implementer.

  3. It defines an interface having members that will be implemented by RealSubject and Proxy class.

  4. This is a class which we want to use more efficiently by using proxy class.

  5. This is a class which holds the instance of RealSubject class and can access RealSubject class members as required.


Correct Option: B
Explanation:

Proxy pattern does not use such object reference. Bridge pattern is used for that.

Which of the following is an incorrect statement about 'Strategy' design pattern?

  1. It declares an interface common to all supported algorithms.

  2. A strategy interface is used to implement the class for the algorithms.

  3. It allows an object to alter its behaviour when its internal state changes.

  4. It maintains a reference to a strategy object.

  5. It may define an interface that lets strategy access its data.


Correct Option: C
Explanation:

It can alter the behaviour of the object. State pattern is used to alter the state of the object.

Which of the following is a false statement about 'Adapter' design pattern?

  1. It connects two incompatible interfaces.

  2. It defines the domain-specific interface that a client uses.

  3. It collaborates with objects conforming to any interface.

  4. It adapts the interface adaptee to the target interface.

  5. It defines an existing interface that needs adapting.


Correct Option: C
Explanation:

This is incorrect.

Which of the following is a false statement about 'Adapter' design pattern?

  1. It is used to combine two or more interfaces.

  2. There are domain-specific interface applied for the client.

  3. It defines an existing interface that needs adapting.

  4. It collaborates with objects conforming to the target interface.

  5. It extends the interface defined by abstraction.


Correct Option: E
Explanation:

It does not extend the interface for abstraction purpose.

Which of the following is a false statement about 'Prototype' design pattern?

  1. It declares an interface for cloning itself.

  2. It implements an operation for cloning itself.

  3. It defines the abstraction interface.

  4. It creates a new object by asking a prototype to clone itself.

  5. It uses a prototype instance for each object.


Correct Option: C
Explanation:

Prototype pattern does not define any abstraction interface. Bridge pattern defines such interface.

Which of the following is an incorrect statement about 'Observer' design pattern?

  1. This pattern defines a one-to-many dependency between objects.

  2. It collaborates with objects conforming to the target interface.

  3. It knows its observers.

  4. An updatable interface is needed for all the objects to be notified.

  5. It stores state of interest to ConcreteObserver.


Correct Option: B
Explanation:

This is incorrect.

Which of the following is an incorrect statement about 'Memento' design pattern in .NET?

  1. It captures and externalises an object's internal state, so that the object can be restored to this state later.

  2. It protects against access of objects by other than the originator.

  3. It defines an object that encapsulates how a set of objects interact.

  4. The internal state of the memento is accessible by the originator only.

  5. It never operates on or examines the contents of a memento.


Correct Option: C
Explanation:

It does not encapsulate the set of objects. Mediator pattern is used for that.

Which of the following statements is false about 'Flyweight' design pattern?

  1. There must be an interface to specify the state of the objects.

  2. It converts the interface of a class into another interface clients expect.

  3. The state of storage must be intrinsic.

  4. Not all Flyweight subclasses need to be shared.

  5. It uses sharing to support large numbers of fine-grained objects efficiently.


Correct Option: B
Explanation:

This pattern does not connect the two interfaces.

- Hide questions