COMPUTER SCIENCE AND ENGINEERING
DATA STRUCTURES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
Which of the following arrays has a length of 5?
|
double[] arr = new double[6];
|
|
double[] arr = {0, 1, 2, 3, 4, 5};
|
|
double[] arr = new double[]{1, 2.3, 4, 5};
|
|
None of the above
|
Explanation:
Detailed explanation-1: -The following declaration creates an array of 10 elements: double[] values = new double[10]; An index can be any integer ranging from 0 to 9.
Detailed explanation-2: -Which of the following is the correct way to declare a multidimensional array in Java? Explanation: The syntax to declare multidimensional array in java is either int[][] arr; or int arr[][]; 5.
Detailed explanation-3: -Explanation: Index in array start with 0.
Detailed explanation-4: -Explanation: Arrays use the length variable to determine the number of elements, making Option A correct.
There is 1 question to complete.