MCQs
Total Questions : 14
| Page 1 of 2 pages
Answer: Option C. -> The program runs fine and displays x[0] is 0.
Question 2. What is the output of the following code?public class Test{ public static void main(String args[]){ double[] myList = {1, 5, 5, 5, 5, 1}; double max = myList[0]; int indexOfMax = 0; for(int i = 1; i < myList.length; i++){ if(myList[i] > max){ max = myList[i]; indexOfMax = i; } } System.out.println(indexOfMax); }}
Answer: Option D. -> 1
Answer: Option B. -> 0
Answer: Option B. -> char[] c = new char[5];
Answer: Option C. -> 120 200 14
Answer: Option D. -> 1 2
Answer: Option D. -> a[1] is 0
Answer: Option B. -> The code can compile and run fine. The second line assigns a new array to arr.
Answer: Option A. -> The reference of the array.