What will be the output of the following Java program?
public class SumOfArray
{
public static void main(String[ ] args) {
int [ ] arr = new int [ ] {1, 2, 3, 4};
int sum = 0;
for (int i = 0; i < arr.length; i++)
{
sum = sum + arr[i];
}
System.out.println("Sum of all the elements of an arry: " + sum);
}
}
1
Sum of all the elements of an array: 9
2
Sum of all the elements of an array: 10
3
sum of all the elements of an array: 12
4
Error