-
What is the output of this program?
public class Result
{
public static void main(String args[])
{
int array1[] = new int[8];
int array2[] = {5, 8, 7, 6, 9};
System.out.println(array1.length + " " + array2.length);
}
}
-
- 9 5
- 5 9
- 8 5
- 5 8
- None of these
Correct Option: C
Arrays in java are implemented as objects, they contain an attribute that is length which contains the number of elements that can be stored in the array. Hence array1.length gives 8 and array2.length gives 5.
output: 8 5