ITELEC

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

ACE

A Proxy Pattern is best used to : A) control access to a remote object B) assemble complex objects C) fetch a resource-intensive object when requested by a client D) store common redundant data between large number of objects E) extract out from the calling client the access or connection logic needed to call an object

CD

A pattern that is intended to provide a means to define a family of algorithms and encapsulate each one as an object for interchangeable use: A) A client needs to use a family of related objects B) A change to an object requires changing other objects C) A client needs to choose from multiple algorithms D) Multiple classes are the same but differ only in their behaviors

A. Strategy Pattern

A pattern that is intended to provide a means to define a family of algorithms and encapsulate each one as an object for interchangeable use: A) Strategy Pattern B) Abstract Factory Pattern C) Visitor Pattern D) State Pattern

B. Facade Pattern

Big portion of clients are remotely invoking methods in your system, the surface area exposed to clients includes fine-grained methods, which of course causes network overhead. Which pattern would improve your system performance in this case? A) Chain of Responsibility Pattern B) Facade Pattern C) Command Pattern D) Adapter Pattern

C. Proxy

Design pattern used to implement Lazy Loading A) Adapter B) Mediator C) Proxy D) Chain of Responsibility

C. Observer

In the Publish-Subscribe messaging model, the subscribers register themselves in a topic and are notified when new messages arrive to the topic. Which pattern does most describe this model? A) Adapter B) Notifier C) Observer D) State

A. Flyweight

It is a pattern used to minimize memory use by letting similar objects share as much data as possible stored in a sharable object. A) Flyweight B) Composite C) Iterator D) Momento

D. Factory Method

It is also known as Virtual Constructor and it is used to define an interface for creating an object but letting the subclass decide which class to instantiate. A) Builder B) Abstract Factory C) Prototype D) Factory Method

C. Decorator

It is also known as Wrapper, it is used when subclassing is not possible or practical to add functionality and it is used to add functionality at runtime A) Composite B) Adapter C) Decorator D) Proxy

B. Command Pattern

It is known as Action or Transaction and is used to encapsulate a request as an object to support rollback, logging, or transaction functionality A) Chain of Responsibility Pattern B) Command Pattern C) Observer Pattern D) Strategy Pattern

java.util

Packages that contains all collection classes

Cloning

Process of creating exact copy of the existing object

D. Virtual Constructor

The factory method design pattern is also known as: A) Abstract factory B) Abstract Constructor C) Virtual factory D) Virtual Constructor

True

There are no direct implementation of the Collection<E> interface

B. Proxy

This pattern known as Surrogate A) Adapter B) Proxy C) Facade D) Method Factory

Vector

Type of List with synchronized access

BC

What are the common implementation strategies of the GOF Adapter pattern? A) Factory Adapter B) Object Adapter C) Class Adapter D) Interface Adapter

BCD

What are the consequences of applying the Builder design pattern? A) it makes the designed product hierarchies exchangeable B) it's easier to introduce new product implementation C) it separates the prodcut construction from it's representation D) the director has fine control over the product creation procedure

B

What are the consequences of applying the GOF Adapter pattern? A) it will improve the system performance B) it makes the client code easier by interacting with a single uniform interface C) it must modify the adaptee class D) it establishes a flexible mechanism for instantiating an object in comparison to the usual java constructor instantiation.

B

What are the consequences of applying the GOF Bridge pattern? A) it makes implementing the client code easier by interacting with a single uniform interface B) it decouples an abstraction from its implementation so that the two can vary independently C) it will decrease the system extesibility D) the client code can traverse tree structures of arbitrary depth recursively

AD

What are the consequences of applying the GOF Composite pattern? A) the client code can traverse tree structures of arbitrary depth recursively B) increases the coupling between the client code and the composite structre C) it will improve the system performance D) the client code can access both the individual objects and compositions in a uniform manner

CD

