COMPUTER GAYN
MCQ BASED ON ARRAY
1. Which of these best describes an array?
a) A data structure that shows a hierarchical behaviorb) Container of objects of similar types
c) Arrays are immutable once initialised
d) Array is not a data structure
ans:- b
2. How do you initialize an array in C?
a) int arr[3] = (1,2,3);
b) int arr(3) = {1,2,3};
c) int arr[3] = {1,2,3};
d) int arr(3) = (1,2,3);
a) int arr[3] = (1,2,3);
b) int arr(3) = {1,2,3};
c) int arr[3] = {1,2,3};
d) int arr(3) = (1,2,3);
ans:- c
3. How do you instantiate an array in Java?
a) int arr[] = new int(3);
b) int arr[];
c) int arr[] = new int[3];
d) int arr() = new int(3);
a) int arr[] = new int(3);
b) int arr[];
c) int arr[] = new int[3];
d) int arr() = new int(3);
ans:- c
4. Which of the following is the correct way to declare a multidimensional array in Java?
a) int[] arr;
b) int arr[[]];
c) int[][]arr;
d) int[[]] arr;
a) int[] arr;
b) int arr[[]];
c) int[][]arr;
d) int[[]] arr;
ans:- c
5. What are the advantages of arrays?
a) Objects of mixed data types can be stored
b) Elements in an array cannot be sorted
c) Index of first element of an array is 1
d) Easier to store elements of same data type
a) Objects of mixed data types can be stored
b) Elements in an array cannot be sorted
c) Index of first element of an array is 1
d) Easier to store elements of same data type
ans:- d
6. Elements in an array are accessed _____________
a) randomly
b) sequentially
c) exponentially
d) logarithmically
a) randomly
b) sequentially
c) exponentially
d) logarithmically
ans:- a
0 Comments