Multiple choice

What is the output of the given program?

public class arr
{
public static void main(String[] args)
{
int array[] = {0, 1, 2, 3, 4};
int key = 3;
for (int pos = 0;
pos < array.length; ++pos)
{
if (array[pos] == key)
{
break;
}
}
System.out.print("Found " + key + "at " + pos);
}
}

  1. Found 3 at 2

  2. Found 3 at 3

  3. Found 3 at 4

  4. Compilation fails

  5. Run time error

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The following line does not compile: System.out.print (found + key + at + pos).