MCQOPTIONS
Saved Bookmarks
This section includes 93 Mcqs, each offering curated multiple-choice questions to sharpen your C Programming knowledge and support exam preparation. Choose a topic below to get started.
| 51. |
What is the default value of byte, short, int or long data type elements of an array in Java? |
| A. | -1 |
| B. | 1 |
| C. | 0 |
| D. | Garbage value |
| Answer» D. Garbage value | |
| 52. |
What is the default value of an element of Object type array? |
| A. | 0 |
| B. | null |
| C. | -1 |
| D. | Garbage value |
| Answer» C. -1 | |
| 53. |
Lazy initialization of array requires the keyword "new" to allocate memory to the array and its elements. State TRUE or FALSE. |
| A. | FALSE |
| B. | TRUE |
| C. | - |
| D. | - |
| Answer» C. - | |
| 54. |
Shorthand array initialization in Java needs the keyword "new" to allocate memory to the array and elements. State TRUE or FALSE. |
| A. | FALSE |
| B. | TRUE |
| C. | - |
| D. | - |
| Answer» B. TRUE | |
| 55. |
The name of an array variable or identifier can start with ___. |
| A. | A letter |
| B. | Underscore ( _ ) |
| C. | Dollar Symbol ($) |
| D. | All |
| Answer» E. | |
| 56. |
An array in Java can be declared only of some predefined types. (TRUE/FALSE) |
| A. | FALSE |
| B. | TRUE |
| C. | - |
| D. | - |
| Answer» B. TRUE | |
| 57. |
If an index of an element is N, what is its actual position in the array? |
| A. | N-1 |
| B. | N |
| C. | N+1 |
| D. | N+2 |
| Answer» D. N+2 | |
| 58. |
We should not specify the array size if declaration and initialization are done at the same time. (TRUE / FALSE) |
| A. | FALSE |
| B. | TRUE |
| C. | - |
| D. | - |
| Answer» C. - | |
| 59. |
What is the output of the below Java program with arrays? |
| A. | RED |
| B. | YELLOW |
| C. | WHITE |
| D. | Compiler error |
| Answer» E. | |
| 60. |
Which is the correct way of knowing Array Size in Java? |
| A. | //int[] ary; |
| B. | //int[] ary; |
| C. | //int[] ary; |
| D. | //int[] ary; |
| Answer» C. //int[] ary; | |
| 61. |
What is the output of the below Java code snippet? |
| A. | 0 |
| B. | -1 |
| C. | 1 |
| D. | Compiler error |
| Answer» B. -1 | |
| 62. |
What is the output of the below Java program? |
| A. | 2,65 |
| B. | 3,95 |
| C. | 3,65 |
| D. | Compiler error |
| Answer» D. Compiler error | |
| 63. |
What is the output of the below Java code snippet with arrays? |
| A. | 0 |
| B. | null |
| C. | Compiler error |
| D. | Runtime Exception - Null Pointer Exception |
| Answer» E. | |
| 64. |
In Java, an array can be declared without initialization without mentioning the size. (TRUE / FALSE) |
| A. | TRUE |
| B. | FALSE |
| C. | - |
| D. | - |
| Answer» B. FALSE | |
| 65. |
It is possible to skip initializing some elements of the array during Shorthand Initialization. (TRUE / FALSE) |
| A. | FALSE |
| B. | TRUE |
| C. | - |
| D. | - |
| Answer» B. TRUE | |
| 66. |
Which are the special symbols used to initialize an array at the time of the declaration itself? |
| A. | Parentheses ( ) |
| B. | Square Brackets [ ] |
| C. | Braces { } |
| D. | Angled Brackets < > |
| Answer» D. Angled Brackets < > | |
| 67. |
Which are the special symbols used to declare an array in Java? |
| A. | Braces { } |
| B. | Parentheses () |
| C. | Square Brackets [ ] |
| D. | Angled Brackets < > |
| Answer» D. Angled Brackets < > | |
| 68. |
In Java language, an array index starts with ___. |
| A. | -1 |
| B. | 0 |
| C. | 1 |
| D. | Any integer |
| Answer» C. 1 | |
| 69. |
An array declaration in Java without initialization ___ memory. |
| A. | Does not allocate |
| B. | Allocates memory |
| C. | - |
| D. | - |
| Answer» B. Allocates memory | |
| 70. |
Unlike C-Arrays, the Java-Arrays have ___. |
| A. | Names |
| B. | Values |
| C. | Methods and Fields |
| D. | None |
| Answer» D. None | |
| 71. |
The Java Virtual Machine (JVM) implements arrays as ___ type. |
| A. | Primitive |
| B. | Object |
| C. | - |
| D. | - |
| Answer» C. - | |
| 72. |
An Array in Java is a collection of elements of ___ data type. |
| A. | Same |
| B. | Different |
| C. | - |
| D. | - |
| Answer» B. Different | |
| 73. |
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. | 0 |
| D. | 6 |
| Answer» C. 0 | |
| 74. |
What will be the output of the program ? #include int main() { float arr[] = {12.4, 2.3, 4.5, 6.7}; printf("%d\n", sizeof(arr)/sizeof(arr[0])); return 0; } |
| A. | 5 |
| B. | 4 |
| C. | 6 |
| D. | 7 |
| Answer» C. 6 | |
| 75. |
What will be the output of the program in Turb C (under DOS)? #include int main() { int arr[5], i=0; while(i |
| A. | 1, 2, 3, 4, 5, |
| B. | Garbage value, 1, 2, 3, 4, |
| C. | 0, 1, 2, 3, 4, |
| D. | 2, 3, 4, 5, 6, |
| Answer» C. 0, 1, 2, 3, 4, | |
| 76. |
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 | |
| 77. |
What will be the output of the program ? #include int main() { static int arr[] = {0, 1, 2, 3, 4}; int *p[] = {arr, arr+1, arr+2, arr+3, arr+4}; int **ptr=p; ptr++; printf("%d, %d, %d\n", ptr-p, *ptr-arr, **ptr); *ptr++; printf("%d, %d, %d\n", ptr-p, *ptr-arr, **ptr); *++ptr; printf("%d, %d, %d\n", ptr-p, *ptr-arr, **ptr); ++*ptr; printf("%d, %d, %d\n", ptr-p, *ptr-arr, **ptr); return 0; } |
| A. | 0, 0, 01, 1, 12, 2, 23, 3, 3 |
| B. | 1, 1, 22, 2, 33, 3, 44, 4, 1 |
| C. | 1, 1, 12, 2, 23, 3, 33, 4, 4 |
| D. | 0, 1, 21, 2, 32, 3, 43, 4, 5 |
| Answer» D. 0, 1, 21, 2, 32, 3, 43, 4, 5 | |
| 78. |
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 | |
| 79. |
What will be the output of the program ? #include int main() { static int a[2][2] = {1, 2, 3, 4}; int i, j; static int *p[] = {(int*)a, (int*)a+1, (int*)a+2}; for(i=0; i |
| A. | 1, 1, 1, 12, 3, 2, 33, 2, 3, 24, 4, 4, 4 |
| B. | 1, 2, 1, 22, 3, 2, 33, 4, 3, 44, 2, 4, 2 |
| C. | 1, 1, 1, 12, 2, 2, 22, 2, 2, 23, 3, 3, 3 |
| D. | 1, 2, 3, 42, 3, 4, 13, 4, 1, 24, 1, 2, 3 |
| Answer» D. 1, 2, 3, 42, 3, 4, 13, 4, 1, 24, 1, 2, 3 | |
| 80. |
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. | |
| 81. |
Does this mentioning array name gives the base address in all the contexts? |
| A. | Yes |
| B. | No |
| Answer» C. | |
| 82. |
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 |
| 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. | |
| 83. |
What will be the output of the program if the array begins 1200 in memory? #include int main() { int arr[]={2, 3, 4, 1, 6}; printf("%u, %u, %u\n", arr, &arr[0], &arr); return 0; } |
| A. | 1200, 1202, 1204 |
| B. | 1200, 1200, 1200 |
| C. | 1200, 1204, 1208 |
| D. | 1200, 1202, 1200 |
| Answer» C. 1200, 1204, 1208 | |
| 84. |
Is there any difference int the following declarations? int fun(int arr[]);int fun(int arr[2]); |
| A. | Yes |
| B. | No |
| Answer» C. | |
| 85. |
Which of the following statements mentioning the name of the array begins DOES NOT yield the base address? 1: When array name is used with the sizeof operator. 2: When array name is operand of the & operator. 3: When array name is passed to scanf() function. 4: When array name is passed to printf() function. |
| A. | A |
| B. | A, B |
| C. | B |
| D. | B, D |
| Answer» C. B | |
| 86. |
Are the expressions arr and &arr same for an array of 10 integers? |
| A. | Yes |
| B. | No |
| Answer» C. | |
| 87. |
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 | |
| 88. |
What will be the output of the program ? #include int main() { void fun(int, int[]); int arr[] = {1, 2, 3, 4}; int i; fun(4, arr); for(i=0; i |
| A. | 2, 3, 4, 5 |
| B. | 1, 2, 3, 4 |
| C. | 0, 1, 2, 3 |
| D. | 3, 2, 1 0 |
| Answer» C. 0, 1, 2, 3 | |
| 89. |
What will be the output of the program ? #include void fun(int **p); int main() { int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 8, 7, 8, 9, 0}; int *ptr; ptr = &a[0][0]; fun(&ptr); return 0; } void fun(int **p) { printf("%d\n", **p); } |
| A. | 1 |
| B. | 2 |
| C. | 3 |
| D. | 4 |
| Answer» B. 2 | |
| 90. |
Which of the following is correct way to define the function fun() in the below program? #include int main() { int a[3][4]; fun(a); return 0; } |
| A. | void fun(int p[][4]) { } |
| B. | void fun(int *p[4]) { } |
| C. | void fun(int *p[][4]) { } |
| D. | void fun(int *p[3][4]) { } |
| Answer» B. void fun(int *p[4]) { } | |
| 91. |
A pointer to a block of memory is effectively same as an array |
| A. | 1 |
| B. | |
| C. | Yes |
| D. | No |
| Answer» B. | |
| 92. |
What does the following declaration mean? int (*ptr)[10]; |
| A. | ptr is array of pointers to 10 integers |
| B. | ptr is a pointer to an array of 10 integers |
| C. | ptr is an array of 10 integers |
| D. | ptr is an pointer to array |
| Answer» C. ptr is an array of 10 integers | |
| 93. |
What will be the output of the program ? #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, 1, 15 |
| B. | 1, 2, 5 |
| C. | 3, 2, 15 |
| D. | 2, 3, 20 |
| Answer» D. 2, 3, 20 | |