Question: Consider the following coding that is developed to implement the Stack class of integers. class stack { int stck [ ] ; int tos; /
Consider the following coding that is developed to implement the Stack class of integers.
class stack
int stck ;
int tos;
Initialize topofstack
Stackint arr
stckarr;
tos
Push an item onto the stack
void pushint item
if tos
System.out.printlnStack is ful;
else
stck tos item;
Pop an item from the stack
int pop
if tos
System.out.printlnStack underflow.";
return ;
ese
return stcktos;
We are now interested to make an interface StackInterface that has functionally to push and
pop with a generic datatype T Modify the class Stack that will implement StackInterface.
Also, in the driver class make stacks of integer, double and push and pop items of each category
in the stacks.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
