Q. If a stack has a maximum size of 5, what will happen if we try to push a 6th element?
-
A.
The element will be added
-
B.
The stack will overflow
-
C.
The stack will shrink
-
D.
The operation will be ignored
Solution
If we try to push a 6th element onto a full stack, it will overflow.
Correct Answer:
B
— The stack will overflow
Learn More →
Q. In a stack, which operation is performed last?
-
A.
Push
-
B.
Pop
-
C.
Peek
-
D.
None of the above
Solution
In a stack, the last operation performed is Pop, which removes the most recently added element.
Correct Answer:
B
— Pop
Learn More →
Q. What is the main advantage of using a queue over a stack?
-
A.
Faster access
-
B.
FIFO order
-
C.
LIFO order
-
D.
Easier implementation
Solution
A queue operates in FIFO (First In, First Out) order, which is useful for scheduling tasks.
Correct Answer:
B
— FIFO order
Learn More →
Q. Which of the following is a valid use case for a stack?
-
A.
Undo functionality in applications
-
B.
Managing print jobs
-
C.
Handling requests in a web server
-
D.
All of the above
Solution
A stack is commonly used for undo functionality in applications.
Correct Answer:
A
— Undo functionality in applications
Learn More →
Q. Which of the following is true about a stack?
-
A.
Elements can be accessed in any order
-
B.
Elements are removed in FIFO order
-
C.
Elements are removed in LIFO order
-
D.
None of the above
Solution
In a stack, elements are removed in LIFO (Last In, First Out) order.
Correct Answer:
C
— Elements are removed in LIFO order
Learn More →
Q. Which operation is not typically associated with a stack?
-
A.
Push
-
B.
Pop
-
C.
Enqueue
-
D.
Peek
Solution
Enqueue is an operation associated with queues, not stacks.
Correct Answer:
C
— Enqueue
Learn More →
Showing 1 to 6 of 6 (1 Pages)