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

 
 

Share on Google+Share on Google+
SCJP Module-9 Question-24
Posted on: July 19, 2010 at 12:00 AM
Advertisement
The Sample code given below will test your knowledge on ArrayList of Java and this example is very helpful for successful completion of SCJP examination.

Given below the sample code :

public static void addition(List list) {
list.add("0021");
}
public static void main(String[] args) {
List<Integer> myList = new ArrayList<Integer>();
addition(myList);
System.out.println(myList.get(0));
}

What will be the output of the above code ?

1. 21

2. 0021

3. An exception is thrown at runtime.

4. Compilation fails.

Answer

(2)

Advertisement

Related Tags for SCJP Module-9 Question-24:


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 19, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com