Bird
0
0

Given this LLD snippet: class User { id: int; name: string; getName(): string; } Which issue would a code review likely catch?

medium📝 Analysis Q4 of 15
LLD - Advanced LLD Concepts
Given this LLD snippet: class User { id: int; name: string; getName(): string; } Which issue would a code review likely catch?
AMethod getName() should return int
BIncorrect data types for id and name
CMissing constructor to initialize id and name
DClass name should be lowercase
Step-by-Step Solution
Solution:
  1. Step 1: Analyze class design completeness

    Class has fields and method but no constructor to initialize fields.
  2. Step 2: Identify common design issues

    Missing constructor can cause uninitialized fields; data types and method return type are correct.
  3. Final Answer:

    Missing constructor to initialize id and name -> Option C
  4. Quick Check:

    Constructor presence check = A [OK]
Quick Trick: Check for initialization methods in class design [OK]
Common Mistakes:
  • Assuming default initialization
  • Ignoring constructor importance
  • Confusing method return types

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes