Share on Google+Share on Google+

SCJP Module-6 Question-13

Advertisement
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)

 

 

Advertisements

Posted on: July 14, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.