In case of the following stack exceptions will be thrown:
If the stack is full when push() is called a StackException is
thrown, as push() cannot input data if the stack is full, i.e.
there is no space to store data in the stack.
If the stack is empty when pop() is called, a StackException is
thrown as there are no elements in the stack to delete. It is
called EmptyStackException.
When using top() i.e. displaying the top of the stack, if the
stack is empty i.e. the index to top element, top= -1, in that case
a EmptyStackException is thrown.