java program : Assume the following method is added to the ArrayStack class. What does this method do? public ArrayStack Undefined() { int j = topOfStack; ArrayStack st1= new ArrayStack(topOfStack + 1); for(int i = 0; i < topOfStack + 1; i++) { st1.theData[j] = theData[i]; j-- ; } return st1; } The method will return a stack containing all the elements of “this” stack in the reverse order. The method will return a stack containing the alternative elements of “this” stack in the original order. The method will return a stack containing all the elements of “this” stack in the original order. The method will return a stack containing the alternative elements of “this” stack in the reverse order.
java
Assume the following method is added to the ArrayStack class. What does this method do?
public ArrayStack<E> Undefined()
{
int j = topOfStack;
ArrayStack<E> st1= new ArrayStack<E>(topOfStack + 1);
for(int i = 0; i < topOfStack + 1; i++)
{
st1.theData[j] = theData[i];
j-- ;
}
return st1;
}
-
The method will return a stack containing all the elements of “this” stack in the reverse order.
-
The method will return a stack containing the alternative elements of “this” stack in the original order.
-
The method will return a stack containing all the elements of “this” stack in the original order.
-
The method will return a stack containing the alternative elements of “this” stack in the reverse order.
Step by step
Solved in 2 steps