Online Test Name | Java Arrays |
Exam Type | Multiple Choice Questions |
Category | Computer Science Engineering Quiz |
Number of Questions | 05 |
Answer: Option C
Explanation:
Operator new allocates block of memory specified by the size of array, and gives the reference of memory allocated to the array variable.
Answer: Option D
Explanation:
Operator new must be succeeded by array type and array size.
What will this code print?
int arr[] = new int [5];
System.out.print(arr);
Answer: Option D
Explanation:
arr is an array variable, it is pointing to array if integers. Printing arr will print garbage value. It is not same as printing arr[0].
Answer: Option A
Explanation:
Array can be initialized using both new and comma separated expressions surrounded by curly braces example : int arr[5] = new int[5]; and int arr[] = { 0, 1, 2, 3, 4};