The Sample code will test your understanding about the Object class of Java.
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
(1)