Java - MCQ
Multiple Choice Questions
Java MCQ - Methods and Arrays - Set 33
26. What will be the output of the following Java code snippet?
Object[] names = new String[3];
names[0] = new Integer(0);
A). ArrayIndexOutOfBoundsException
B). ArrayStoreException
C). Compilation Error
D). Code runs successfully
View Answer
Correct: B
27. Generics does not work with?
A). Set
B). List
C). Tree
D). Array
View Answer
Correct: D
28. How to sort an array?
A). Array.sort()
B). Arrays.sort()
C). Collection.sort()
D). System.sort()
View Answer
Correct: B
29. How to copy contents of array?
A). System.arrayCopy()
B). Array.copy()
C). Arrays.copy()
D). Collection.copy()
View Answer
Correct: A
30. Where is an array stored in memory?
A). heap space
B). stack space
C). heap space and stack space
D). first generation memory
View Answer
Correct: A