Prerequisite : Java Arrays
Question 1. What is the output of this question?
B) Runtime Exception
Explanation : To specify array size allowed data type are – byte, short, int, char and all of these are valid data types here.
Question 2. What is the output of this question?
C) Run successfully
Explanation : One Dimension array have size declaration as compulsory feature.
Error : array dimension missing int a11 = new int; // line 2
Question 3. Which of the following declarations are invalid?
B) line 1, 3, 4
C) line 3, 4
D) line 2, 3, 4
Explanation : First two declarations are allowed and so no error. line 3 and 4 have zero and last dimension respectively.
error: array dimension missing
int arr3=new int;//line 3 ^ error: ']' expected int arr4=new int;//line 4 ^ error: ';' expected int arr4=new int;//line 4
Question 4. Which of the following lines give error?
A) line 4, 5, 6, 7
C) No Error
D) line 4, 7
Explanation : In three dimensional array have first two dimension declaration is compulsory other wise we will get compile time error:illegal startup expression.
Question 5. What is the output of this question?
C) 0 0 0 0 0
Explanation : arr : It is giving the base address of array
arr : It is giving value of array element at 0th location.
This article is contributed by Shivakant Jaiswal. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.