Given the resulting stack X below, what would be the result of each of the following?

```
X.push(new Integer(4));
X.push(new Integer(3));
Integer Y = X.pop();
X.push(new Integer(7));
X.push(new Integer(2));
X.push(new Integer(5));
X.push(new Integer(9));
Integer Y = X.pop();
X.push(new Integer(3));
X.push(new Integer(9));

a) Y = X.peek();

b) Y = X.pop();
Z = X.peek();

```

a) The value of Y would be 9 and the stack would remain unchanged.

b) The value of Y would be 9, the value of Z would be 3, and the stack would contain:
3 5 2 7 4

Computer Science & Information Technology

You might also like to view...

All applications should be ________ before they are given to the final user

Fill in the blank(s) with correct word

Computer Science & Information Technology

In what frequency band does Bluetooth operate?

What will be an ideal response?

Computer Science & Information Technology