-
What is the output of this program?
public class Result
{
public static void main(String args[])
{
int a[] = {5, 6, 7, 9, 11};
for ( int k = 0; k < a.length - 1; ++k)
System.out.print(a[k] + " ");
}
}
-
- 6 7 9 11
- 5 6 7 9
- 1 2 3 4
- 5 6 7 8
- None of these
Correct Option: B
a.length() is 5, so the loop is executed for 4 times.
output: 5 6 7 9