Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Post-Test CoR AdvProg

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

Which of the following patterns allows an object to notify interested listeners of changes to its state?

a)

Chain of Responsibility

b)

Strategy

c)

Observer

d)

Command

e)

Template

2.

Which of the following patterns allows multiple objects an opportunity to process a request without guaranteeing that any of them must process it?

a)

Chain of Responsibility

b)

Strategy

c)

Observer

d)

Command

3.

Which of the following is an object pattern that encapsulates interchangeable algorithms in objects so the algorithm can vary independently of the classes that use it?

a)

Chain of Responsibility

b)

Strategy

c)

Observer

d)

Command

4.

What is the main purpose of the strategy pattern?

a)

To provide a way to change the behavior of a class at runtime

b)

To define a fixed set of steps that must be followed by subclasses

c)

To create reusable code by encapsulating algorithms

d)

To promote loose coupling between classes

5.

How does the strategy pattern make the code more flexible and adaptable to change?

a)

By encapsulating algorithms in reusable code

b)

By promoting loose coupling between classes

c)

By allowing for dynamic changes in the algorithm used at runtime

d)

By defining a fixed set of steps that must be followed by subclasses

6.

In the push model, the subject sends the observers updates without being prompted, while in the pull model, the observers request updates from the subject.

a)

True

b)

False

7.

Which of these is the purpose of the Chain of Responsibility pattern?

a)

To allow a request to be processed by a series of handlers

b)

To define a one-to-many relationship between objects

c)

To provide a way to change the behavior of a class at runtime

d)

To promote loose coupling between classes

8.

Chain of Responsibility pattern might be useful when you need to maintain a list of subscribers to an event and notify them of updates.

a)

True

b)

False

9.

How does the Chain of Responsibility pattern work?

a)

By passing a request through a chain of objects until one of them handles it

b)

By allowing objects to subscribe to receive events

c)

By providing a way for objects to be notified of changes in another object

d)

By encapsulating algorithms in reusable code

10.

Observer pattern promote loose coupling between objects by allowing objects to communicate without knowing the details of each other’s implementation.

a)

True

b)

False