<< Chapter < Page | Chapter >> Page > |
Revised: Thu Apr 07 11:03:31 CDT 2016
This page is included in the following Books:
This module is one in a collection of modules on Java Collections designed for teaching ITSE2321 - Object-Oriented Programming (Java) at Austin Community College in Austin, TX.
This module contains review questions and answers keyed to the module titled Java4100: The Comparator Interface, Part 2 .
Once you study that module, you should be able to answer the review questions in this module.
The questions and the answers in this module are connected by hyperlinks to make it easy for you to navigate from the question to the answer and back again.
What output is produced by the program shown in Listing 1 ?
True or False? By using a Comparator object, you can achieve comparisons and sort orders that are different from the natural ordering for a given element type.
True or False? The first time the fillIt method is called in Listing 1 , the TreeSet collection referred to by the incoming parameter named ref is populated with the following names in the following order:
Joe Bill Tom JOE BILL TOM
True or False? The second time the fillIt method is called in Listing 1 , the TreeSet collection referred to by the incoming parameter named ref is populated with the following names in the following order:
Bill Bill Joe Joe Tom Tom
Explain why the second time the fillIt method is called in Listing 1 , the TreeSet collection referred to by the incoming parameter named ref is populated with the following names in the following order:
Bill Joe Tom
What is the meaning of the following two images?
These images were inserted here simply to insert some space between the questions and the answers to keep them from being visible on the screen at thesame time.
This image was also inserted for the purpose of inserting space between the questions and the answers.
A Comparator object's reference is passed to the TreeSet constructor when the second TreeSet object is instantiated. The Comparator is designed to eliminate the distinction between upper-case and lower-case characters when each new elementis compared with the existing elements. This causes the last three names to be treated as duplicates of the first three names so they are not added to thecollection. As a result, the collection ends up containing only the first three names that are added.
False. The second time the fillIt method is called in Listing 1 , the TreeSet collection referred to by the incoming parameter named ref is populated with the following names in the following order with duplicate elements eliminated:
Notification Switch
Would you like to follow the 'Object-oriented programming (oop) with java' conversation and receive update notifications?