Question: Consider the following Java statements, assuming that MyStack is a class that implements the interface StackInterface: int n = 4; StackInterface stack = new MyStack
Consider the following Java statements, assuming that MyStack is a class that implements the interface StackInterface:
int n = 4; StackInterfacestack = new MyStack<>(); while (n > 0) { stack.push(n); n--; } // end while int result = 1; while (!stack.isEmpty()) { int integer = stack.pop(); result = result * integer; } // end while System.out.println("result = " + result);
a. What value is displayed when this code executes?
b. What mathematical function does the code evaluate?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
