Try to practice these array questions regularly in order to get used to it. Doing so, the concept of Array operation will become second nature to you and you will excel in multiple competitive exams like BCA, MCA, GATE, GRE, IES, PSC, UGC NET, DOEACC Exams etc. You should try to solve these questions yourself before moving through the answers.
Stack using Array Questions and Answers
1. Which of the following real world scenarios would you associate with a stack data structure?
a) piling up of chairs one above the other
b) people standing in a line to be serviced at a counter
c) offer services based on the priority of the customer
d) tatkal Ticket Booking in IRCTC
Answer: piling up of chairs one above the other
2. What does ‘stack underflow’ refer to?
a) accessing item from an undefined stack
b) adding items to a full stack
c) removing items from an empty stack
d) index out of bounds exception
Answer: removing items from an empty stack
3. What is the time complexity of pop() operation when the stack is implemented using an array?
4. Which of the following array position will be occupied by a new element being pushed for a stack of size N elements (capacity of stack > N)?
5. 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
Answer: EmptyStackException is thrown
6. Array implementation of Stack is not dynamic, which of the following statements supports this argument?
a) space allocation for array is fixed and cannot be changed during run-time
b) user unable to give the input for stack operations
c) a runtime exception halts execution
d) improper program compilation
Answer: space allocation for array is fixed and cannot be changed during run-time
7. Which of the following array element will return the top-of-the-stack-element for a stack of size N elements (capacity of stack > N)?