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 pop() operation can be written as
A) if (top == 0)
Throw new RuntimeException("Underflow") ;
Top--;
String temp = s[top];
S[top] = null;
Return temp;
B) if (top == 0.
Throw new RuntimeException("Underflow".;
String temp = s[top];
Top--;
S[top] = null;
Return temp;
C) if (top == 0.
Throw new RuntimeException("Underflow".;
Return s[top-1];
Top --;
S[top] = null;
D) top--;
Return s[top];
Correct Answer:
Verified
Q10: The JCF Stack class is used to
Q11: The stack push operation
A) is normally implemented
Q12: A stack is a container that allows
Q13: In a list implementation of a queue,the
Q14: A stream of cars going through a
Q16: Consider a class that uses the following
Q17: Consider a class that uses the following
Q18: The stack pop operation
A) removes all items
Q19: In an array-based implementation of a stack,an
Q20: The stack peek operation
A) checks a stack
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