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...

A computational problem is

A) a problem that can be solved using an algorithm B) one that arises in the writing of computer programs C) one that arises when a program runs out of memory, or has some other kind of runtime error D) None of the above

Computer Science & Information Technology

____ tweens change one shape to another.

A. Formation B. Shape C. Motion D. Frame-by-frame

Computer Science & Information Technology

____ view shows what a page will look like when viewed in a browser.

A. Split B. Code C. Design D. Dual

Computer Science & Information Technology

When using indexed sequential record organization, each entry in the index file contains the ____ and the physical location of the data block where this record, and the records with smaller keys, are stored.

A. last record name B. highest record key C. lowest record key D. first record name

Computer Science & Information Technology