A bag is a very similar construct to a set except that duplicates are allowed in a bag. What changes would have to be made to extend a TreeSet to create an implementation of a bag?
What will be an ideal response?
The primary change would be to remove the duplicate restriction in the add method. Since the addAll method, and then indirectly the union method, use the add method, this one change will allow duplicates. The definitions of other methods would need to be examined as well. For example, should the remove method delete the first occurrence of an element or all occurences of an element?
You might also like to view...
Polymorphism enables you to:
a. program in the general. b. program in the specific. c. absorb attributes and behavior from previous classes. d. hide information from the user.
__________ is a fast, accurate, inexpensive, high-capacity, nonvolatile extension of main memory.
a. RAM b. ROM c. D-RAM d. Secondary storage
Grid lines are the lines between ________ in a table or spreadsheet
A) headers B) paragraphs C) cells D) tabs
When you want to move a GroupBox object, you must first move its contained objects.
Answer the following statement true (T) or false (F)