Bird
0
0

Why does a Stack in C# use the LIFO principle instead of FIFO?

hard🧠 Conceptual Q10 of 15
C Sharp (C#) - Collections
Why does a Stack in C# use the LIFO principle instead of FIFO?
ABecause it models real-world scenarios like undo operations where the last action is reversed first
BBecause it is easier to implement than FIFO
CBecause FIFO is only used in databases
DBecause Stack stores items in sorted order
Step-by-Step Solution
Solution:
  1. Step 1: Understand Stack use cases

    Stacks are used in scenarios like undo features where the last action must be undone first.
  2. Step 2: Connect behavior to real-world analogy

    This matches the Last In, First Out (LIFO) principle, reflecting how recent actions are reversed first.
  3. Final Answer:

    Because it models real-world scenarios like undo operations where the last action is reversed first -> Option A
  4. Quick Check:

    Stack LIFO matches undo operation logic [OK]
Quick Trick: Stack LIFO fits undo/redo real-world tasks [OK]
Common Mistakes:
MISTAKES
  • Thinking Stack stores sorted items
  • Confusing FIFO with LIFO reasons

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Sharp (C#) Quizzes