it had been implemented using linked listfor examplethe size specification would be unnecessary the push(method increments top so it points to the space just above the previous topand stores data item there notice that top is incremented before the item is inserted the pop(method returns the value at top and then decrements top this effectively removes the item from the stackit' inaccessiblealthough the value remains in the array (until another item is pushed into the cellthe peek(method simply returns the value at topwithout changing the stack the isempty(and isfull(methods return true if the stack is empty or fullrespectively the top variable is at - if the stack is empty and maxsize- if the stack is full figure shows how the stack class methods work figure operation of the stackx class methods error handling there are different philosophies about how to handle stack errors what happens if you try to push an item onto stack that' already fullor pop an item from stack that' emptywe've left the responsibility for handling such errors up to the class user the user should always check to be sure the stack is not full before inserting an itemif!thestack isfull(insert(item)else system out print("can' insertstack is full")in the interest of simplicitywe've left this code out of the main(routine (and anywayin this simple programwe know the stack isn' full because it has just been initializedwe do include the check for an empty stack when main(calls pop(