<< Chapter < Page Chapter >> Page >
This module contains review questions and answers keyed to the module titled Java4100: The Comparator Interface, Part 2.

Revised: Thu Apr 07 11:03:31 CDT 2016

This page is included in the following Books:

Table of contents

Preface

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.

Questions

Question 1 .

What output is produced by the program shown in Listing 1 ?

  • Compiler Error
  • Runtime Error
  • Joe Bill Tom JOE BILL TOM
  • Tom TOM Joe JOE Bill BILL
  • Joe Bill Tom
  • None of the above.

Answer 1

Question 2

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.

Answer 2

Question 3

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

Answer 3

Question 4

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

Answer 4

Question 5

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

Answer 5

Listings

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.

Spacer image of a rabbit and a penguin.

This image was also inserted for the purpose of inserting space between the questions and the answers.

Spacer image of a penguin and some houses.

Answers

Answer 5

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.

Back to Question 5

Answer 4

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:

Questions & Answers

What are types of cell
Nansoh Reply
how can I get this book
Gatyin Reply
what is lump
Chineye Reply
what is cell
Maluak Reply
what is biology
Maluak
what's cornea?
Majak Reply
what are cell
Achol
Explain the following terms . (1) Abiotic factors in an ecosystem
Nomai Reply
Abiotic factors are non living components of ecosystem.These include physical and chemical elements like temperature,light,water,soil,air quality and oxygen etc
Qasim
what is biology
daniel Reply
what is diffusion
Emmanuel Reply
passive process of transport of low-molecular weight material according to its concentration gradient
AI-Robot
what is production?
Catherine
Pathogens and diseases
how did the oxygen help a human being
Achol Reply
how did the nutrition help the plants
Achol Reply
Biology is a branch of Natural science which deals/About living Organism.
Ahmedin Reply
what is phylogeny
Odigie Reply
evolutionary history and relationship of an organism or group of organisms
AI-Robot
ok
Deng
what is biology
Hajah Reply
cell is the smallest unit of the humanity biologically
Abraham
ok
Achol
what is biology
Victoria Reply
what is biology
Abraham
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Object-oriented programming (oop) with java. OpenStax CNX. Jun 29, 2016 Download for free at https://legacy.cnx.org/content/col11441/1.201
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Object-oriented programming (oop) with java' conversation and receive update notifications?

Ask