Share on Google+Share on Google+

SCJP Module-9 Question-15

Advertisement
The Sample code will test your understanding about the Object class of Java.

Given below the sample code :

33. Object [] Obj = {
34. new Integer(12),
35. new String("foo"),
36. new Integer(5),
37. new Boolean(true)
38. };
39. Arrays.sort(Obj);
40. for(int i=0; i<Obj.length; i++) {
41. System.out.print(Obj[i].toString());
42. System.out.print(" ");
43. }

What will be the output of the above code ?

1. ClassCastException at line 39.

2. Error at line 33

3. Error at line 41

4. 12 foo 5 true

Answer

(1)

Advertisements

Posted on: July 17, 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.