MCQOPTIONS
Saved Bookmarks
This section includes 100 Mcqs, each offering curated multiple-choice questions to sharpen your Arrays knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
Consider the declaration char street[10] = "abcdefghi"; Choose the correct remark(s) |
| A. | &street and street will have different values |
| B. | &street is meaningless |
| C. | &street+1 and street+1 will have the same values |
| D. | None of the above |
| Answer» E. | |
| 2. |
A file is preferable to an array of structures because |
| A. | file lives even after the program that created it terminates |
| B. | memory space will not be wasted |
| C. | there are many system tools to manipulate files |
| D. | All of the above |
| Answer» E. | |
| 3. |
Pick the correct answers if x is an one dimensional array, then |
| A. | &x[ i ] is same as x + i - 1 |
| B. | *(x + 1) is same as *(&x [ i ]) |
| C. | *(x + i) is same as x[ i ] |
| D. | both (b) & (c) |
| Answer» E. | |
| 4. |
Choose the correct statements |
| A. | an entire array can be passed as an argument to a function |
| B. | a part of an array can be passed as argument to a function |
| C. | any change done to an array that is passed as an argument to a function will be local to the function |
| D. | Both (a) & (b) |
| Answer» E. | |
| 5. |
While sorting a set of names, representing the names as an array of pointers is preferable to representing the names as a two dimensional array of characters because |
| A. | storage needed will be proportional to the size of the data |
| B. | execution will be faster |
| C. | swapping process becomes easier and faster |
| D. | All of the above |
| Answer» E. | |
| 6. |
If arr is a two dimensional array of 10 rows and 12 columns, then arr (5) logically points to the |
| A. | sixth row |
| B. | Fifth row |
| C. | fifth column |
| D. | sixth column |
| Answer» B. Fifth row | |
| 7. |
A set of names can be represented as a |
| A. | two-dimensional array of characters |
| B. | one-dimensional array of strings |
| C. | one-dimensional array of pointers to character |
| D. | All of above |
| Answer» E. | |
| 8. |
Which of the following concepts make extensive use of arrays? |
| A. | Binary trees |
| B. | Scheduling of processes |
| C. | Caching |
| D. | Spatial locality |
| Answer» E. | |
| 9. |
When does the ArrayIndexOutOfBoundsException occur? |
| A. | Compile-time |
| B. | Run-time |
| C. | Not an error |
| D. | Not an exception at all |
| Answer» C. Not an error | |
| 10. |
What is the output of the following piece of code? public class array { public static void main(String args[]) { int []arr = {1,2,3,4,5}; System.out.println(arr[5]); } } |
| A. | 4 |
| B. | 5 |
| C. | ArrayIndexOutOfBoundsException |
| D. | InavlidInputException |
| Answer» D. InavlidInputException | |
| 11. |
Minimum number of interchange needed to convert the array 89,19,40,14,17,12,10,2,5,7,11,6,9,70, into a heap with the maximum element at the root is |
| A. | 1 |
| B. | 2 |
| C. | 3 |
| Answer» D. | |
| 12. |
A one dimensional array A has indices 1....75.Each element is a string and takes up three memory words. The array is stored starting at location 1120 decimal. The starting address of A[49] is |
| A. | 1167 |
| B. | 1164 |
| C. | 1264 |
| D. | 1169 |
| Answer» D. 1169 | |
| 13. |
If S is an array of 80 characters, then the value assigned to S through the statement scanf("%s",S) with input 12345 would be |
| A. | "12345" |
| B. | nothing since 12345 is an integer |
| C. | S is an illegal name for string |
| D. | %s cannot be used for reading in values of S |
| Answer» B. nothing since 12345 is an integer | |
| 14. |
For 'C' programming language |
| A. | Constant expressions are evaluated at compile |
| B. | String constants can be concatenated at compile time |
| C. | Size of array should be known at compile time |
| D. | All of these |
| Answer» E. | |
| 15. |
If x is an array of interger, then the value of &x[i] is same as |
| A. | &x[i-1] + sizeof (int) |
| B. | x + sizeof (int) * i |
| C. | x+i |
| D. | none of these |
| Answer» B. x + sizeof (int) * i | |
| 16. |
Below is an example of - int RollNum[30][4]; |
| A. | 3-D Array |
| B. | 2-D Array |
| C. | 1-D Array |
| D. | 4-D Array |
| Answer» C. 1-D Array | |
| 17. |
O(N)(linear time) is better than O(1) constant time. |
| A. | True |
| B. | False |
| Answer» C. | |
| 18. |
In C Programming, If we need to store word "INDIA" then syntax is as below - |
| A. | char name[6] = {'I','N','D','I','A',' 0'} |
| B. | char name[6] = {"I","N","D","I","A"} |
| C. | char name[]; |
| D. | D. |
| Answer» B. char name[6] = {"I","N","D","I","A"} | |
| 19. |
What is the output of the following piece of code? public class array { public static void main(String args[]) { int []arr = {1,2,3,4,5}; System.out.println(arr[2]); System.out.println(arr[4]); } } |
| A. | 3 and 5 |
| B. | 5 and 3 |
| C. | 2 and 4 |
| D. | 4 and 2 |
| Answer» B. 5 and 3 | |
| 20. |
Which of the following is a correct way to declare a multidimensional array in Java? |
| A. | int[] arr; |
| B. | int arr[[]]; |
| C. | int[][]arr; |
| D. | int[[]] arr; |
| Answer» D. int[[]] arr; | |
| 21. |
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); |
| Answer» D. int arr() = new int(3); | |
| 22. |
C does no automatic array bound checking. This is |
| A. | true |
| B. | false |
| C. | C's asset |
| D. | C's shortcoming |
| Answer» E. | |
| 23. |
If n has the value 3, then the statement a [++n] = n++ ; |
| A. | assigns 3 to a [5] |
| B. | assigns 4 to a [5] |
| C. | assigns 4 to a [4] |
| D. | what is assigned is compiler-dependent |
| Answer» E. | |
| 24. |
The following program main() { static char a[3][4] = {"abcd", "mnop", "fghi"}; putchar(**a); } |
| A. | will not compile successfully |
| B. | results in run-time error |
| C. | prints garbage |
| D. | none of the above |
| Answer» E. | |
| 25. |
Under which of the following conditions, the size of an one-dimensional array need not be specified? |
| A. | when initialization is a part of definition |
| B. | when it is a declaration |
| C. | when it is a formal parameter and an actual argument |
| D. | All of the above |
| Answer» E. | |
| 26. |
Consider the statement int val[2] [4] = { 1, 2, 3, 4, 5, 6, 7, 8} ; 4 will be the value of |
| A. | val[0 ][ 3] |
| B. | val[0][4] |
| C. | val[1][1] |
| D. | none of the above |
| Answer» B. val[0][4] | |
| 27. |
The following program main( ) { static int a[ ] = { 7, 8, 9 } ; printf( "%d", 2[ a ] + a[ 2 ] ) ; } |
| A. | results in bus error |
| B. | results in segmentation violation error |
| C. | will not compile successfully |
| D. | none of the above |
| Answer» E. | |
| 28. |
While passing an array as an actual argument, the function call must have the array name |
| A. | with empty brackets |
| B. | with its size |
| C. | alone |
| D. | none of the above |
| Answer» D. none of the above | |
| 29. |
The parameter passing mechanism for an array is |
| A. | call by value |
| B. | call by reference |
| C. | call by value-result |
| D. | None of the above |
| Answer» C. call by value-result | |
| 30. |
A string that is a formal parameter can be declared |
| A. | An array with empty braces |
| B. | A pointer to character |
| C. | Both A and B |
| D. | None of the above |
| Answer» D. None of the above | |
| 31. |
The information about an array used in program will be stored in |
| A. | Symbol Table |
| B. | Activation Record |
| C. | Dope Vector |
| D. | Both A and B |
| Answer» D. Both A and B | |
| 32. |
Array is an example of _______ type memory allocation |
| A. | Compile time |
| B. | Run time |
| C. | Both A and B |
| D. | None of the above |
| Answer» B. Run time | |
| 33. |
Array can be considered as set of elements stored in consecutive memory locations but having __________. |
| A. | Same data type |
| B. | Different data type |
| C. | Same scope |
| D. | None of these |
| Answer» B. Different data type | |
| 34. |
Which of the following correctly declares an array? |
| A. | int geeks[20]; |
| B. | int geeks; |
| C. | geeks{20}; |
| D. | array geeks[20]; |
| Answer» B. int geeks; | |
| 35. |
A three dimensional array in C is declared as int A[x][y][z]. Consider that array elements are stored in row major order and indexing begins from 0. Here, the address of an item at the location A[p][q][r] can be computed as follows |
| A. | &A[0][0][0] + w(y * z * q + z * p + r) |
| B. | &A[0][0][0] + w(y * z * p + z*q + r) |
| C. | &A[0][0][0] + w(x * y * p + z * q+ r) |
| D. | &A[0][0][0] + w(x * y * q + z * p + r) |
| Answer» C. &A[0][0][0] + w(x * y * p + z * q+ r) | |
| 36. |
Let A[1...n] be an array of n distinct numbers. If i < j> A[j], then the pair (i, j) is called an inversion of A. What is the expected number of inversions in any permutation on n elements ? |
| A. | n(n-1)/2 |
| B. | n(n-1)/4 |
| C. | n(n+1)/4 |
| D. | 2n[logn] |
| Answer» C. n(n+1)/4 | |
| 37. |
Which of the following statements are correct about 6 used in the program? int num[6]; num[6]=21; |
| A. | In the first statement 6 specifies a particular element, whereas in the second statement it specifies a type. |
| B. | In the first statement 6 specifies a array size, whereas in the second statement it specifies a particular element of array. |
| C. | In the first statement 6 specifies a particular element, whereas in the second statement it specifies a array size. |
| D. | In both the statement 6 specifies array size. |
| Answer» C. In the first statement 6 specifies a particular element, whereas in the second statement it specifies a array size. | |
| 38. |
Which of the following statements are correct about an array? 1. The array int num[26]; can store 26 elements. 2. The expression num[1] designates the very first element in the array. 3. It is necessary to initialize the array at the time of declaration. 4. The declaration num[SIZE] is allowed if SIZE is a macro. |
| A. | 1 |
| B. | 1,4 |
| C. | 2,3 |
| D. | 2,4 |
| Answer» C. 2,3 | |
| 39. |
What will be the output of the program if the array begins at address 65486? #include int main() { int arr[] = {12, 14, 15, 23, 45}; printf("%u, %u n", arr, &arr); return 0; } |
| A. | 65486, 65488 |
| B. | 65486, 65486 |
| C. | 65486, 65490 |
| D. | 65486, 65487 |
| Answer» C. 65486, 65490 | |
| 40. |
Which of the following statements are correct about the program below? #include int main() { int size, i; scanf("%d", &size); int arr[size]; for(i=1; i<=size; i++) { scanf("%d", arr[i]); printf("%d", arr[i]); } return 0; } |
| A. | The code is erroneous since the subscript for array used in for loop is in the range 1 to size. |
| B. | The code is erroneous since the values of array are getting scanned through the loop. |
| C. | The code is erroneous since the statement declaring array is invalid |
| D. | The code is correct and runs successfully. |
| Answer» D. The code is correct and runs successfully. | |
| 41. |
What will be the output of the program if the array begins at 65472 and each integer occupies 2 bytes? #include int main() { int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 1, 7, 8, 9, 0}; printf("%u, %u n", a+1, &a+1); return 0; } |
| A. | 65474, 65476 |
| B. | 65480, 65496 |
| C. | 65480, 65488 |
| D. | 65474, 65488 |
| Answer» C. 65480, 65488 | |
| 42. |
What will be the output of the program ? #include int main() { int arr[1]={10}; printf("%d n", 0[arr]); return 0; } |
| A. | 1 |
| B. | 10 |
| C. | 6 |
| Answer» C. 6 | |
| 43. |
Are the expressions arr and &arr same for an array of 10 integers? |
| A. | Yes |
| B. | No |
| Answer» C. | |
| 44. |
Predict the output of below code: #include int main() { int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 1, 7, 8, 9, 0}; printf("%u, %u n", a+1, &a+1); return 0; } |
| A. | 65430, 43569 |
| B. | 65239, 64763 |
| C. | 65480, 65496 |
| D. | 61123, 74123 |
| Answer» D. 61123, 74123 | |
| 45. |
Predict the output of below code: #include int main() { int a[5] = {5, 1, 15, 20, 25}; int i, j, m; i = ++a[1]; j = a[1]++; m = a[i++]; printf("%d, %d, %d", i, j, m); return 0; } |
| A. | 2,5,15 |
| B. | 3, 2, 15 |
| C. | 1,2,5 |
| D. | 12,15,1 |
| Answer» C. 1,2,5 | |
| 46. |
If n has the value 3, then the statement |
| A. | assigns 4 to a [4] |
| B. | what is assigned is compiler-dependent |
| C. | assigns 4 to a [5] |
| D. | assigns 4 to a [6] |
| Answer» C. assigns 4 to a [5] | |
| 47. |
applications of a multidimensional array |
| A. | Matrix-Multiplication |
| B. | Minimum Spanning Tree |
| C. | Finding connectivity between nodes |
| D. | All the above |
| Answer» E. | |
| 48. |
What is Array? |
| A. | Collection of different type of elements |
| B. | Collection of similar type of elements |
| C. | None of the above |
| D. | Both A and C |
| Answer» C. None of the above | |
| 49. |
C does no automatic array bound checking. This is |
| A. | True |
| B. | False |
| C. | C's asset |
| D. | C's shortcoming |
| Answer» E. | |
| 50. |
Predict the output of below code: #include int main() { int ary[2][3][4], j = 20; ary[0][0] = &j; printf("%d n", *ary[0][0]); } |
| A. | Junk Value |
| B. | No output |
| C. | Compile time Error |
| D. | Address of j |
| Answer» D. Address of j | |