Home Tutorial Java Scjp Part9 SCJP Module-9 Question-23

 
 

SCJP Module-9 Question-23
Posted on: July 19, 2010 at 12:00 AM
The sample code given below will check your understanding about the sorting string of an ArrayList object.

Given below the sample code :

import java.util.*;
public class SortStrings{
public static void main(String[] args) {
ArrayList<String> str = new ArrayList<String>();
str.add("bBbB");
str.add("BbB");
str.add("bBb");
str.add("BBbb");
Collections.sort(str);
for (String a : str) { System.out.print(a + " "); }
}
}

What will be the output of the above code ?

 1. bBbB bBb BBbb BbB

2. BBbb Bbb bBb bBbB

3. BbB BBbb bBbB bBb

4. bBb BbB bBbB BBbb

Answer

(2)

Related Tags for SCJP Module-9 Question-23:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.