+1 vote
in Data Structures & Algorithms I by (110k points)
What happens when you pop from an empty stack while implementing using the Stack ADT in Java?

(a) Undefined error

(b) Compiler displays a warning

(c) EmptyStackException is thrown

(d) NoStackException is thrown

My query is from Stack using Array topic in portion Abstract Data Types of Data Structures & Algorithms I

This question was addressed to me during an internship interview.

1 Answer

+1 vote
by (412k points)
selected by
Best answer
Right choice is (c) EmptyStackException is thrown

For explanation: The Stack ADT throws an EmptyStackException if the stack is empty and a pop() operation is tried on it.

Related questions

Welcome to TalkJarvis QnA, a question-answer community website for the people by the people. On TalkJarvis QnA you can ask your doubts, curiosity, questions and whatever going in your mind either related to studies or others. Experts and people from different fields will answer.