Single Choice Not Set

QWhat 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);
        }
}

 

ID: #2200 Java Constructor and Methods 1,810 views
Question Info
#2200Q ID
Not SetDifficulty
Java Constructor and MethodsTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • B 1
  • C 2
  • D 3
Correct Answer

Explanation

1

Share This Question

Challenge a friend or share with your study group.