Mcq On Java Array

21. Which of these is an incorrect Statement?

A. It is necessary to use new operator to initialize an array
B. Array can be initialized using comma separated expressions surrounded by curly braces
C. Array can be initialized when they are declared
D. None of the mentioned

View Answer


22. What is the type of variable ‘b’ and ‘d’ in the below snippet?

int a[], b;
int []c, d;

A. ‘b’ and ‘d’ are int
B. ‘b’ and ‘d’ are arrays of type int
C. ‘b’ is int variable; ‘d’ is int array
D. ‘d’ is int variable; ‘b’ is int array

View Answer


23. Which of these is necessary to What is the output of below snippet?specify at time of array initialization?

Object[] names = new String[3];
names[0] = new Integer(0);

/

A. ArrayIndexOutOfBoundsException
B. ArrayStoreException
C. Compilation Error
D. Code runs successfully

View Answer


24. How to sort an array?

A. Array.sort()
B. Arrays.sort()
C. Collection.sort()
D. System.sort()

View Answer


25. How to copy contents of array?

A. System.arrayCopy()
B. Array.copy()
C. Arrays.copy()
D. Collection.copy()

View Answer







Also check :


Discussion


* You must be logged in to add comment.