CH 10 Queue, Ch 11 Queue Implementation, CH 6 - Stack Implementation, CH 5 Stacks, CH 3 - Bag implementation that links data, CH 2 Bag implementations that use Arrays, CH 1 - Bags,

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

A collection is not necessarily an abstract data type.

False

In an array-based chain implementation of a Stack ADT, what is the performance of the ensureCapacitymethod when the array is not full? a.O(1) b.O(n) c.O(n log n) d.O(n2)

O(1)

The Java Class Library interface Queue method that retrieves the entry at the front of a queue but throws a NoSuchElementException if the queue was empty is

element

The method for adding a new item to the back of a queue is called

enqueue

You should never suppress compiler warnings.

false

infix expressions are easier to evaluate than postfix expressions.

false

you can push, pop and get items at either end of the ADT deque.

false

You need two external references for a circular doubly linked chain, one for the firstNode and one forthe lastNode.

true

Code written with respect to an interface makes it difficult to replace one implementation of a bag with another.

False

Entries of a bag may belong to different classes because items are unordered.

False

You cannot determine the exact number of times a particular item appears in a bag because it is unordered.

False

In a circular array-based implementation of a queue, what is the performance when the enqueueoperation does not resize the array?

O(1)

In a doubly linked chain implementation of a queue, what is the performance when the dequeue operation ?

O(1)

In a linked chain implementation of a queue, the performance of the enqueue operation is

O(1)

In a linked chain implementation of a queue, the performance of the getFront operation is

O(1)

In a linked-chain implementationof a Stack ADT, the performance of pushing an entry onto the stack is a.O(1) b.O(2) c.O(n) d.O(n2)

O(1)

In a two-part circular linked chain implementation of a queue, what is the performance when the dequeue operation ?

O(1)

In a circular array-based implementation of a queue, what is the performance when the enqueueoperation if you amortize the cost of resizing the array over all additions to the queue?

O(log n)

.In an array-based chain implementation of a Stack ADT, what is the performance of the ensureCapacitymethod when the array is full? a.O(n) b.O(1) c.O(n log n) d.O(n2)

O(n)

In a circular array-based implementation of a queue, what is the performance when the enqueueoperation must resize the array?

O(n)

A method can change the state of an object passed to it as an argument.

True

A set is a special kind of bag.

True

All entries of a bag must have the same data type or a subtype of that data type.

True

An abstract data type is not necessarily a collection.

True

By declaring a data type to be a BagInterface, we can replace the bag class with another class that implements the BagInterface.

True

Entries of a bag can belong to classes related by inheritance.

True

The _____ shows a method's state during execution. a.activation record b.stack c.program counter d.program stack

activation record

The Java Class Library interface Queue method to put an entry on the back of a queue that throws an exception of the method fails is

add

Which bag behaviors would need modified when implementing a set? a.add() b.clear() c.contains() d.toArray()

add()

Which behavior(s) change the contents of a bag?a.add() b.getFrequencyOf() c.contains() d.toArray()

add()

