<< Chapter < Page | Chapter >> Page > |
True or False? There is a class named Arrays that contains various methods for manipulating arrays (such as sorting and searching) . The Arrays class contains many overloaded versions of the sort method. As usual, each overloaded version of the sort method requires a different argument list.
Given: Listing 1 makes two calls to overloaded sort methods of the Arrays class using the following overloaded methods. (Note that I omitted generics syntax from the signatures because generics is beyond the scope of this course .)
True or False? In Listing 1 , the call to the first sort method in the above list produces the following output:
Tom TOM Joe JOE Bill BILL
True or False? In Listing 1 , the call to the second sort method in the above list produces the following output:
Tom TOM Joe JOE Bill BILL
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.
True.
False. Here is what the documentation has to say about this overloaded version of the Arrays.sort method:
Sorts the specified array of objects into ascending order, according to the natural ordering of its elements. All elements in the array must implementthe Comparable interface.
According to that specification, the output would be:
BILL Bill JOE Joe TOM Tom
True.
True.
True.
False. By default, a Vector object does not sort the elements. Therefore, the output order is the same as the input order shown inthe fillIt method.
Joe Bill Tom JOE BILL TOM
True.
True.
False. The position of each element in an ordered collection is determined by a numeric index associated with the element and is independent ofthe value of the element.
True.
False. Because a Vector object is a List object, (and not a Set object) it is allowed to contain duplicate elements.
False. A Vector object is a List object. The Vector class implements the Collection interface and the List interface but not the Set interface.
Collection data
Joe Bill Tom JOE BILL TOM
Raw array data
Joe Bill Tom JOE BILL TOM
Natural order sorted array data
BILL Bill JOE Joe TOM Tom
Custom order sorted array data
Tom TOM Joe JOE Bill BILL
Collection data
Joe Bill Tom JOE BILL TOM
True.
True.
False. The Collection interface declares a method named toArray , which can be called on a Collection object to "return an array containing all of the elements in this collection whose runtime type is that ofthe specified array" .
Notification Switch
Would you like to follow the 'Object-oriented programming (oop) with java' conversation and receive update notifications?