A directory of Objective Type Questions covering all the Computer Science subjects. Here you can access and discuss Multiple choice questions and answers for various compitative exams and interviews.

81. 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);
View Answer Report Discuss Too Difficult!
Answer: (c).int arr[3] = {1,2,3};

82. 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);
View Answer Report Discuss Too Difficult!
Answer: (c).int arr[] = new int[3];

83. 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. All of the mentioned
View Answer Report Discuss Too Difficult!
Answer: (d).All of the mentioned

84. 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
View Answer Report Discuss Too Difficult!
Answer: (a).3 and 5

85. 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
View Answer Report Discuss Too Difficult!
Answer: (c).ArrayIndexOutOfBoundsException

86. When does the ArrayIndexOutOfBoundsException occur?
a. Compile-time
b. Run-time
c. Not an error
d. None of the mentioned
View Answer Report Discuss Too Difficult!
Answer: (b).Run-time

87. Which of the following concepts make extensive use of arrays?
a. Binary trees
b. Scheduling of processes
c. Caching
d. Spatial locality
View Answer Report Discuss Too Difficult!
Answer: (d).Spatial locality

88. What are the advantages of arrays?
a. Easier to store elements of same data type
b. Used to implement other data structures like stack and queue
c. Convenient way to represent matrices as a 2D array
d. All of the mentioned
View Answer Report Discuss Too Difficult!
Answer: (d).All of the mentioned

89. What are the disadvantages of arrays?
a. We must know before hand how many elements will be there in the array
b. There are chances of wastage of memory space if elements inserted in an array are lesser than than the allocated size
c. Insertion and deletion becomes tedious
d. All of the mentioned
View Answer Report Discuss Too Difficult!
Answer: (d).All of the mentioned

90. What is a bit array?
a. Data structure for representing arrays of records
b. Data structure that compactly stores bits
c. An array in which most of the elements have the same value
d. None of the mentioned
View Answer Report Discuss Too Difficult!
Answer: (b).Data structure that compactly stores bits