Examveda

What will be the output of the following Java program?
class Output 
{
    public static void main(String args[])
    {
        int arr[] = {1, 2, 3, 4, 5};
        for ( int i = 0; i < arr.length - 2; ++i)
            System.out.println(arr[i] + " ");
    } 
}

A. 1 2

B. 1 2 3

C. 1 2 3 4

D. 1 2 3 4 5

Answer: Option B


This Question Belongs to Java Program >> Miscellaneous In Java

Join The Discussion

Related Questions on Miscellaneous in Java