What are the consequences of applying the GOF Decorator pattern? A) it makes the client code easier by interacting with a single uniform interface B) the client code can traverse tree structures of arbitrary depth recursively C) it will will not alter the class inheritance hierarchy to accommodate for the additional functionality D) it allows to nest layers of decorators to add more functionality

ABC

What are the consequences of applying the GOF Decorator pattern? A) the client code can gradually add more functionality as it nests more layers of decorators B) it assigns more functionality to an object without sub-classing it C) it makes it harder to identify the the decorated and the decorator objects D) the client code can traverse tree structures of arbitrary depth recursively

ACD

What are the consequences of applying the GOF Prototype pattern? A) each concrete prototype class must implement the clone method B) it makes it easier for a certain family of objects to work together C) it enable the client code to register an new concrete prototype instance at run time D) it reduces of the class hierarchy as compared to the other factory design patterns

A

What are the consequences of applying the GOF Singleton pattern? A) it introduces thread safety issue when the singleton instance is instantiated on demand B) the client code can creates multiple instances at run time C) it reduces of the class hierarchy as compared to the other factory design patterns D) it makes it easier for a certain family of objects to work together

AC

What are the consequences of applying the GOF factory method pattern? A) it decouples the client code from the application specific classes B) it makes the designed product families exchangeable C) it establishes a flexible mechanism for instantiating an object in comparison to the usual java constructor instantiation.

BD

What are the consequences of applying the abstract factory pattern? A) it will be much easier to introduce new family of products B) it makes it easier for a certain family of objects to work together C) it makes it easier for the client to deal with tree-structured data D) it makes the designed product families exchangeable

Design patterns help you analyze the more abstract areas of a program by providing concrete, well-tested solutions. Design patterns help you write code faster by providing a clearer picture of how you're implementing the design. Design patterns encourage code reuse and accommodate change by supplying well-tested mechanisms for delegation and composition, and other non-inheritance based reuse techniques. Design patterns encourage more legible and maintainable code by following well-understood paths.

What benefits does patterns provide

A group of objects

What is Collection in Java? A. A group of objects B. A group of classes C. A group of interfaces D. None of the mentioned

AC

What is the difference between an adapter and a decorator? A) The adapter adds no functionalities to the adaptee class, whereas the Decorator extends the functionality of the object B) The adapter is a creational pattern, whereas the decorator is a structural design pattern C) Both introduce a level of indirection between a client class and a class it uses

Set

What type of collection would we use if we wanted no duplicates?

four one three two

What will be the output of the program? TreeSet map = new TreeSet(); map.add("one"); map.add("two"); map.add("three"); map.add("four"); map.add("one"); Iterator it = map.iterator(); while (it.hasNext() ) { System.out.print( it.next() + " " ); }

AB

What would lead you to apply the builder design pattern? A) To abstract steps of construction of objects so that different implementations B) To apply the same object construction procedure on variety of representations C) To translates one interface for a class into a compatible interface D) To restrict instantiation of a class to one object

Polymorphism

When child class object pass into parent class reference

ACD

When would you use the GOF Adapter design pattern? A) to translates an existing class interface into a compatible target interface B) to improve your system performance C) to transforming the client code data into appropriate format expected by the target interface D) to allow classes with incompatible interfaces to work together

CD

When would you use the GOF Bridge design pattern? A) to implement lazy loading of expensive objects B) to improve system reliability and scalability C) to decouple an abstraction from its implementation so that the two can vary independently D) to hide the implementation details from the client code of your design

C

When would you use the GOF Composite design pattern? A) to decouple an abstraction from its implementation so that the two can vary independentl B) to translates an existing class interface into a compatible target interface C) to arrange object hierarchies such that the client code can access both the individual objects and compositions in a uniform manner D) to improve the system overall performance

BD

When would you use the GOF Decorator design pattern?\ A) to translates an existing class interface into a compatible target interface B) to assign more functionality to an object without sub-classing it C) to decouple an abstraction from its implementation so that the two can vary independently D) to nest layers of decorators to add more functionality

BC

