0% found this document useful (0 votes)
2 views3 pages

Array MCQ Questions

The document contains multiple-choice questions (MCQs) related to arrays in Java, covering topics such as array initialization, accessing elements, error types, and memory allocation. It also includes programming tasks that require defining classes and performing calculations on arrays. The questions test knowledge of array properties, syntax, and operations in Java.

Uploaded by

Tamilselvi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Array MCQ Questions

The document contains multiple-choice questions (MCQs) related to arrays in Java, covering topics such as array initialization, accessing elements, error types, and memory allocation. It also includes programming tasks that require defining classes and performing calculations on arrays. The questions test knowledge of array properties, syntax, and operations in Java.

Uploaded by

Tamilselvi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Array MCQ Questions

[Link] x[ ] = new int[10];


[Link] (x[3]);
(a) Syntax Error
(b) Runtime Error
(c) 0
(d) -1
2. int x[ ]={2, 4, 6, 8, 10, 12};
[Link] (x[2]++ + ++x[4] + x[2]);
(a) 24
(b) 23
(c) 25
(d) 22
3. Which of the following statement displays the 2nd element of an array x?
(a) [Link](x[2]);
(b) [Link](x[1]);
(c) [Link](x[3]);
(d) None of the above
4. Name the type of error in the statement:
int x[ ]={1, 2, 3};
[Link](x[[Link]]);
(a) Syntax error
(b) Run time error
(c) Logical error
(d) No error
5. The array float a[ ]=new float[5] occupies:
(a) 10 bytes
(b) 40 bytes
(c) 20 bytes
(d) 80 bytes
6. Legal subscripts in Java, for an array having N elements.
7. Total size of array A having 25 elements of char type.
8. Total size of array [100] of int type is ?
9. The act of arranging the array elements in a specified order is known as.
10. How do you determine the number of elements in an array?
int buses[] = new int[5];
a) [Link]
b) [Link]()
c) [Link]
d) [Link]()
11. Index in an array starts at .....
a) -1 b) 0 c) 1 d) infinite
12. Assuming int takes 4 bytes of memory, what is the size of int arr[ ] of 15
elements.
a) 15 bytes b) 19 bytes c) 11 bytes d) 60 bytes
[Link] the correct array declaration statement.
a) int arr[ ] = new arr[10]; b) int arr[ ] = new int[10];
c) int arr[i] = 10; d) int arr[10] = new int[10];
14. Which of the following creates an empty two-dimensional array
with dimensions 2×2?
a) int[][] blue = new int[2, 2];
b) int[][] blue = new int[2], [2];
c) int[][] blue = new int[2][2];
d) int[][] blue = new int[2 x 2];
15. Consider the following array and answer the following questions: [2]
int x[ ] ={23 , 45 , 67 , 12 , 45, 89 , 24 , 12 , 9 , 7};
a) int n=[Link]; What will be the value of n?
b) int y=x[1] + x[4]; What will be the value of y?
Answer the Questions:
[Link] a class to declare an array of size 20 of double datatype, accept the
elements into the array and perform the following:
 Calculate and print the sum of all the elements.
 Calculate and print the highest value of the array.

2. A double dimensional array is defined as N[4][4] to store numbers. Write


a program to find the sum of all even numbers and product of all odd
numbers of the elements stored in Double Dimensional Array (DDA).
Sample Input:
12 10 15 17
30 11 32 71
17 14 29 31
41 33 40 51
Sample Output:
Sum of all even numbers: ..........
Product of all odd numbers: ..........

You might also like