Monday, January 7, 2013

Design Patterns Short Test


A time ago I prepared this test for a course in the internal training program of the company I worked for. I gave a quick training of design patterns using the most common ones as described in the Gang of Four book. You can get it from my drive in Google, or read it here. 


  1. The follow applicability a system should be configured with one of multiple families of products.”, describes the pattern:
    1. Builder
    2. Decorator
    3. Singleton
    4. Abstract Factory

  1. The diagram below is read as
                             
  1. A is an aggregate class
  2. B implements A
  3. B extends from A
  4. A is an abstract class

  1. These two patterns can be used for undo operations.
    1. Decorator & Visitor
    2. Memento & Command
    3. Factory Method & Chain of Responsibility
    4. Command & Observer

  1. Loose coupling is when
    1. A class has just a small number of lines of code
    2. An application is designed with a small set of classes
    3. Reflection is used to instance the objects
    4. A class has little knowledge of another implementing class


  1. Which pattern uses a pool to share objects instead of instancing an excessive amount of them?
    1. Adapter
    2. Flyweight
    3. Proxy
    4. None of above


  1. Which of the follow is a general principle of class designing?
    1. Favor inheritance over composition
    2. Avoid polyphormism
    3. Use only creational patterns
    4. Favor composition over inheritance

  1. Incompatible interfaces can be overcome with the pattern:
    1. Interpreter
    2. Observer
    3. Adapter
    4. Bridge

  1. Which statements are correct about design patterns?
    1. They are proven solutions to common design problems
    2. They benefit code reusability
    3. They provide a common language among programmers
    4. All mentioned

  1. The capacity to add responsibilities on runtime to individual objects, that is, without affecting other objects, can be accomplished with this pattern.
    1. Decorator
    2. Proxy
    3. State
    4. Façade

  1. One applicability of the Observer pattern is :
    1. When a class should have all its attributes declared as public
    2. When an object should be able to notify others about an event
    3. When a class should have all its methods declared as public
    4. All of them

  1. Which pattern is represented in this diagram?
    1. Composite
    2. Prototype
    3. Façade
    4. Singleton

  1. Which pattern is being used in this line of code?
MyPattern s1 = MyPattern.Instance();

  1. Singleton
  2. Prototype
  3. Factory Method
  4. Command

  1. Which type of pattern is described in the next sentence: “Are concerned with algorithms and the assignments of responsibilities between objects”
    1. Creational
    2. Structural
    3. Behavioral
    4. None

  1. This pattern has two types: virtual & security.
    1. Façade
    2. Iterator
    3. Singleton
    4. Proxy

  1. Suppose there is a class that has a request, but you don’t want to hard code the class that will satisfy that request, but more than one class can satisfy it. You will use the follow pattern:
    1. Façade
    2. Chain of responsibility
    3. Proxy
    4. Command

No comments:

Post a Comment