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

 
 

SCJP Module-9 Question-11
Posted on: July 17, 2010 at 12:00 AM
Advertisement
The sample program given below will test your understanding of inserting data into the object of the ArrayList class and printing them using for loop.

Given below the sample code :

public class Check{
public static void main(String... args) {
ArrayList<Integer> alist = new ArrayList<Integer>();
alist.add(3);
alist.add(12);
alist.add(21);
alist.add(30);
for(int a : alist)
System.out.println(a);
}
}

What will be the output of the above code ?

1. compile error

2. 3 12 21 30

3. 0 0 0 0

4. 30 21 12 3

Answer

(2)

Advertisement

Related Tags for SCJP Module-9 Question-11:


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.

Posted on: July 17, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com