Consider a class that uses the following variables to implement an array-based stack:

```
String [] s = new String[100];
int top = 0;

```

a method that implements the String peek() operation can be written as
A) return s[top];
B)
if (top == 0)
throw new RuntimeException("Underflow");
else
return s[top];
C)
if (top == 0)
throw new RuntimeException("Underflow");
else
return s[top-1];
D) return s[top-1];

C)
if (top == 0)
throw new RuntimeException("Underflow");
else
return s[top-1];

Computer Science & Information Technology

You might also like to view...

If you click the Select button in the accompanying figure, which of the following happens?

A. Dreamweaver connects to the remote server. B. The names of all the databases on the remote server to which you have access appear in the Select Database list. C. The Select Database dialog box opens. D. All of the above

Computer Science & Information Technology

The ____________________ contains buttons used to accomplish tasks in the Finder window.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology