wood burning stoves*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes explain the code output Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "explain the code output" Watch "explain the code output" New topic
Author

explain the code output

anita dhar
Ranch Hand

Joined: Jul 14, 2007
Posts: 69
import java.util.*;
class Flubber
{
public static void main(String[] args)
List<String> x = new ArrayList<String>();
x.add("x");
x.add("xx");
x.add("Xx");

// insert code here
for(String s: x)
System.out.println(s);

And output :
xx
Xx
x



which code inserted at // insert code here . will produce the preeceding output ?
(choose all that apply)

A . Collection.sort(x);

B . Comparable c = Collection.reverse();
Collections.sort(x,c);
C . Comparator c = Collection.reverse();
Collections.sort(x,c);
D . Comparable c = Collection.reverseOrder();
Collections.sort(x,c);
E. Comparator c = Collection.reverseOrder();
Collections.sort(x,c);
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41134
    
  45
That's rather easy to find out, isn't it?

Also, please QuoteYourSources.


Ping & DNS - my free Android networking tools app
anita dhar
Ranch Hand

Joined: Jul 14, 2007
Posts: 69
i am not getting the flow order of this question
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: explain the code output
 
Similar Threads
collections
Whats the output???
doubt about the program???
Collections.sort
comparable and comparator interface