Question
Question 1 2 points Which behaviors change the contents of a bag? clear ( ) add ( ) remove ( ) all of the above
Question 1 2 points
Which behaviors change the contents of a bag?
clear ( )
add ( )
remove ( )
all of the above
Signaler cette question
Question 2 2 points
Which method removes all entries of a bag?
empty()
delete()
remove()
clear()
Signaler cette question
Question 3 2 points
An object of type Node that contains a data type of Node is a
forward reference
logic error
improper reference
circular reference
Signaler cette question
Question 4 2 points
1. Which instruction suppresses an unchecked-cast warning from the compiler?
@SuppressUnchecked()
@SuppressWarnings(unchecked)
@SuppressUncheckedWarnings()
@Warning(suppress unchecked)
Signaler cette question
Question 5 2 points
1. When you write a program for an algorithm and it is taking much longer than expected you should
buy a faster computer
try to design a better algorithm
rewrite the algorithm in a different language
ignore the problem
Signaler cette question
Question 6 2 points
A language-dependent specification for a group of values and operations on those values is called a/an:
data structure
abstract data type
collection
primitive
Signaler cette question
Question 7 2 points
1. Which one of the following Java statements allocates an array in the bag constructor causing a compiler warning for an
unchecked operation? Assume capacity is an integer.
bag = new T[capacity];
bag = new Object[capacity];
bag = (T[ ]) new Object[capacity];
bag = new (T[ ]) Object[capacity];
Signaler cette question
Question 8 2 points
1. What are the consequences of returning a reference to the bag array in the toArray method?
the return variable is an alias for the private instance array variable
the client will have direct access to the private instance array variable
the client could change the contents of the private instance array variable without using the public access methods
all of the above
Signaler cette question
Question 9 2 points
A stub should ______________.
report that is was invoked by displaying a message
include a return statement that returns a dummy value
be written early for testing programs
all of the above
Signaler cette question
Question 10 2 points
Where is a new node added to a linked list?
at the end
at the beginning
in the middle
in a random place
Signaler cette question
Question 11 2 points
1. In a node object, the next field contains
a reference to another node
the data portion of the node
a reference to the beginning of the list
none of the above
Signaler cette question
Question 12 2 points
An algorithm has
time requirements
space requirements
both a and b
none of the above
Signaler cette question
Question 13 2 points
1. Measuring the growth of an algorithms time requirement grows as the problem size increases is called the
time complexity
growth rate function
space complexity
overall measurement function
Signaler cette question
Question 14 2 points
Which of the following is NOT true with regard to bags?
can contain duplicate items
is an abstract data type
objects are in a specific order
is a kind of collection in Java
Signaler cette question
Question 15 2 points
1. The most significant contributor to an algorithms time requirement is
the addition operaton
the multiplication operation
the algorithms basic operation
memory access time
Signaler cette question
Question 16 2 points
Which method removes one occurrence of a particular entry from a big if possible?
clear ( an Item )
remove ( an Item )
delete ( an Item )
empty ( an Item )
Signaler cette question
Question 17 2 points
1. To measure the time requirement of an algorithm, we must
run the algorithm for different problem sizes
code the algorithm in several different languages and compare the run times
find an appropriate growth rate function
all of the above
Signaler cette question
Question 18 2 points
Why would the add method return false?
when addition of a new item was successful
when there was not a duplicate of the entry already in the bag
when there was a duplicate of the entry already in the bag
when the addition of a new item was not successful
Signaler cette question
Question 19 2 points
Which method returns a count of the current number of items in a bag?
getCurrentSize()
getSize()
size()
currentSize()
Signaler cette question
Question 20 2 points
1. The memory required to run an algorithm is called
memory complexity
time complexity
spae complexity
storage complexity
Signaler cette question
Question 21 2 points
What is an advantage of using a chain for a Bag ADT?
It has a fixed size which is easier to manage.
It can be resized to provide as much space as needed.
It avoids moving data when adding or removing bag entries.
All of the above.
Signaler cette question
Question 22 2 points
1. When removing a node from a chain, what case should we consider?
the node is at the end of the chain
the node is at the beginning of the chain
both a and b
none of the above
Signaler cette question
Question 23 2 points
1. A stub is created for what purpose?
to avoid duplicate code
to avoid syntax errors
to protect the integrity of the ADT
to practice fail-safe programming
Signaler cette question
Question 24 2 points
When removing a node from a chain, what case should we consider?
the node is not at the beginning of the chain
the node is at the end of the chain
both a and b
none of the above
Signaler cette question
Question 25 2 points
1. A measure of an algorithms execution needs is called
time complexity
speed complexity
space complexity
run time complexity
Signaler cette question
Question 26 2 points
1. Which one of the following is considered a safe and secure programming practice?
using @SupressWarning (unchecked)
making no assumptions about the actions of clients and users
adding the comments and headers of the public methods to the class by copying them from the interface
all of the above
Signaler cette question
Question 27 2 points
An incomplete definition of a method is called a _____.
core method
fail-safe method
stub
security problem
Signaler cette question
Question 28 2 points
An implementation of an ADT with a programming language is called a/an:
primitive
collection
abstract data type
data structure
Signaler cette question
Question 29 2 points
Which method removes one unspecified entry from a bag if possible?
clear()
remove()
delete()
empty()
Signaler cette question
Question 30 2 points
1. For large values of n which statement is true?
(n2 + n ) / 2 behaves like n2
(n2 + n ) / 2 behaves like n
(n2 + n ) / 2 behaves like n/2
all of the above
Signaler cette question
Question 31 2 points
1. Which one of the following is considered a safe and secure programming practice?
using generic data types
identifying a group of core methods to implement first
validating input data and arguments to a method
none of the above
Signaler cette question
Question 32 2 points
Accessing all of the nodes in a chain beginning with the first one is called a(n)
visitation
chaining
link crawl
traversal
Signaler cette question
Question 33 2 points
1. When implementing the bag ADT, which scenario could result in a security problem?
a SecurityException is thrown in the constructor
an IllegalStateException is thrown in the constructor
the delete method is implemented before the add method
a client attempts to create a bag whose capacity exceeds a given limit
Signaler cette question
Question 34 2 points
1. Which code correctly adds the first entry to an empty bag?
Node newNode = new Node();
newNode = newEntry;
Node newNode = new Node(newEntry);
firstNode = newNode;
both a & b.
none of the above.
Signaler cette question
Question 35 2 points
Which of the following methods is a good candidate for a core method?
add ( )
toArray ( )
isArrayFull ( )
all of the above.
Signaler cette question
Question 36 2 points
What happened when a bag becomes full in a linked list implementation?
The add method will return false.
A MemoryExceededException will be thrown.
An OutofMemoryError will occur.
This condition is not possible with a linked list implementation.
Signaler cette question
Question 37 2 points
Which of the following methods is a good candidate for a core method?
clear ( )
contains ( )
add ( )
remove ( )
Signaler cette question
Question 38 2 points
Which behaviors do not change the contents of a bag?
remove ( )
add ( )
clear ( )
none of the above
Signaler cette question
Question 39 2 points
1. Which of the following operations could be identified as the basic operation of an algorithm?
addition
multiplication
division
all of the above
Signaler cette question
Question 40 2 points
A programs execution time depends in part on
the speed of the computer it is running on
the memory capacity
the language the algorithm is written i
all of the above
Signaler cette question
Question 41 2 points
Problem size is defined as
the amount of memory an algorithms uses
the number of items an algorithms processes
the amount of execution time an algorithm takes
none of the above
Signaler cette question
Question 42 2 points
1. When implementing the bag ADT, which scenario could result in a security problem?
a constructor throw an exception or error before completing its initialization
the programmer validates input data to a method
generics are used to restrict data types of the entries in the collection
a group of core methods is not defined
Signaler cette question
Question 43 2 points
What happens if an OutOfMemoryError occurs while adding a new node to the chain?
the chain will lose its integrity
a faulty node will be added to the beginning of the chain
access to the chain will be lost
the chain will remain intact
Signaler cette question
Question 44 2 points
1. An object you link in Java to form a linked list is called a(n)
node
address
reference
link
Signaler cette question
Question 45 2 points
1. To properly evaluate the effectiveness of an algorithm, you need to determine
the average case
the best case
the worst case
all of the above
Signaler cette question
Question 46 2 points
An object that groups other objects and provides services to its clients is called a/an:
collection
abstract data type
data structure
primitive
Signaler cette question
Question 47 2 points
A test driver for the bad add method should check for which one of the following
printing elements of the bag
adding elements of the correct type
an over capacity condition
an empty bag condition
Signaler cette question
Question 48 2 points
Which behavior is NOT represented in a bag?
reorder the bag
report the number of items in the bag
report if the bag is empty
add an item to the bag
Signaler cette question
Question 49 2 points
1. Computing the sum of the first n integers using the formulat n * (n + 1) / 2 has a growth rate
of n2
of n2 + n
independent of n
all of the above
Signaler cette question
Question 50 2 points
What happens when you use the new operator in the LinkedBag constructor?
a new node is created
the JRE allocates memory for a node object
a new object is instantiated
all of the above
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started