MCQ On ARRAY With Answers
MCQ On ARRAY With Answers
(a) ‘A’ (b) ‘\0’ 15. What is the size of int arr[9] assuming that int is of
4 bytes?
(c) null (d) ‘\0’ or null
(a) 9 (b) 36 24. Array A[ index] = ___( first element in an array) ?
(c) 35 (d) None of the above (a) 0 (b) -1
16. Name the process of inserting an element in the (c) 2 (d) 1
stack? 25. Identify an element in an array which a user can
(a) Insert (b) Add access.
(c) Push (d) None of the above (a) randomly (b) sequentially
17. Name the condition when the user tries to delete (c) exponentially (d) logarithmically
the element from the empty stack ? 26. How can we define an array in java?
(a) Underflow (a) objects
(b) Garbage collection (b) object references
(c) Overflow (c) primitive data type
(d) None of the above (d) none of above
18. Name the condition where the size of the stack is 27. When we pass an array to a method, a method
10 and we try to add the 11th element in the stack. receives ____
(a) Underflow (a) A copy of the array
(b) Garbage collection (b) a copy of the forst element
(c) Overflow (c) the reference of the array
(d) None of the above (d) the length of the array
19. At which time the 28. Name the operators that is used to allocate
ArrayIndexOutOfBoundsException occur? memory to array variable in Java?
(a) Compile-time (a) malloc (b) alloc
(b) Run-time (c) new (d) new malloc
(c) Not an error 29. Choose the incorrect Statement
(d) Not an exception at all (a) It is necessary to use new operator to initialize
20. Which concepts make extensive use of arrays? an array
(a) Binary trees (b)
Array can be initialized using comma
(b) Scheduling of processes separated expressions surrounded by curly
(c) Caching braces
(d) Spatial locality (c)
Array can be initialized when they are
declared
21. Choose the best reason to use arrays.
(d) None of the mentioned
(a) Objects of mixed data types can be stored
30. What is needed to specify time of array
(b) Elements in an array cannot be sorted
initialization?
(c) Index of first element of an array is 1
(a) Row
(d) Easier to store elements of same data type
(b) Column
22. Why we should avoid using arrays?
(c) Both Row and Column
(a) Data structure like queue or stack cannot be
(d) None of the mentioned
implemented
(b) There are chances of wastage of memory space
Fill in the blanks
if elements inserted in an array are lesser than
the allocated size 31. Array is a collection of elements of ___ data type.
(c) Index value of an array can be negative (a) Same
(d) Elements are sequentially accessed (b) Different
23. If int is of 4bytes, what is the size of int arr[15];? 32. JVM implements arrays as ___ type.
(a) 15 (b) 19 (a) Primitive
(c) 11 (d) 60 (b) Object
33. Java-Arrays have ___. 3. default value of an (iii) 0
(a) Names element of Object
(b) Values type array
(c) Methods and Fields 4. default value of (iv) null
(d) None byte, short, int or
long data type
34. Array declaration without initialization ___
(a) 1-(ii), 2-(i), 3-(iv), 4-(iii)
memory.
(b) 1-(i), 2-(ii), 3-(iv), 4-(iii)
(a) Does not allocate
(c) 1-(ii), 2-(i), 3-(iii), 4-(iv)
(b) Allocates memory
(d) 1-(ii), 2-(iv), 3-(i), 4-(iii)
35. An array index starts with ___.
42. Match the columns:
(a) –1 (b) 0
Group A Group B
(c) 1 (d) Any integer
1. default value of a (i) stores the
36. Name of an array variable can start with ___.
char data type elements of
(a) A letter similar types
(b) Underscore ( _ ) 2. array (ii) ‘\0’ or null
(c) Dollar Symbol ($) 3. declaring an array (iii) int arr[2] = {10, 20}
(d) All 4. initialize an array (iv) int javatpoint[10];
37. Array of arrays is called ___ array. (a) 1-(ii), 2-(i), 3-(iv), 4-(iii)
(a) Bidirectional (b) 1-(i), 2-(ii), 3-(iv), 4-(iii)
(b) Combo (c) 1-(ii), 2-(i), 3-(iii), 4-(iv)
(c) Multidimensional (d) 1-(ii), 2-(iv), 3-(i), 4-(iii)
(d) Multi-value 43. Match the columns:
38. Array of dimension N contains __ number of Group A Group B
subscripts or brackets? 1. Advantage of the (i) Spatial locality
(a) N-1 (b) N array
(c) N+1 (d) 10*N 2. Highly uses the (ii) Easier to access
concept of an the elements
39. Row number and Column number in
array
Multidimensional array starts with ___ digit.
3. Disadvantage of (iii) 36
(a) -1 (b) 0
the array
(c) 1 (d) 2 4. Size of int arr[9] (iv) Wastage of
40. 4-dimensional array is an example of ___ memory
dimensional arrays. (a) 1-(ii), 2-(i), 3-(iv), 4-(iii)
(a) 4 (b) 3 (b) 1-(i), 2-(ii), 3-(iv), 4-(iii)
(c) 2 (d) 1 (c) 1-(ii), 2-(i), 3-(iii), 4-(iv)
(d) 1-(ii), 2-(iv), 3-(i), 4-(iii)
Match the following
44. Match the columns:
41. Match the columns: Group A Group B
Group A Group B 1. inserting an (i) Underflow
1. special symbols (i) Braces { } element in the
used to declare an stack
array 2. delete the element (ii) Push
2. to initialize an (ii) Square Brackets from the empty
array [] stack
3. size of the stack (iii) run time 48. Choose the correct output of Java code snippet
is 10 and we try int[] balls = {};
to add the 11th System.out.print(balls.length);
element in the (a) 0 (b) -1
stack (c) 1 (d) Compiler error
4. Array Index (iv) Overflow 49. Choose the correct output of Java program with
Out of Bounds arrays
Exception occur at
String[] colors = {“RED”;”YELLOW”;”WHITE”};
(a) 1-(ii), 2-(i), 3-(iv), 4-(iii)
System.out.print(colors[2]);
(b) 1-(i), 2-(ii), 3-(iv), 4-(iii)
(a) RED
(c) 1-(ii), 2-(i), 3-(iii), 4-(iv)
(b) YELLOW
(d) 1-(ii), 2-(iv), 3-(i), 4-(iii)
(c) WHITE
45. Match the columns:
(d) Compiler error
Group A Group B
50. Choose the correct output of Java program with
1. extensive use of (i) Easier to store arrays
arrays elements
public class Polo {
2. Advantages of (ii) Spatial locality
public static void main(String args[])
arrays
{
3. Disadvantages of (iii) 0
arrays String[] computer = {“RAM”,”HDD”,”MOUSE”};
4. Index of the first (iv) chances of String[] parts = {computer[0],computer[2]};
element in an wastage of System.out.print(parts[1]);
array memory space }
(a) 1-(ii), 2-(i), 3-(iv), 4-(iii) }
(b) 1-(i), 2-(ii), 3-(iv), 4-(iii) (a) RAM (b) HDD
(c) 1-(ii), 2-(i), 3-(iii), 4-(iv) (c) MOUSE (d) Compiler error
(d) 1-(ii), 2-(iv), 3-(i), 4-(iii) 51. Choose the correct output of Java program
int ages[3] = {25, 27, 30};
Programming based questions System.out.println(ages[1]);
46. Choose the correct output for Java code snippet (a) 25 (b) 27
with arrays (c) 30 (d) Compile error
static int[] nums; 52. When index of an element is N, what will be its
public static void main(String args[]) actual position in the array
(a) N-1 (b) N
{
(c) N+1 (d) N+2
System.out.println(nums.length);
53. Choose correct output for the code?
}
#include <stdio.h>
(a) 0 int main()
(b) null {
(c) Compiler error int arr[5]={10,20,30,40,50};
(d) Runtime Exception - Null Pointer Exception system.out.print(“%d”, arr[5]);
47. Choose the correct output of the below Java return 0;
program }
int[] marks = {35,65,95}; (a) Garbage value
System.out.print(marks.length + “,” + marks[1]); (b) 10
(a) 2,65 (b) 3,95 (c) 50
(c) 3,65 (d) Compiler error (d) None of the above
54. With reference to the program code given below, fact=fact*i;
answer the questions that follow: }
public class Prime System.out.println(“Factorial of “+number+” is:
{ “+fact);
public static void main(String args[]) }
{ }
int i,m=0,flag=0; (a) What will be the output?
int n=3;//it is the number to be checked (i) Factorial of 5 is: 120
m=n/2; (ii) Factorial of 5 is: 121