Menu
Question Index
...

What will be the output of the following program?

public class GuessWhat
{
    public static void main(String args[])
    {
        int a[] = {11, 6, 17, 8, 9, 34, 14};
        System.out.println(guessWhat(a));
    }
    public static int guessWhat(int arr[])
    {
        int x = 0;
        for (int element : arr)
        x = x < element ? element : x;
        return x;
    }
}


Returns the index of the highest element in the array
Returns true/false if there are any elements that repeat in the array
Returns the highest element in the array
Returns the index of the lowest element in the array
Compilation Error or Runtime Error

Doubts

Problems

Topic: For-each Loop In Core Java Programming

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App