QUESTION 4 All entries of a bag must have the same data type or a subtype of tha
ID: 2247662 • Letter: Q
Question
QUESTION 4
All entries of a bag must have the same data type or a subtype of that data type.
True
False
1 points
QUESTION 5
By declaring a data type to be a BagInterface, we can replace the bag class with another class that implements the BagInterface.
True
False
1 points
QUESTION 6
A method can change the state of an object passed to it as an argument.
True
False
1 points
QUESTION 7
A set is a special kind of bag.
True
False
1 points
QUESTION 8
A language-independent specification for a group of values and operations on those values is called a/an:
abstract data type
data structure
collection
primitive
1 points
QUESTION 9
An implementation of an ADT with a programming language is called a/an:
data structure
abstract data type
collection
primitive
1 points
QUESTION 10
An object that groups other objects and provides services to its clients is called a/an:
collection
abstract data type
data structure
primitive
1 points
QUESTION 11
Which of the following is not true with regard to bags?
objects are in a specific order
can contain duplicate items
is an abstract data type
is a kind of collection in Java
1 points
QUESTION 12
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
1 points
QUESTION 13
Why would the add method return false?
when the addition of a new item was not successful
when there was a duplicate of the entry already in the bag
when there was not a duplicate of the entry already in the bag
when addition of a new item was successful
1 points
QUESTION 14
Which behaviors do not change the contents of a bag?
add()
clear()
remove()
none of the above
1 points
QUESTION 15
Which behaviors change the contents of a bag?
clear()
remove()
add()
all of the above
1 points
QUESTION 16
When using abstraction as a design principle you should focus on:
what you want to do with the data
how the data is stored
how the data is manipulated
all of the above
1 points
QUESTION 17
Which of the following is a special kind of bag that does not allow duplicate entries?
set
collection
extended bag
super bag
1 points
QUESTION 18
When adding an item to a bag, which of the following statements are true?
You cannot specify the position of the item in the bag.
You can specify the item will be placed as the first in the bag.
You can specify the item will be placed as the last in the bag.
None of the above.
1 points
QUESTION 19
To accommodate entries of any class, the bag methods use ______ .
a generic type
an inherited type
a sub class
all of the above
1 points
QUESTION 20
Which behavior(s) change the contents of a bag?
remove()
getCurrentSize()
isEmpty()
getFrequencyOf()
1 points
QUESTION 21
Which behavior(s) change the contents of a bag?
add()
getFrequencyOf()
contains()
toArray()
1 points
QUESTION 22
Which behaviors leave the contents of a bag unaltered?
contains()
remove()
clear()
add()
1 points
QUESTION 23
Which behavior(s) leave the contents of a bag unaltered?
toArray()
getFrequencyOf()
isEmpty()
all of the above
1 points
QUESTION 24
Which of the following are good reasons to write Java statements that use your bag ADT before the implementation is done?
it helps confirm the design
it helps check the suitability of the specification
it helps check your understanding of the specification
all of the above
1 points
QUESTION 25
Which of the following would be suitable items to store in a bag?
marbles
coins
student roster
all of the above
1 points
QUESTION 26
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?
the order of the words is unimportant
the words in the document are not unique
getFrequencyOf() is a useful behavior for determining the word distribution
all of the above
1 points
QUESTION 27
For which of the following would a bag implementation be suitable?
a shopping cart
a vending machine
a postage stamp collection
all of the above
1 points
QUESTION 28
Which behavior is not specified in the bag ADT?
sort()
contains()
clear()
remove()
1 points
QUESTION 29
Which bag behavior is not useful or relevant for a set?
getFrequencyOf()
add()
remove()
contains()
1 points
QUESTION 30
Which bag behaviors would need modified when implementing a set?
add()
clear()
contains()
toArray()
abstract data type
data structure
collection
primitive
Explanation / Answer
let's talk a bit about bags first ,
bag is a collection of objects where new objects can be added to the bag but can't be removed once added to the bag.
the basic possible operation available on the bag data structure are
Q4) True.
Q5) - true
Q6) - false
Q7) - true
Q8 ) abstract data type
Q9) data structure.
Q10) collection
Q11) can't contain dublicate elements
Q12) reorder a bag
Q13) when there was a duplicate of the entry already in the bag
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.