When would you use the GOF Factory method design pattern? A) To ensure that a certain group of related objects are used together B) To control the creation of an object based on a established interface C) To allow the concrete implementation to determine the subclass to construct. D) To abstract steps of construction of complex objects

BC

When would you use the GOF Prototype design pattern? A) To abstract steps of construction of complex objects B) To determine the classes to be instantiated at run time C) To avoid the proliferation of the class hierarchy D) To restrict class instantiation to one object

BC

When would you use the GOF Singleton design pattern? A) to ensure that a certain group of related objects are used together B) to limit the class instantiation to one object C) to provide global access to once instance across the system D) to abstract steps of construction of complex objects

BCD

When would you use the GOF abstract factory pattern? A) To design a structure which has a uniform interface for both compositions of objects and individual objects. B) To ensure that a certain group of related objects are used together C) The client which uses your design is not dependent on how the object are created or connected together D) To decouple the creation of objects from their usage

AB

When would you use the GOF builder design pattern? A) to abstract steps of construction of complex objects B) to build different representations of complex objects based on the concrete implementations of construction procedure C) to establish an interface for creating an object, but let the concrete implementations decide which subclass to instantiate D) to encapsulate a family of individual factories that have a common theme

C. to treat individual objects and compositions uniformly

Which best defines the use of the Composite Design Pattern? A) the Composite design pattern allows the clients to build a complex object of smaller different ones B) the Composite design pattern allows adding and removing functionality dynamically C) the Composite design pattern allows the clients to treat individual objects and compositions uniformly

ArrayList

Which collection class allows you to grow or shrink its size and provides indexed access to its elements, but whose methods are not synchronized?

B. Composite Design Pattern

Which design pattern is used in the Java AWT Abstract Window Toolkit? A) Adapter design pattern B) Composite design pattern C) Bridge design pattern D) Proxy design pattern

B. Factory Method Design Pattern

Which design pattern is used in the Java Database connectivity JDBC(TM)? A) Builder design pattern B) Factory method design pattern C) Abstract Factory design Pattern D) Singletone design Pattern

B. Decorator Design Pattern

Which design pattern is used in the Java InputStream, OutputStream, Reader, Writer hierarchies? A) Adapter design pattern B) Decorator design pattern C) Composite design pattern D) Bridge design pattern

B. Composite Design Pattern

Which design pattern you would you use to arrange object hierarchies such that the client code can access both the individual objects and compositions in a uniform manner ? A) Adapter design pattern B) Composite design pattern C) Composite adapter design pattern D) Composite factory design pattern

D. Decorator Design Pattern

Which design pattern you would you use to assign more functionality to an object without sub-classing it? A) Bridge design pattern B) Adapter design pattern C) Composite design pattern D) Decorator design pattern

D. Factory Method Design Pattern

Which design pattern you would you use to control the creation of an object based on a established interface, while allowing the concrete implementation to determine the subclass to construct A) Singleton design pattern B) Builder Factory design pattern C) Prototype factory design pattern D) Factory method design pattern

B. Bridge Design Pattern

Which design pattern you would you use to decouple an abstraction from its implementation so that the two can vary independently? A) Adapter design pattern B) bridge design pattern C) Facade design pattern D) Composite bridge design pattern

C. Builder Design Pattern

Which design pattern you would you use to decouple the creation procedure of a complex object from it's concrete instance to be able to apply that procedure on variety of implementations. A) Factory builder design pattern B) Method Builder design pattern C) Builder design pattern D) Factory method design pattern

D. Prototype Design Pattern

Which design pattern you would you use to have a prototypical instance determine the concrete class of object being created? A) Prototype factory design pattern B) Virtual prototype design pattern C) Abstract prototype design pattern D) Prototype design pattern

D. Singleton Design Pattern

Which design pattern you would you use to limit the class instantiation to one object? A) Factory Method Design Pattern B) Builder design pattern C) Prototype design pattern D) Singleton design pattern

B. Adapter Design Pattern

