Consider a class that uses the following variables to implement an array-based stack:
```
String[] s = new String[100];
int top = -1; // Note top == -1 indicates stack is empty
```
return temp;
B)
if (top == -1)
throw new RuntimeException("Empty Stack");
s[top] = null;
top--;
return s[top];
C)
if (top == -1)
throw new RuntimeException("Empty Stack");
String temp = s[top];
s[top] = null;
top--;
return temp;
D) None of the above
C)
if (top == -1)
throw new RuntimeException("Empty Stack");
String temp = s[top];
s[top] = null;
top--;
return temp;
You might also like to view...
Grouping data is useful in a database with a single-field primary key
Indicate whether the statement is true or false
A new thread begins its life cycle by transitioning to the __________ state.
a. runnable. b. waiting. c. terminated. d. new.