Data Structure Questions and Answers-Array and Array Operations

 

 Help authour, Buy PDF Ebook   >>>Click Here<<<

Data Structure Questions and Answers-Array and Array Operations

Question 1
Which of these best describes an array?
A
A data structure that shows a hierarchical behavior
B
Container of objects of similar types
C
Container of objects of mixed types
D
All of the mentioned
Arab culture Questions answers
Question 1 Explanation: 
Array contains elements only of the same type.
Question 2
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);
ICT Questions answers
Question 2 Explanation: 
This is the syntax to initialize an array in C.
Question 3
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);
UPSC GS Questions answers
Question 3 Explanation: 
Note that option b is declaration whereas option c is to instantiate an array.

Question 4
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
Library science Questions answers
Question 4 Explanation: 
All the options are syntactically correct.

Question 5
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
Aptitude test Questions answers
Question 5 Explanation: 
Array indexing starts from 0.
There are 5 questions to complete.

 

 Help authour, Buy PDF Ebook   >>>Click Here<<<