1.

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 thrownMy query is from Stack using Array topic in portion Abstract Data Types of Data Structures & Algorithms IThis question was addressed to me during an internship interview.

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.



Discussion

No Comment Found

Related InterviewSolutions