Which design pattern you would you use to translates an existing class interface into a compatible target interface? A) Proxy design pattern B) Adapter design pattern C) Facade design pattern D) Adapter factory design pattern

BE

Which is considered an example of Chain of Responsibility Pattern? A) java.awt.event.ComponentAdapter B) The Java Servlet filter framework C) javax.jms.QueueConnectionFactory D) java.awt.Toolkit E) Java exception handling

ABD

Which of the following are participants in the GOF Adapter design pattern? A) Adapter B) Adaptee C) Bridge D) Target interface

ACE

Which of the following are participants in the GOF Composite design pattern? A) Component B) Compound C) Leaf D) Connection E) Composite

CDE

Which of the following are participants in the GOF Decorator design pattern? A) Abstract Decorator B) Virtual Decorator C) Decorator D) Concrete Decorator E) Component

AD

Which of the following are participants in the GOF Prototype design pattern? A) Prototype B) Abstract Prototype C) Virtual Prototype D) Concrete Prototype

B. Singleton

Which of the following are participants in the GOF Singleton design pattern? A) Abstract Singleton B) Singleton C) Concrete Singleton D) Singleton factory

CDE

Which of the following are participants in the GOF abstract factory design pattern ? A) Factory methods B) Factory constructors C) Abstract factory D) Abstract product E) Concrete factory

ACE

Which of the following are participants in the GOF bridge design pattern ? A) Abstraction B) Bridge C) RefinedAbstraction D) Class Generalization E) Implementor

ACD

Which of the following are participants in the GOF builder design pattern? A) Builder interface B) Constructor Interface C) Director Interface D) Concrete Builder class E) Concrete constructor class

AB

Which of the following are participants in the GOF builder design pattern? A) Creator B) Product C) Refined Abstraction D) Abstract factory

C

Which of the following code snippet represents a Singleton design pattern implementation? A) public class PrintSpooler { public PrintSpooler INSTANCE = new PrintSpooler(); public PrintSpooler () {} public static PrintSpooler getInstance() { return INSTANCE; } } B) public class PrintSpooler { private PrintSpooler INSTANCE = new PrintSpooler(); private PrintSpooler () {} public static PrintSpooler getInstance() { return INSTANCE; } } C) public class PrintSpooler { private static final PrintSpooler INSTANCE = new PrintSpooler(); private PrintSpooler () {} public static PrintSpooler getInstance() { return INSTANCE; } } D) public class PrintSpooler { private final PrintSpooler INSTANCE = new PrintSpooler(); private PrintSpooler () {} public static PrintSpooler getInstance() { return INSTANCE; } }

AB

Which of the following is a GOF Structural Design Pattern? A)Composite B)Flyweight C)Singleton D)Method Factory

Queue

Which of these classes is not part of Java's collection framework? A. Maps B. Array C. Stack D. Queue

Collection

Which of these interface declares core method that all collections will have? A. set B. EventListner C. Comparator D. Collection

List

Which of these interface handle sequences? A. Set B. List C. Comparator D. Collection

SortedList

Which of these interface is not a part of Java's collection framework? A. List B. Set C. SortedMap D. SortedList

Set

Which of these interface must contain a unique element? A. Set B. List C. Array D. Collection

Collection

Which of these is Basic interface that all other interface inherits? A. Set B. Array C. List D. Collection

max(Comparator comp)

Which of these is an incorrect form of using method max() to obtain maximum element? A. max(Collection c) B. max(Collection c, Comparator comp) C. max(Comparator comp) D. max(List c)

All of the above

Which of these is static variable defined in Collections? A. EMPTY_SET B. EMPTY_LIST C. EMPTY_MAP D. All of the above

unmodifiableCollection() method is available only for List and Set

Which of these is true about unmodifiableCollection() method? A. unmodifiableCollection() returns a collection that cannot be modified. B. unmodifiableCollection() method is available only for List and Set. C. unmodifiableCollection() is defined in Collection class.

singletonList()

