Deck 3: Testing and Debugging
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/25
Play
Full screen (f)
Deck 3: Testing and Debugging
1
In the Java API, class java.util.Stack<E> implements a stack; there is no stack interface.
True
2
The array data field can be used for storage of a stack instead of using Java's ArrayList class.
True
3
The statement Stack myStack = new Stack(); defines a stack that holds String objects.
True
4
The implementation of the Stack ADT as an extension of Vector is a good choice because all the Vector methods are accessible.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
5
There is only one stack interface in Java.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
6
A(n) ____________________ is a data structure in which objects are inserted into and removed from the same end.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
7
A(n) ____________________ is a string that reads the same in either dierection: left to right or right to left.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
8
If you attempt to pop an empty stack, your program will throw a(n) ____________________.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
9
The ____________________ class implements a growable array of objects. Like an ArrayList, it contains components that can be accessed using an integer index.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
10
The ListStack class is said to be a(n) ____________________ class because it adapts the methods available in another class (List) to the interface its clients expect by giving different names to essentially the same operations.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
11
In terms of efficiency, all stack operations using an array structure are ____________________.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
12
The value of the following postfix expression is ___________________.
1 2 + 4 * 3 +
1 2 + 4 * 3 +
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
13
Rewrite the following as an infix expression: 5 6 * 10 -
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
14
A(n) ____________________ is a data structure with the property that only the top element is accessible.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
15
In a(n) ____________________, the top element is the data value that was most recently stored.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
16
The methods that make up the StackInt interface are ____.
A) push(), pop(), empty()
B) push(), pop(), peek(), empty()
C) peek(), remove(), insert()
D) peek(), insert(), isEmpty()
A) push(), pop(), empty()
B) push(), pop(), peek(), empty()
C) peek(), remove(), insert()
D) peek(), insert(), isEmpty()
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
17
The Java API includes a Stack class as part of the package java.util. This class is declared as follows:
A) public class Stack<E> implements Vector<E>
B) public class Stack<E> extends List<E>
C) public class Stack<E> extends Vector<E>
D) public class Stack<E>
A) public class Stack<E> implements Vector<E>
B) public class Stack<E> extends List<E>
C) public class Stack<E> extends Vector<E>
D) public class Stack<E>
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
18
What is value of the following postfix expression?
5 6 1 + *
A) 14
B) 20
C) 30
D) 35
5 6 1 + *
A) 14
B) 20
C) 30
D) 35
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
19
Which of the following is a balanced expression?
A) (a + b * {c [d - e]}) + (d / e )
B) (a + b * {c [d - e])) + (d / e )
C) (a + b * {c [d - e])) + (d / e ]
D) (a + b * {c [d - e])}+ (d / e )
A) (a + b * {c [d - e]}) + (d / e )
B) (a + b * {c [d - e])) + (d / e )
C) (a + b * {c [d - e])) + (d / e ]
D) (a + b * {c [d - e])}+ (d / e )
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
20
An alternative to implementing a stack as an extension of Vector is to write a class that has a(n) ____ component.
A) array
B) List
C) Queue
D) tree
A) array
B) List
C) Queue
D) tree
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
21
The easiest approach to implementing a stack in Java would be to give it a(n) ____ component for storing the data.
A) LinkedStack
B) ListStack
C) SyntaxErrorException
D) List
A) LinkedStack
B) ListStack
C) SyntaxErrorException
D) List
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
22
Rewrite the following in infix form: x1 2.5 count * 3 / +
A) x1 * 2.5 / count + 3
B) x1 + 2.5 * count / 3
C) x1 + 2.5 / count * 3
D) x1 * 2.5 + count / 3
A) x1 * 2.5 / count + 3
B) x1 + 2.5 * count / 3
C) x1 + 2.5 / count * 3
D) x1 * 2.5 + count / 3
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
23
The method ____ returns the position of the character argument in the string.
A) String.indexOf
B) String.index
C) String.charOf
D) String.char
A) String.indexOf
B) String.index
C) String.charOf
D) String.char
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
24
The storage policy used by a stack is ____.
A) FIFO
B) LIFO
C) LIFFO
D) FIFFO
A) FIFO
B) LIFO
C) LIFFO
D) FIFFO
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
25
The value of the following expression is ____.
5 7 * 3 10 + + 4 /
A) 8
B) 12
C) 20
D) 36
5 7 * 3 10 + + 4 /
A) 8
B) 12
C) 20
D) 36
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck