AMP

Chapter-3 Stack — Online MCQ Test

COMPUTER SCIENCE · CLASS 12 SECOND PUC · Karnataka State Board
Practice Chapter-3 Stack with a free chapter-wise online MCQ test. This chapter covers: stack - LIFO - Python lists - push - pop. AI-generated questions from basic to board-exam level, with instant results and explanations.

Start Exam on Full Site →

Chapter-3 Stack — Important Questions & Answers

What does LIFO stand for in the context of a stack?
  • A. Last In First Out
  • B. Linear In First Out
  • C. Last In For Output
  • D. Longest Input First Output
Answer: A. Last In First Out
LIFO is the fundamental principle of stack data structure where the last element inserted is the first one to be removed.
Which Python data structure is commonly used to implement a stack?
  • A. Dictionary
  • B. List
  • C. Tuple
  • D. Set
Answer: B. List
Python lists provide append() and pop() methods that make them ideal for implementing stacks.
What will be the output of the following code? stack = [1, 2, 3, 4] stack.pop() print(len(stack))
  • A. 3
  • B. 4
  • C. 2
  • D. 1
Answer: A. 3
After pop(), one element is removed from the stack, reducing its length from 4 to 3.
What is the maximum number of elements that can be stored in a stack implemented using a Python list of size 10?
  • A. 10
  • B. 9
  • C. 11
  • D. Unlimited
Answer: D. Unlimited
Python lists are dynamic and can grow beyond their initial size, so a stack can store unlimited elements.
What is the result of the following code sequence and why is it important? stack = [1, 2, 3] value = stack.pop() stack.append(value + 10) print(stack)
  • A. [1, 2, 3, 13] - demonstrates queue behavior
  • B. [1, 2, 13] - demonstrates modifying stack elements after popping
  • C. [1, 2, 3, 10] - demonstrates push operation
  • D. Error - cannot perform arithmetic on popped elements
Answer: B. [1, 2, 13] - demonstrates modifying stack elements after popping
This demonstrates that after popping the top element (3), we can modify it and push it back, showing flexibility in stack manipulation.