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
Q2: In a list implementation of a queue,the
Q3: The stack pull operation
A) increases the capacity
Q4: The stack class provided by the Java
Q5: In a list implementation of a stack,the
Q6: Compilers of modern programming languages support method
Q7: Consider a class that uses the following
Q8: A queue is a container that allows
Q9: The stack empty operation
A) removes all elements
Q10: The JCF Stack class is used to
Q11: The stack push operation
A) is normally implemented
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents