Search Header Logo

SDA Lab Quiz 3 A & B

Authored by Muhammad Abdullah Nasim

Computers

University

Used 2+ times

SDA Lab Quiz 3 A & B
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the primary purpose of the Singleton pattern?

To ensure a class has only one instance and provide a global point of access to it

To inherit behavior from multiple classes

To instantiate multiple objects of the same type

To allow runtime object creation with different types

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

Singleton s1 = Singleton.getInstance();

Singleton s2 = Singleton.getInstance();

System.out.println(s1 == s2);

true

false

Runtime Error

Compilation Error

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the Factory Method pattern mainly used for?

To enforce inheritance

To allow the creation of objects without specifying their concrete classes

To create a single global object

To serialize objects

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following best explains the advantage of Factory Method over direct object instantiation?

Reduces memory consumption

Increases tight coupling

Avoids constructors

Provides flexibility in object creation

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

What will be the output of the following code?

(Factory Method)

Woof

Meow

Runtime Error

None of these

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the main goal of the Composite design pattern?

To simplify condition checking

To treat individual and composite objects uniformly

To avoid using inheritance

To optimize recursion

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Folder
└── File

Which pattern does this represent?

Singleton

Builder

Composite

Factory Method

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?