Data Structure MCQ (Multiple Choice Questions) - Jobee Planet Latest Jobs

Post Top Ad

Your Ad Spot

Recent Jobs

Data Structure MCQ (Multiple Choice Questions)

Data Structure Questions and Answers – Array and Array Operations

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on “Array and Array Operations”.


1. Which of these best describes an array?




... Answer is B)
Explanation: Array contains elements only of the same type.



2. How do you initialize an array in C?




... Answer is C)
Explanation: This is the syntax to initialize an array in C.



3. How do you instantiate an array in Java?




... Answer is C)
Explanation: Note that int arr[]; is declaration whereas int arr[] = new int[3]; is to instantiate an array.



4. Which of the following is the correct way to declare a multidimensional array in Java?




... Answer is C)
Explanation: The syntax to declare multidimensional array in java is either int[][] arr; or int arr[][];



5. What is the output of the following Java 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 is A)
Explanation: Array indexing starts from 0.


No comments:

Post a Comment

Post Top Ad

Your Ad Spot