SCJP Module-9 Question-23


 

SCJP Module-9 Question-23

The sample code given below will check your understanding about the sorting string of an ArrayList object.

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)

Ads