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 top-of-stack
Stack(int arr[]){
stck=arr;
tos =-1
}
// Push an item onto the stack
void push(int item){
if (tos==9)
System.out.println("Stack is ful1.");
else
stck [++tos]= item;
}
// Pop an item from the stack
int pop(){
if (tos 0){
System.out.println("Stack underflow.");
return 0 ;
e1se
}
return stck[tos--];
}
}
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 3 items of each category
in the stacks.
 Consider the following coding that is developed to implement the Stack

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!