adplus-dvertising
frame-decoration

Question

What is the output of the below Java program?
int ages[3] = {25, 27, 30};
System.out.println(ages[1]);

a.

25

b.

27

c.

30

d.

Compile error

Posted under Java Programming

Answer: (d).Compile error

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 the below Java program?

Similar Questions

Discover Related MCQs

Q. We should not specify the array size if declaration and initialization are done at the same time. (TRUE / FALSE)

Q. If an index of an element is N, what is its actual position in the array?

Q. An array in Java can be declared only of some predefined types. (TRUE/FALSE)

Q. The name of an array variable or identifier can start with ___.

Q. Shorthand array initialization in Java needs the keyword "new" to allocate memory to the array and elements. State TRUE or FALSE.

Q. Lazy initialization of array requires the keyword "new" to allocate memory to the array and its elements. State TRUE or FALSE.

Q. What is the default value of an element of Object type array?

Q. What is the default value of byte, short, int or long data type elements of an array in Java?

Q. What is the default value of float or double data type elements of an array in Java?

Q. What is the default value of a char data type elements of an array in Java?

Q. What is the default value of boolean data type elements of an array in Java?

Q. Allocating memory with the keyword "new" causes the array elements to carry default values. State TRUE or FALSE.

Q. An array of arrays in Java is called ___ array.

Q. A multidimensional array contains elements of the same data-type in all rows and columns. State TRUE or FALSE.

Q. An array of dimension N contains __ number of subscripts or brackets?

Q. An array with two dimensions is called a two-dimensional array in Java. State TRUE or FALSE.

Q. Row number and Column number in a Multidimensional array start with ___.

Q. A 4-dimensional array is an array of ___ dimensional arrays.

Q. Choose the correct way of initializing a multidimensional array below.

Q. State TRUE or FALSE. In a multidimensional array, the number of Columns in each Row can be different.
1
2 3
4 5 6