LLD - Behavioral Design Patterns — Part 2Which scenario best demonstrates the use of the Null Object pattern?AThrowing an exception when a null value is encountered.BReturning a special object instead of null to avoid conditional checks.CLogging an error message when a null is found.DUsing a global variable to store null values.Check Answer
Step-by-Step SolutionSolution:Step 1: Identify what Null Object pattern doesIt returns a special object that behaves safely instead of returning null.Step 2: Compare optionsThrowing exceptions or logging errors are error handling, not Null Object usage. Using global variables for null is unrelated.Final Answer:Returning a special object instead of null to avoid conditional checks. -> Option BQuick Check:Null Object usage = Return special object [OK]Quick Trick: Null Object returns safe object, not null [OK]Common Mistakes:MISTAKESConfusing error handling with Null Object patternThinking Null Object throws exceptionsUsing global variables for null management
Master "Behavioral Design Patterns — Part 2" in LLD9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepArchTryChallengeDesignRecallScale
More LLD Quizzes Behavioral Design Patterns — Part 1 - Observer pattern - Quiz 12easy Behavioral Design Patterns — Part 1 - Strategy pattern - Quiz 7medium Behavioral Design Patterns — Part 1 - Template Method pattern - Quiz 2easy Design — Elevator System - Emergency handling - Quiz 12easy Design — Elevator System - Elevator, Floor, Request classes - Quiz 8hard Design — Elevator System - Scheduling algorithm (SCAN, LOOK) - Quiz 15hard Design — Library Management System - Search functionality design - Quiz 9hard Design — Parking Lot System - Concurrency considerations - Quiz 13medium Design — Parking Lot System - Class identification (ParkingLot, Floor, Spot, Vehicle) - Quiz 8hard Design — Tic-Tac-Toe Game - Board, Player, Game classes - Quiz 10hard