Design Pattern Flashcards

1
Q

What is concrete Instanciation

A

It is creation of object using new operator

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is difference between Factory Method & Factory Object

A

Factory object is instance of class which creates the Concrete Object
Factory method is where the actual instance of class is created

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is recursive composition?

A

Recursive composition is where composite class is aware of other classes in heirarchy (and may be used to create the certain type of class)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are principles that are realised using composite pattern?

A
  1. Decomposition
  2. Generalisation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is aggregation stack?

A

It is stack of object where the current object knows about the object above it and augment the one below it

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is difference between aggregation and inheritance?

A

In aggregation, we access behaviour of class using it’s object. Inheritance we inherit behaviour

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a Structural Design Pattern?

A

A design pattern that deals with object composition to form larger structures.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

True or False: Structural Design Patterns focus on how classes and objects are composed to form larger structures.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Name a common Structural Design Pattern.

A

Adapter Pattern

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the purpose of the Adapter Pattern?

A

To allow incompatible interfaces to work together.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Fill in the blank: The ______ Pattern allows an object to alter its behavior when its internal state changes.

A

State

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Which Structural Design Pattern provides a way to compose objects into tree structures to represent part-whole hierarchies?

A

Composite Pattern

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

True or False: The Bridge Pattern separates an abstraction from its implementation.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the main goal of the Decorator Pattern?

A

To add new functionality to an object dynamically.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Multiple Choice: Which of the following is NOT a Structural Design Pattern? A) Composite B) Observer C) Facade D) Proxy

A

B) Observer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does the Facade Pattern provide?

A

A simplified interface to a complex subsystem.

17
Q

Fill in the blank: The ______ Pattern allows for lazy initialization of an object.

18
Q

What is the main advantage of using the Flyweight Pattern?

A

To minimize memory usage by sharing common parts of state among multiple objects.

19
Q

True or False: The Composite Pattern cannot be used to treat individual objects and compositions uniformly.

20
Q

Which Structural Design Pattern is useful for decoupling an interface from its implementation?

A

Bridge Pattern

21
Q

What is the role of a ‘Component’ in the Composite Pattern?

A

It defines the interface for objects in the composition.

22
Q

Multiple Choice: In which scenario would you use the Decorator Pattern? A) To create a new class hierarchy B) To add responsibilities to objects dynamically C) To simplify complex systems D) To provide an interface

A

B) To add responsibilities to objects dynamically

23
Q

What does the Proxy Pattern allow in terms of access control?

A

It allows for controlling access to an object by acting as a surrogate.

24
Q

True or False: The Flyweight Pattern is primarily concerned with reducing the number of objects instantiated.

25
What is a key characteristic of the Adapter Pattern?
It provides interface for incompatible classes to communicate
26
Fill in the blank: The ______ Pattern is useful when you want to provide a unified interface to a set of interfaces in a subsystem.
Facade
27
Which Structural Design Pattern helps to manage a large number of objects efficiently?
Flyweight Pattern
28
What is the primary function of the Decorator Pattern?
To extend the behavior of objects at runtime.
29
True or False: The Bridge Pattern can be used to avoid a permanent binding between an abstraction and its implementation.
True
30
What is the primary benefit of using the Composite Pattern?
It allows clients to treat individual objects and compositions uniformly.
31
Multiple Choice: Which pattern would you use to provide a simple interface to a complex subsystem? A) Adapter B) Facade C) Composite D) Proxy
B) Facade
32
What is the purpose of the State Pattern?
To allow an object to change its behavior when its state changes.