MCQs
Total Questions : 105
| Page 1 of 11 pages
Answer: Option B. -> char[] c = new char[5];
Answer: Option A. -> 0
Answer: Option C. -> The program runs fine and displays x[0] is 0.
Question 5. 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);
}
}
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 B. -> 1
Answer: Option B. -> 120 200 14
Answer: Option C. -> 1 2
Answer: Option C. -> a[1] is 0
Answer: Option C. -> The code can compile and run fine. The second line assigns a new array to arr.
Answer: Option C. -> The reference of the array.