SCJP Module-6 Question-13


 

SCJP Module-6 Question-13

This program will check your understanding of Collection in Java and prepare you for SCJP exam.

This program will check your understanding of Collection in Java and prepare you for SCJP exam.

Given below the sample code :

public static Collection fetch() {
Collection mylist = new LinkedList();
sorted.add("B"); sorted.add("C"); sorted.add("A");
return mylist;
}
public static void main(String[] args) {
for (Object o: fetch()) {
System.out.print(o + ", ");
}
}

What will be the output of the following code ?

1. Give compile error

2. A B C

3  B, C , A

4. B C A

Answer :

(3)

 

 

Ads