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.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter8: Arrays
Section: Chapter Questions
Problem 20RQ
icon
Related questions
Question

java program :

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;    

}

 

 
  1. The method will return a stack containing all the elements of “this” stack in the reverse order.

     
  2. The method will return a stack containing the alternative elements of “this” stack in the original order.

     
  3. The method will return a stack containing all the elements of “this” stack in the original order.

     
  4. The method will return a stack containing the alternative elements of “this” stack in the reverse order.

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT