Bird
0
0

Which of the following code snippets correctly creates an immutable data structure in a low-level design context?

easy📝 Conceptual Q12 of 15
LLD - Advanced LLD Concepts
Which of the following code snippets correctly creates an immutable data structure in a low-level design context?
AUsing a constant object or final class with no setters.
BUsing a regular class with public fields that can be changed.
CUsing a mutable list that allows adding or removing items.
DUsing a global variable that can be updated anytime.
Step-by-Step Solution
Solution:
  1. Step 1: Identify immutable structure traits

    Immutable means no changes allowed after creation, so no setters or public mutable fields.
  2. Step 2: Match code snippet to traits

    Constant object or final class with no setters fits immutability.
  3. Final Answer:

    Using a constant object or final class with no setters. -> Option A
  4. Quick Check:

    Immutable = constant, no setters [OK]
Quick Trick: Immutable means no setters or public mutable fields [OK]
Common Mistakes:
  • Choosing mutable lists or global variables
  • Confusing final keyword with mutable fields
  • Ignoring setters in class design

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes