πŸ“Š JAVA
Q. What is the output of the following code?
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);
        }
}
  • (A) 0
  • (B) 1
  • (C) 2
  • (D) 3
πŸ’¬ Discuss
βœ… Correct Answer: (B) 1

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
173
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Shivam
Publisher
πŸ“ˆ
99%
Success Rate