Which of these methods can convert an object into a List? A. SetList() B. ConvertList() C. singletonList() D. CopyList()

shuffle()

Which of these methods can randomize all elements in a list? A. rand() B. randomize() C. shuffle() D. ambigous()

clear()

Which of these methods deletes all the elements from invoking collection? A. clear() B. reset() C. delete() D. refresh()

fill()

Which of these methods sets every element of a List to a specified object? A. set() B. fill() C. Complete() D. add()

C. Factory Method

Which pattern is most appropriate when a decision must be made at the time a class is instantiated? A) Bridge B) Composite C) Factory Method D) Command

D. Flyweight

Which pattern is utilized in this example ? Every character object in a word document has data about the graphical representation and the position, but to avoid redundant graphical representation data for objects to the same character, it is advisable to extract out these representation data to one shared object between these objects, and store only the position of each character internally in each object. A) Abstract Factory B) Method Factory C) Builder D) Flyweight

A. Chain of Responsibility

Which pattern to use when more than one object can handle a request, and the handler is unknown? A) Chain of Responsibility B) Command C) Strategy D) Observer

The elements in the collection are ordered

Which statement is true for the class ArrayList? - The elements in the collection are ordered. - The collection is guaranteed to be immutable. - The elements in the collection are guaranteed to be unique. - The elements in the collection are accessed using a unique key.

B. Virtual Proxy

You are building an online makeup website, which provides beside text articles, makeup tutorials as videos files. Which pattern is recommended to use in such a website to deliver these media resources? A) value list handler B) virtual proxy C) intercepting filter D) composite view

B. Apply the Adapter Pattern

You are trying to add a class already written in another application to serve clients, beside other classes, in your system. All other classes have the same interface, the incoming class has a totally different interface than the clients expect, but contains all required functionalities. What kind of refactoring is needed to make this class fit in with minimum changes in your system? A) apply the Proxy Pattern B) apply the Adapter Pattern C) create a new class which implements the expected interface and copy and paste the code from the class in the other application to this new class

C. Bridge Design Pattern

You design an application for an advertis-ement company, which produces different sort of publications such as books, articles, leaflets, etc. The company publishes those products in many media formats such as printed material, CD, DVD, online websites, etc. How you would model the company products hierarchy (Publications, Media)? A) Use composite design pattern to enable the publication and media hierarchies to be treated in the same way as a single instance of an object. B) Use the adapter design pattern to translates publication interface into a compatible media interface. C) Use bridge design pattern to build separate hierarchies for the publications and the media, to decouple the abstraction from its implementation so that the two can vary independently

Map

You need to store elements in a collection that guarantees that no duplicates are stored and all elements can be accessed in natural order. Which interface provides that capability?

C. Apply the Singleton pattern to class A

You want all the clients using class A to use the same instance of class A, what should you do to achieve this goal. A) mark class A final B) mark class A abstract C) apply the Singleton pattern to class A D) apply the Memento pattern to class A

B. Abstract Family

You want to create families of related objects, to be used interchangeably to configure your app. A. Chain of Responsiblity B. Abstract Family C. Builder D. Observer

ACE

how to implement the Singleton design pattern? specify all the needed steps that apply. A) add final modifier to the Class declaration B) add final modifier to the constructor declaration C) add private or protected modifier to the constructor declaration D) introduce a final static constructor of the Singleton class E) introduce a static getter method for the Singleton instance F) The class name must be Singleton

A. Iterator

java.util.Enumeration is an example of which pattern? A) Iterator B) Command C) Observer D) Strategy


Ensembles d'études connexes

Chapter 29: Contraception and Unplanned Pregnancies

View Set

Macroeconomics (Review Intro Concepts)-Economics

View Set

How Artificial Intelligence Affects Jobs

View Set

Cellular Components of Blood: Red Blood Cells

View Set

Econ 14-1 Business cycles and fluctuations

View Set

Jill Seiver Psychology 100 - Chapter 14 Review

View Set