Java Quiz Day 72

Last Updated :
Discuss
Comments

Question 1

What is the primary intent of the Builder Design Pattern?

  • To create a single instance of a class.

  • To create complex objects step by step

  • To allow objects to communicate without being tightly coupled

  • To wrap an object and provide extra functionality

Question 2

Which creational pattern is Builder most closely related to?

  • Prototype

  • Singleton

  • Factory

  • Decorator

Question 3

In the Builder pattern, which component is responsible for assembling the parts of the final object?

  • Product

  • Builder

  • Builder

  • Director

Question 4

Which of the following best describes the “Product” in the Builder pattern?

  • The object being constructed

  • The algorithm that creates the object

  • The interface for building objects

  • The class that manages object lifecycle

Question 5

Why is the Builder pattern preferred when constructing immutable objects?

  • It makes them mutable temporarily

  • It avoids multiple constructors with many parameters

  • It forces lazy initialization

  • None of the above.

Question 6

Which of the following is a real-world analogy of the Builder pattern?

  • A Pizza order where you can add toppings step by step

  • A Printer that prints only one copy

  • A Switch that turns on or off

  • A Remote Control with fixed buttons

Question 7

In Java, which popular class commonly uses the Builder pattern?

  • StringBuilder

  • StringTokenizer

  • Scanner

  • Thread

Question 8

What is the main advantage of the Builder pattern over telescoping constructors?

  • Less code duplication

  • Improved readability and flexibility

  • It guarantees thread safety

  • It reduces object size

Question 9

In the Builder pattern, can the same Builder be reused to create multiple objects?

  • Yes, always

  • No, never

  • Yes, but only if it resets its state

  • Only if the Product is immutable

Question 10

Which of these best summarizes the structure of the Builder pattern?

  • Product, Client, Singleton

  • Builder, Product, Factory

  • Product, Builder, Director, Client

  • Singleton, Factory, Observer

There are 10 questions to complete.

Take a part in the ongoing discussion