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

 
 

SCJP Module-9 Question-11
Posted on: July 17, 2010 at 12:00 AM
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)

Related Tags for SCJP Module-9 Question-11:


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.