Multiple Choice
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];
Correct Answer:

Verified
Correct Answer:
Verified
Q3: In a list implementation of a queue,the
Q4: The stack pull operation<br>A) increases the capacity
Q5: The stack peek operation<br>A) checks a stack
Q6: Consider a class that uses the following
Q7: A queue is a container that allows
Q9: Consider a class that uses the following
Q10: In an implementation of a stack based
Q11: A queue based on a linked list
Q12: In a list implementation of a stack,the
Q13: Compilers of modern programming languages support method