Bird
0
0

Which of the following is the correct way to add a new item to the Menu class in a typical object-oriented design?

easy📝 Conceptual Q12 of 15
LLD - Design — Food Delivery System
Which of the following is the correct way to add a new item to the Menu class in a typical object-oriented design?
Amenu.addItem('Pizza', 12.99)
BMenu.add('Pizza', 12.99)
Cmenu.insertItem('Pizza', 12.99)
DaddItem(menu, 'Pizza', 12.99)
Step-by-Step Solution
Solution:
  1. Step 1: Identify instance method usage

    Adding an item to a Menu instance uses the instance method, so calling menu.addItem(...) is correct.
  2. Step 2: Eliminate incorrect syntax

    Menu.add(...) suggests a static method which is unlikely; insertItem is not standard; addItem(menu, ...) is procedural, not OOP style.
  3. Final Answer:

    menu.addItem('Pizza', 12.99) -> Option A
  4. Quick Check:

    Instance method call = menu.addItem(...) [OK]
Quick Trick: Use instance.method() to add items, not static or procedural calls [OK]
Common Mistakes:
  • Using static method call instead of instance method
  • Confusing method names
  • Calling functions outside class context

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes