Creational Design Pattern

Creational Design Pattern

University

22 Qs

quiz-placeholder

Similar activities

Usability Quiz

Usability Quiz

University

20 Qs

SE2 (LAB) Week 3 – 4 Strategy Pattern

SE2 (LAB) Week 3 – 4 Strategy Pattern

University

23 Qs

Threads and Process

Threads and Process

University

20 Qs

Laboratory - Week 10 – 11 Facade Pattern

Laboratory - Week 10 – 11 Facade Pattern

University

20 Qs

Programação Orientada a Objetos - Quiz 2

Programação Orientada a Objetos - Quiz 2

University

26 Qs

Multimedia Development Stage

Multimedia Development Stage

University

21 Qs

Design Pattern 2

Design Pattern 2

University

17 Qs

Patrones de diseño U1

Patrones de diseño U1

University

25 Qs

Creational Design Pattern

Creational Design Pattern

Assessment

Quiz

Computers

University

Hard

Created by

Kasmir Syariati

Used 5+ times

FREE Resource

22 questions

Show all answers

1.

MULTIPLE SELECT QUESTION

30 sec • 2 pts

Which of the following creational design patterns shares the goal of hiding the object creation logic from the client code?

Factory

Builder

Prototype

Abstract Factory

Singleton

Answer explanation

Both Factory Method and Abstract Factory hide the object creation logic and provide an interface for clients to interact with the created objects.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

When might you choose the Prototype pattern over the Factory Method pattern?

When you need to create complex objects with many configurable parts.

When you need to ensure only one instance of an object exists.

When you want to defer the decision of which object to create until runtime.

When you need a central registry to manage all created objects.

Answer explanation

Prototype excels at creating complex objects by cloning existing ones, while Factory Method focuses on creating new objects based on a type.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

The Factory Method pattern often relies on inheritance to differentiate between object types. Can the Builder pattern also leverage inheritance for similar purposes?

No, Builder uses composition to define object structures.

Yes, Builder subclasses can define specific construction steps for different object types.

Builder relies solely on interfaces to define object creation logic.

Both inheritance and composition are commonly used in Builder.

Answer explanation

Builder uses composition with different builder methods to define object structures, not inheritance.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Imagine a system where you need to create different shapes (Square, Circle) based on user input. Which creational pattern would be most suitable, considering the Factory Method?

Singleton

Abstract Factory

Prototype

Builder

Answer explanation

Abstract Factory allows creating families of related objects (like shapes) based on a user choice.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

The Factory Method class typically defines a method to create objects. Can the Singleton pattern also define a similar method for controlled access to its single instance?

No, Singleton relies on a static field for access, not a method.

Yes, the Singleton class can have a getInstance() method for controlled access.

Singleton uses a factory class to delegate object creation.

Both Factory Method and Singleton hide the object creation logic completely.

Answer explanation

Singleton often defines a getInstance() method to provide controlled access to its single instance.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

When using the Factory Method pattern, the client code interacts with the created objects through an interface. Does the Builder pattern also enforce this concept?

No, Builder clients directly interact with concrete builder classes.

Yes, Builder provides an interface to define the object structure, which clients use.

Factory Method allows concrete classes to be returned, while Builder always returns interfaces.

Both patterns hide the implementation details of the created objects.

Answer explanation

Builder defines an interface for object construction, similar to Factory Method using interfaces for created objects.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Compared to the Factory Method, the Abstract Factory pattern introduces an additional layer of abstraction. What benefit does this extra layer provide?

It simplifies the creation of complex objects with many parts.

It allows creating families of related objects based on a type.

It reduces the number of concrete factory classes required.

It enforces code reusability for object creation logic.

Answer explanation

Abstract Factory provides a central location to define families of related objects, promoting code reuse and flexibility.

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?