adplus-dvertising
frame-decoration

Question

What is the output of this 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

Posted under Java Programming

Answer: (b).1 2 3

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of this program?