1.
What are the disadvantages of arrays?
Answer: Option 'D'
All of the mentioned
Arrays are of fixed size, hence during the compile time we should know its size and type, since arrays are stored in contigous locations, insertion and deletion becomes time consuming.
2.
Which of the following is a correct way to declare a multidimensional array in Java?
Answer: Option 'D'
All the options are syntactically correct.
3.
How do you initialize an array in C?
Answer: Option 'C'
This is the syntax to initialize an array in C.
4.
Which of the following concepts make extensive use of arrays?
Answer: Option 'C'
Whenever a particular memory location is referred, it is likely that the locations nearby are also referred, arrays are stored as contigous blocks in memory, so if you want to access array elements, spatial locality makes it to access quickly.
5.
Which of these best describes an array?
Answer: Option 'B'
Container of objects of similar types
Array contains elements only of the same type.
6.
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]); } }
Answer: Option 'C'
Trying to access an element beyond the limits of an array gives ArrayIndexOutOfBoundsException.
7.
How do you instantiate an array in Java?
Answer: Option 'B'
Note that option b is declaration whereas option c is to instantiate an array.
8.
What are the advantages of arrays?
Answer: Option 'D'
Arrays are simple to implement when it comes to matrices of fixed size and type, or to implement other data structures.
9.
When does the ArrayIndexOutOfBoundsException occur?
Answer: Option 'B'
ArrayIndexOutOfBoundsException is a run-time exception and the compilation is error-free.
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[2]); System.out.println(arr[4]); } }
Answer: Option 'A'
Array indexing starts from 0.