Which of the following methods is a good candidate for a core method: a.add( )b.clear() c.contains() d.remove(

add()

Which of the following is an advantage of using an array to implement the ADT bag? a.adding an entry to a bag is fast b.removing a particular entry requires time to locate the entry c.increasing the size of the array requires time to copy its entries d.the client has control over the size of the bag

adding an entry to a bag is fast

When adding a node to a two-part circular linked chain implementation of a queue we insert the new node into the chain

after the node that freeNode reference

_____ is an alias for the name of the pop method. a.pull b.remove c.delete d.all of the above

all of the above

When a linked chain contain nodes that reference both the next node and the previous node, it is called a(n)

doubly linked list

Which of the followingare properties of a set?a.duplicates are permitted b.elements are stored in order c.elements may not be removed d.none of the above

duplicates are permitted

A chain requires less memory than an array of the same length.

false

A nested class is defined partially within another class definition.

false

A priority queue cannot have null entries

false

In a circular array-based implementation of a queue, frontIndexis equal to one less than backIndexwhen the queue is full.

false

In a circular array-based implementation of a queue, frontIndexis equal to one more than backIndexwhen the queue is empty.

false

In a linked chain implementation of a queue, the enqueue operation could potentially be dependent on the other entries and will require a search.

false

In a linked chain implementation of a queue, the enqueue operation requires a traversal to the end of the chain to insert a new entry onto the queue.

false

In an array-based implementation of a queue, inserting and deleting entries is accomplished using modulo arithmetic.

false

In an array-based implementation of a queue, keeping the front entry of the queue at queue[0] is inefficient.

false

Security checks are essential to maintain the integrity of the LinkedBag objects.

false

The Queue interface extends the Deque interface.

false

The bottom item in a stack was the last item added.

false

The first item added to a stack is the first one removed.

false

The outer LinkedBagclass can access the data fields of the inner Node class directly without using set and get methods

false

Unlike a stack, a queue does not restrict access to its entries.

false

When a circular linked chain is used to represent a queue, it is not necessary to maintain a firstNodedata field.

false

When defining the bag class write methods that have simple implementation first to get them out of the way.

false

When defining the bag class, you should implement the isArrayFulland removeoperations first.

false

When testing a method, you only need to check for arguments that lie within the legal range of their corresponding parameter.

false

When using a linked implementation, a bag can never become full.

false

You can only pop from the top of the stack but you can peek at any entry on the stack.

false

You should implement all methods of an ADT implementation before testing to make testing easier.

false

What type of behavior defines a queue?

first in first out

Stacks exhibit which type of behavior? a.first-in, first out b.first-in, last out c.last-in, first out d.last-in, last out

last-in, first out

A linked chain whose last node is null is sometimes called a(n)

linear linked chain

The nextfield in a node is also referred to as the a.link portion b.node c.initial address d.data portion

link portion

In a linked chain implementation of a queue, an external reference to the last node in the chain is called a(n)

tail reference

To efficiently remove a node at the end of a linked chain implementation of a queue requires as

tail reference

In the program stack, the record at the top of the stack belongs to the method a.that is currently executing b.that is scheduled to execute next c.that called the method that is currently executing d.none of the above

that is currently executing

What happens if an OutOfMemoryError occurs while adding a new node to the chain? a.the chain will remain intact b.the chain will lose its integrity c.a faulty node will be added to the beginning of the chain d.access to the chain will be lost

the chain will remain intact

The removemethod replaces the removed entry with null because a.the entry could potentially be scheduled for garbage collection b.the client expects a null return value c.it is a fail-safe programming practice d.otherwise it could be considered a duplicate value

the entry could potentially be scheduled for garbage collection

A return value of -1 from the getIndexmethod indicates a.the entry was not present in the bag b.the entry was found at the end of the array c.the bag was empty d.the bag was full

the entry was not present in the bag

What happens when you remove a node from a chain with only one node? a.the firstNodereference will become null b.the firstNodereference will become invalid c.an IllegalOperationException is thrown d.none of the above

the firstNode reference will become null

When removing a node from a chain, what case should we consider? a.the node is at the beginning of the chain b.the node is at the end of the chain c.both a and b d.none of the above

the node is at the beginning of the chain

In the linked chain implementation of a queue, the chain's tail last node contains

the queue's back entry

In the linked chain implementation of a queue, the chain's first node contains

the queue's front entry

When you remove an item from a stack, you remove it from a.the top b.the bottom c.the middle d.wherever the client specifies

the top

When resizing an array to increase the bag size, if the copy exceeds the maximum memory specified for the computer, the checkCapacitymethod should a.throw an IllegalStateException b.throw a MaxSizeExceededException c.throw a MaxMemoryExceededException d.return false

throw an IllegalStateException

When a counter enumerates simulated time units, it is called a(n)

time-driven simulation

A stub is created for what purpose? a.to avoid syntax errors b.to avoid duplicate code c.to protect the integrity of the ADT d.to practice fail-safe programming

to avoid syntax errors

In a ResizableArrayBag class, why does the addmethod always return true? a.to conform to the bag interface b.because the array will always double in size c.returning void is not a fail-safe programming practice d.all of the above

to conform to the bag interface

Which method can be used to retrieve all of the elements of a bag? a.toArray() b.printBag() c.displayBag() d.getAllItems()

toArray()

Accessing all of the nodes in a chain beginning with the first one is called a(n) a.traversal b.visitation c.chaining d.link crawl

traversal

A class should not return a reference to an array that is a private data field.

true

A final class is more secure than one that is not final.

true

A node does not reference the data in another node.

true

A stack restricts access to its entries.

true

After the method clear, the programmer does not need to worry about deallocating the nodes that were in the chain.

true

All entries in the stack ADT must have the same data type.

true

An array potentially wastes more space than a chain.

true

Any method that adds an entry to a collection is typically considered to be a core method.

true

Any methods that a core method might call are part of the core group.

true

Each node in an ordinary linked chain references only the next node.

true

In a circular array-based implementation of a queue, the available locations are not contiguous.

true

In a circular array-based implementation of a queue, you cannot use only frontIndexto determine when a queue is full.

true

In a linked chain implementation of a queue, when both the firstNode and lastNode entries are null, the chain is empty.

true

In a linked-chain implementation of the Stack ADT, the first node references the stack's top entry.

true

In the program stack, the second record on the stack belongs to the method that called the current method.

true

It is a good programming practice to only access a class's data fields only through accessor and mutator methods.

true

Parentheses override the rule of operator precedence

true

Pull is an alias for the pop method.

true

Queues are used in operating systems.

true

The ArrayDeque class implements the Stack interface

true

The Java Class Library ADT PriorityQueue uses the compareTo method to determine how to order entries.

true

The Java Class Library interface for Queue has no operation to modify the contents of the front entry.

true

The item most recently added to a queue is at the back of the queue.

true

The null value can be used to signal failure to remove or retrieve an entry from a priority queue when it is empty.

true

When a circular linked chain has one node, the node references itself.

true

When comparing objects in a bag, we assume that the class to which the objects belong defines its own version of equals.

true

Write stubs early in the implementation of an ADT so you can begin testing early.

true

You cannot reach the bottom item in a stack without popping all of the other items off first.

true

The removemethod for a given entry returns a.the first entry in the chain that matches or null of it is not in the chain b.the last entry in the chain that matches or null of it is not in the chain c.true if the method succeeds, false otherwise d.none of the above

true if the method succeeds, false otherwise

Which one of the following is considered a safe and secure programming practice? a.validating input data and arguments to a method b.identifying a group of core methods to implement first c.using generic data types d.none of the above

validating input data and arguments to a method

When using abstraction as a design principle you should focus on: a.what you want to do with the data b.how the data is stored c.how the data is manipulated d.all of the above

what you want to do with the data

Why would the add method return false? a.when the addition of a new item was not successful b.when there was a duplicate of the entry already in the bag c.when there was not a duplicate of the entry already in the bag d.when addition of a new item was successful

when the addition of a new item was not successful

When would you choose a two-part circular chain over a circular chain?

when you frequently add an entry after removing one

Given the following infix expression, which one of the following is the corresponding postfix expression? w + x * y / z a.w x y * z / + b.w x + y z * / c.w x y q + * / d.none of the above

wxy*z/+

When adding an item to a bag, which of the following statements are true? a.You cannot specify the position of the item in the bag. b.You can specify the item will be placed as the first in the bag. c.You can specify the item will be placed as the last in the bag. d.None of the above.

you cannot specify the position of the item in the bag

In a circular linked chain, when a node is removed from the queue

it is deallocated

An object you link in Java to form a linked list is called a(n) a.node b.address c.reference d.link

node

Given the following chain, what does the resultant chain look like after removing the node with the entry "L" in it?"J", "X", "F", "K", "L", null a."X", "F", "K", "J", null b."J", "X", "F", "K", null c.you cannot remove the last node d.none of the above

"J", "X", "F", "K", null

If the following nodes are added in order, what does the resultant chain look like? "L", "A", "R", "X", "J" a."J", "X", "R", "A", "L", null b."L", "A", "R", "X", "J", null c.null, "J", "X", "R", "A", "L" d.null, "L", "A", "R", "X", "J"

"J", "X", "R", "A", "L", null

Given the following chain, what does the resultant chain look like after adding the node with an entry "U" in it?"J", "X", "F", "K", "L", null a."U", "J", "X", "F", "K", "L", null b."J", "X","F", "K", "L", "U", null c.you cannot determine where the entry will go in a bag chain implementation d.none of the above

"J", "X","F", "K", "L", "U", null

What item is at the front of the list after these statements are executed?DequeInterface<String> waitingLine = new LinkedDeque<>();waitingLine.addToFront("Jack"); waitingLine.addToFront("Rudy"); waitingLine.addToBack("Larry"); waitingLine.addToBack("Sam"); String name = waitingLine.getBack();

"Rudy"

Given the following chain, what does the resultant chain look like after removing the node with the entry "J" in it? "J", "X", "F", "K", "L", null a."X", "F", "K", "L", null b.null, "X", "F", "K", "L", null c.you cannot remove the first node in an non-empty chain d.none of the above

"X","F","K","L",null

After the following statements execute, what item is at the front of the queue? QueueInterface<String> zooDelivery = new LinkedQueue<>(); zooDelivery .enqueue("lion");zooDelivery .enqueue("tiger");zooDelivery .enqueue("cheetah");String next = zooDelivery .dequeue();next = zooDelivery .dequeue();zooDelivery .enqueue("jaguar");

"cheetah"

After the following statements execute, what item is at the back of the queue? QueueInterface<String> zooDelivery = new LinkedQueue<>();zooDelivery .enqueue("lion");zooDelivery .enqueue("tiger");zooDelivery .enqueue("cheetah");String next = zooDelivery .dequeue();next = zooDelivery .dequeue();zooDelivery .enqueue("jaguar");

"jaguar"

If an array bag contains the entries "lions", "elephants", "otters", "bears", "tigers", "lemurs" and a call to the remove method with the entry "bears" is made, what does the array look like after remove? a."lions", "elephants", "otters", "lemurs", "tigers", null b."lions", "elephants", "otters", null, "tigers", "lemurs" c."lions", "elephants", "otters", "tigers", "lemurs", null d."lions", "elephants", "otters", "tigers", "lemurs"

"lions", "elephants", "otters", "lemurs", "tigers", null

Using the evaluatePostfix algorithm, evaluate the following postfix expression. wx+ y* z/ Assume that w=3 , x=4, y = 2, z = 7. a.2 b.28 c.18 d.21

2

Using the evaluatePostfix algorithm, evaluate the following postfix expression. 7 2 + 4 * a.36 b.13 c.15 d.18

36

Using the evaluatePostfix algorithm, evaluate the following postfix expression. a b + c d -* Assume that a =5,b =7, c = 6, and d = 2. a.48 b.39 c.55 d.none of the above

48

Which instruction suppresses an unchecked-cast warning from the compiler? a.@SuppressWarnings("unchecked") b.@SuppressUnchecked() c.@SuppressUncheckedWarnings() d.@Warning("suppress unchecked")

@SuppressWarnings("unchecked")

An incomplete definition of a method is called a _____. a.stub b.core method c.fail-safemethod d.security problem

stub

What is the entry returned by the peekmethod after the following stack operations.push(A), push(R), pop(), push(D), pop(), push(L), pop(), push(J), push(S), pop(), pop() a.A b.S c.L d.D

A

What happened when a bag becomes full in a linked list implementation? a.An OutofMemoryError will occur. b.The addmethod will return false. c.A MemoryExceededException will be thrown. d.This condition is not possible with a linked list implementation.

An OutofMemoryError will occur

The Java Class Library method to resize an array is called a.Arrays.copyOf b.Arrays.resize c.Arrays.copy d.Arrays.double

Arrays.copyOf

An array whose index of the first location follows the index its last one is call

Circular

What is an advantage of using a chain for a Bag ADT? a.It avoids moving data when adding or removing bag entries. b.It has a fixed size which is easier to manage. c.It can be resized to provide as much space as needed. d.All of the above.

It avoids moving data when adding or removing bag entries

What item is at the front of the list after these statements are executed? DequeInterface<String> waitingLine = new LinkedDeque<>();waitingLine.addToBack("Adam");waitingLine.addToFront("Rudy");waitingLine.addToBack("Larry");waitingLine.addToBack("Sam");waitingLine.addtoFront("Jack");String name = waitingLine.getFront();name = getFront();

Jack

Which code correctly adds the first entry to an empty bag? a.Node newNode = new Node(newEntry); firstNode = newNode; b.Node newNode = new Node();newNode = newEntry;firstNode = newNode; c.botha & b d.none of the above

Node newNode = newNode(newEntry); firstNode = newNode;

In a circular array-based implementation of a queue, what is the performance when the dequeue operation ?

O(1)

What item is at the front of the list after these statements are executed?DequeInterface<String> waitingLine = new LinkedDeque<>();waitingLine.addToFront("Jack"); waitingLine.addToBack("Rudy"); waitingLine.addToBack("Larry"); waitingLine.addToFront("Sam"); String name = waitingLine.getFront(); name = getBack(); waitingLine.addtoBack("Adam");

Rudy

What item is at the front of the list after these statements are executed?DequeInterface<String> waitingLine = new LinkedDeque<>();waitingLine.addToFront("Jack"); waitingLine.addToFront("Rudy"); waitingLine.addToBack("Larry"); waitingLine.addToBack("Sam"); String name = waitingLine.getFront();

Rudy

Given the following chain, what does the resultant chain look like after removing the node with the entry "K" in it? "J", "X", "F", "K", "L", null a."X", "F", "J", "L", null b."J", "X", "F", "L", null c."J", "X", "F", "K", "L", null d.none of the above

X", "F", "J", "L", null

When implementing the bag ADT, which scenario could result in a security problem? a.a client attempts to create a bag whose capacity exceeds a given limit b.a SecurityException is thrown in the constructor c.an IllegalStateException is thrown in the constructor d.the delete method is implemented before the add method

a client attempts to create a bag whose capacity exceeds a given limit

When implementing the bag ADT, which scenario could result in a security problem? a.a constructor throw an exception or error before completing its initialization b.the programmer validates input data to a method c.generics are used to restrict data types of the entries in the collection d.a group of core methods is not defined

a constructor throw an exception or error before completing its initialization

To accommodate entries of any class, the bag methods use ______. a. a generic type b.an inherited type c.a sub class d.all of the above

a generic type

Given the following infix expression, which one of the following is the corresponding postfix expression? a + r ^ 2 -5 a.a r 2 ^ + 5 - b.a r + ^ 5 - c.a r 2 5 + ^ - d.none of the above

a r 2 ^ +5 -

In a node object, the next field contains a.a reference to another node b.the data portion of the node c.a reference to the beginning of the list d.none of the above

a reference to another node

Given the following infix expression, which one of the following is the corresponding postfix expression?(a + b) * (c -d) / (e + f) a.a b + c d -* e f + / b.a b c d e f + * -/ + c.a b + c d -e f + * / d.none of the above

ab+cd-*ef+/

A language-independent specification for a group of values and operations on those values is calleda/an: a.abstract data type b.data structure c.collection d.primitive

abstract data type

The ADT priority queue organizes objects

according to priority of the objects

How does a queue organize it items?

according to the order in which they were added

.You wish to keep track of the distribution of words in a document, for example, how many times the word "apple" appears. You store each word in the document in a bag. Why is a bag a potentially good solution? a.the order of the words is unimportant b.the words in the document are not unique c.getFrequencyOf() is a useful behavior for determining the word distribution d.all of the above

all of the above

A common alias for the queue method dequeue is

all of the above

A common alias for the queue method enqueue is

all of the above

A fixed size array a.has a limited capacity b.can waste memory c.prevents expansion when the bag becomes full d.all of the above

all of the above

A reasonable action when attempting to remove an item from an empty stack is a.assume a precondition that the stack is not empty has been met b.throw an exception c.return null d.all of the above

all of the above

A stub should a.report that is was invoked by displaying a message b.include a return statement that returns a dummy value c.be written early for testing programs d.all of the above

all of the above

A two-part circular linked chain implementation of a queue

all of the above

For which of the following would a bag implementation be suitable? a.a shopping cart b.a vending machine c.a postage stamp collection d.all of the above

all of the above

In a two-part circular linked chain implementation of a queue

all of the above

In an array-based implementation of a queue, a possible solution to dealing with the full condition is to

all of the above

In order to resize an array to accommodate a larger bag, you must a.define an alias that references the original array b.create anew array that is larger than the original array and make the alias reference it c.copy the contents of the original array reference by the alias to the new array and discard the original array d.all of the above

all of the above

In the removemethod, setting the last entry of the array to null a.flags the removed object for garbage collection b.prevents malicious code from accessing it c.is a good security practice d.all of the above

all of the above

The Stack ADT may be implemented with a.a linked-chain b.an array c.a vector d.all of the above

all of the above

The activation record contains a.the method's arguments b.local variables c.a copy of the program counter d.all of the above

all of the above

The clear method a.sets the firstNode to null b.traverses the chain and deallocating each node until it reaches the end c.returns true if it succeeds d.all of the above

all of the above

What are the consequences of returning a reference to the bag array in the toArray method? a.the return variable is an alias for the private instance array variable b.the client will have direct access to the private instance array variable c.the client could change the contents of the private instance array variable without using the public access methods d.all of the above

all of the above

What happens when you use the new operator in the LinkedBag constructor? a.a new node is created b.the JRE allocates memory for a node object c.a new object is instantiated d.all of the above

all of the above

When adding a node to a two-part circular linked chain implementation of a queue

all of the above

When calling the removemethod with an argument if there are multiple entries a.exactly which occurrence removed is unspecified b.only one occurrence is removed c.the first occurrence is removed d.all of the above

all of the above

When removing a node from a two-part circular linked chain implementation of a queue

all of the above

Which behavior(s) leave the contents of a bag unaltered? a.toArray() b.getFrequencyOf() c.isEmpty() d.all of the above

all of the above

Which behaviors change the contents of a bag?a.clear() b.remove() c.add() d.all of the above

all of the above

Which of the following are good reasons to write Java statements that use your bag ADT before the implementation is done? a.it helps confirm the design b.it helps check the suitability of the specification c.it helps check your understanding of the specification d.all of the above

all of the above

Which of the following methods is a good candidate for a core method: a.add() b.toArray() c.isArrayFull() d.all of the above

all of the above

Which of the following real-world events could be simulated using a queue?

all of the above

A test driver for the bad add method should check for which one of the following a.an over capacity condition b.printing elements of the bag c.adding elements of the correct type d.an empty bag condition

an over capacity condition

Where does a queue add new items?

at the back

Where is a new node added to a linked list? a.at the beginning b.at the end c.in the middle d.in a random place

at the end

Where will you find the item added earliest to a queue?

at the front

Which one of the following Java statements allocatesan array in the bag constructorcausing a compiler warning for an unchecked operation? Assume capacityis an integer. a.bag = (T[ ]) new Object[capacity]; b.bag = new T[capacity]; c.bag = new Object[capacity]; d.bag = new (T[ ]) Object[capacity];

bag = (T[]) new Object[capacity];

An expression that has correctly paired delimiters is called a(n) a.balanced expression b.Reverse Polish expression c.infix expression d.algebraic expression

balanced expression

In a linked chain implementation of a queue, when the queue is empty

both & b

If we use a chain of linked nodes with only a head reference to implement a queue which statement is true?

both a & b

A deque ADT behaves

both a and b

An inner class is a.a nested class b.not static c.both a and b d.none of the above

both a and b

When removing a node from a chain, what case should we consider? a.the node is not at the beginning of the chain b.the node is at the end of the chain c.both a and b d.none of the above

both a and b

How can we tell if a two-part circular linked chain queue is empty?

both the queueNode and freeNode reference the same Node

Decrementing the private class variable numberOfEntriesina bag a.causes the last entry to be ignored b.causes an IllegalState exception to be thrown c.destroys the integrity of the bag container d.is a security problem

causes the last entry to be ignored

In a ______ the last node references the first node.

circular linked chain

The operation to remove all entries from a stack is called a(n) a.clear b.remove c.removeAll d.empty

clear

Which method removes all entries of a bag? a.clear() b.remove() c.delete() d.empty()

clear()

An object that groups other objects and provides services to its clients is called a/an: a.collection b.abstract data type c.data structure d.primitive

collection

Which behaviors leave the contents of a bag unaltered? a.contains() b.remove() c.clear() d.add()

contains()

An implementation of an ADT with a programming language is called a/an: a.data structure b.abstract data type c.collection d.primitive

data structure

The _____ ADT that has operations to add, remove, or retrieve entries at both the front and back of a queue is called a

deque

The method for removing an item from the front of a queue is called

dequeue

When the need to expand the size of a bag occurs, the common practice is to a.double the size of the array b.increase the size of the array by one to accommodate the new entry c.use the Fibonacci sequence to determine the incremental size of the new array d.prompt the user for how much larger the bag will need to be

double the size of the array

An object of type Node that contains a data type of Node is a a.circular reference b.improper reference c.forward reference d.logic error

forward reference.

Which method returns a count of the current number of items in a bag? a.getCurrentSize() b.getSize() c.size() d.currentSize()

getCurrentSize()

Which bag behavior is not useful or relevant for a set? a.getFrequencyOf() b.add() c.remove() d.contains()

getFrequencyOf()

The method for retrieving the queue's front entry without altering the queue is called

getFront

_____ is an alias for the peek method. a.getTop b.pull c.look d.all of the above

getTop

A reference to the first node in a linked list is called the _____ reference. a.head b.initial c.first d.default

head

Which of the following is a disadvantage of using an array to implement the ADT bag? a.increasing the size of the array requires time to copy its entries b.adding an entry to a bag is fast c.removing an unspecified entry from the array is fast d.all of the above

increasing the size of the array requires time to copy its entries

Ordinary algebraic expressions are also known as a.infix expressions b.postfix expressions c.prefix expressions d.all of the above

infix expressions

Placing the Node class inside the LinkedBag class makes it a(n) a.inner class b.outer class c.dependent class d.inherited class

inner class

_____ is an alias for the push method. a.insert b.pull c.delete d.all of the above

insertt

Adding a new entry to an empty bag a.is a simple task b.must be treated as a special case c.throws an IllegalOperationException d.causes a NullExceptionError

is a simple task

The precedence of an operator in a postfix expression a.is implied by the order in which the operators and operands occur b.is always left to right c.is always right to left d.depends on the compiler implementation

is implied by the order in which the operators and operands occur

A top-level class a.is not nested b.is nested in an enclosing class c.is always static d.is defined entirely within another class definition

is not nested

Which one of the following is considered a safe and secure programming practice? a.making no assumptions about the actions of clients and users b.using @SupressWarning ("unchecked") c.adding the comments and headers of the public methods to the class by copying them from the interface d.all of the above

making no assumptions about the actions of clients and users

Which of the following would be suitable items to store in a bag? a.marbles b.coins c.student roster d.all of the above

marbles

The remove method with no arguments returns a.the first entry in the chain b.true if the method succeeds, false otherwise c.a random entry in the chain d.none of the above

none of the above

Which behaviors do not change the contents of a bag? a.add() b.clear() c.remove() d.none of the above

none of the above

Which of the following is not true with regard to bags? a.objects are in a specific order b.can contain duplicate items c.is an abstract data type d.is a kind of collection in Java

objects are in a specific order

Sets that adhere to the standard interface in the Java Class library a.do not contain a pair of objects x and y such that x.equals(y) is true b.are completely compatible with the bag interface c.allow duplicate entries d.order the objects contained in the set

od not contain a poair of objects x and y such that x.equals(y) is true

the Java Class Library interface Queue method to put an entry on the back of a queue that returns false if the method fails is

offer

When you add an item to a stack, you place it a.on the top b.on the bottom c.in the middle d.it doesn't matter where

on the top

In a circular array-based implementation of a queue implementation where one unused location is used to differentiate between the front and back of the queue, the frontIndexis _____ than the backIndex.

one more

In a circular array-based implementation of a queue, the initial size of the array should be

one more than the queue's initial capacity

A common alias for the queue method getFront is

peek

The Java Class Library interface Queue method that retrieves the entry at the front of a queue but returns null if the queue was empty is

peek

The operation to retrieve the top entry of a stack without removing it is called a(n) a.peek b.pop c.look d.top

peek

The Java Class Library interface Queue method that retrieves and removes the entry at the front of a queue and returns null if the queue was empty is

poll

The operation to return a stack's top entry is called a(n) a.pop b.get c.top d.peek

pop

Reverse polish notation is another term for a(n) a.postfix expression b.prefix expression c.infix expression d.algebraic expression

postfix expression

Polish notation is another term for a(n) a.prefix expression b.postfix expression c.infix expression d.algebraic expression

prefix expression

During program execution, the _____ references the current instruction. a.program counter b.stack c.frame d.activation record

program counter

At the time a method is called during program execution, the activation record is pushed onto the a.program stack b.execution stack c.frame d.none of the above

program stack

The operation to add an entry to a stack is called a(n) a.push b.add c.put d.peek

push

The ____ ADT organizes its entries according to the order in which they were added.

queue

In the LinkedBag implementation, the numberOfEntries field a.records the number of entries in the current bag b.records the number of nodes in the chain c.is set to zero in a new chain d.all of the above

records the number of entries in the current bag

The Java Class Library interface Queue method that retrieves and removes the entry at the front of a queue and throws a NoSuchElementException if the queue was empty is

remove

Which behavior(s)change the contents of a bag?a.remove() b.getCurrentSize() c.isEmpty() d.getFrequencyOf()

remove()

Which method removes one unspecified entryfrom a bag if possible? a.remove() b.clear () c.delete() d.empty()

remove()

Which method removes one occurrence of a particular entry from a bag if possible?a.remove(anItem) b.clear (anItem) c.delete(anItem) d.empty(anItem)

remove(anitem)

A call to the remove method with no arguments a.removes the first node b.removes the last node c.removes a random node d.asks the user which node to remove

removes a random node

The method removethat has no parameter in the bag implementation a.removes the last entry in the array b.removes the first entry in the array c.removes a random entry in the array d.none of the above

removes the last entry in the array

Which behavior is not represented in a bag?a.reorder the bag b.report the number of items in the bag c.report if the bag is empty d.add an item to the bag

reorder the bag

The most efficient approach to dealing with a gap left in an array after removing an entry from a bag is to a.replace the entry being removed with the last entry in the array and replace the last entry with null b.replace the entry being removed with the first entry in the array and replace the first entry with null c.shift subsequent entries and replace the duplicate reference to the last entry with null d.replace the entry being removed with null

replace the entry being removed with the last entry in the array and replace the last entry with null

A call to the remove method with no arguments on an empty list a.returns null b.returns false c.throws a ListEmptyException d.throws an IllegalOperationException

returns null

If a bag is empty before the removemethod executes, it a.returns null b.throw an exception c.returns an error message d.all of the above

returns null

The dequeue method

returns the item at the front of the queue

The pop and peek methods throw a(n) ________ exception when the stack is empty. a.runtime b.checked c.compile time d.stackEmpty

runtime

To convert an infix expression to a postfix expression a.scan the infix expression left to right b.scan the infix expression right to left c.search for all of the operators first d.search for all of theoperands first

scan the infix expression left to right

.Which of the following is a special kind of bag that does not allow duplicate entries? a.set b.collection c.extended bag d.super bag

set

Which behavior is not specified in the bag ADT?a.sort() b.contains() c.clear() d.remove()

sort()


Kaugnay na mga set ng pag-aaral

Important Math Concepts and Formulas(Review w/Appendix D)

View Set

Business Law (Chapter 25) Agency Formation and Duties

View Set