0% found this document useful (0 votes)
5 views4 pages

Array

The document contains a series of multiple-choice questions and fill-in-the-blank questions related to arrays in Java programming. It covers topics such as array initialization, memory allocation, search algorithms, and sorting techniques. Each question is designed to test knowledge of Java arrays and their properties.

Uploaded by

sripanja181
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views4 pages

Array

The document contains a series of multiple-choice questions and fill-in-the-blank questions related to arrays in Java programming. It covers topics such as array initialization, memory allocation, search algorithms, and sorting techniques. Each question is designed to test knowledge of Java arrays and their properties.

Uploaded by

sripanja181
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

## Sec on A: Mul ple Choice Ques ons (15 Marks)

Each ques on carries 1 mark. Choose the most appropriate op on.

1. What is the default value of an unini alized int array element?

a) 0

b) Null

c) Garbage value

d) 1

2. Which keyword is used to allocate memory for an array in Java?

a) malloc

b) create

c) new

d) give

3. If int p[] = {2, 4, 6, 8, 10}, what is the value of p[p[1]]?

a) 4

b) 6

c) 10

d) 8

4. What is the index number of the last element in an array of size N?

a) N

b) N+1

c) N-1

d) 0
5. Which property returns the number of elements in an array?

a) length()

b) length

c) size()

d) index

6. An array is a collec on of ____ data types.

a) Heterogeneous

b) Homogeneous

c) Different

d) Dynamic

7. What will [Link]([Link]) output if int a[] = new int[5]?

a) 4

b) 0

c) 5

d) Error

8. Which error occurs if you try to access arr[5] in an array of size 5?

a) ArrayOutOfBoundsExcep on

b) ArrayIndexOutOfBoundsExcep on

c) ArrayOverloadExcep on

d) NullPointerExcep on

9. Which of these is a valid array declara on?

a) int arr = new int[5];

b) int arr[] = new int[5];

c) array arr[] = new int[5];

d) int arr[] = int[5];


10. In Linear Search, what is the maximum number of comparisons for an array of size n?

a) 1

b) n/2

c) n

d) log n

11. Which technique is used to arrange array elements in a specific order?

a) Searching

b) Sor ng

c) Indexing

d) Traversing

12. Binary Search requires the array to be:

a) Small

b) Unsorted

c) Sorted

d) Empty

13. What is the value of x[2] a er: int x[] = {1, 2, 3, 4, 5}; x[2] += x[4];?

a) 7

b) 8

c) 5

d) 3

14. Arrays in Java are stored as:

a) Objects

b) Primi ve data

c) Variables

d) Strings
15. What is the star ng index of any array?

a) 1

b) -1

c) 0

d) 10 [2, 3]

------------------------------

## Sec on B: Fill in the Blanks & Short Output (15 Marks)

Each ques on carries 1 or 2 marks as indicated.

1. The process of accessing every element of an array exactly once is called ____. (1)

2. The elements of an array are stored in ____ memory loca ons. (1)

3. Name the search algorithm that follows the "Divide and Conquer" strategy. ____ (1)

4. Write a Java statement to declare and ini alize an array marks with values 85, 90, and 75.
(2)

5. In Bubble Sort, if there are n elements, how many passes are required to sort the array?
____ (1)

6. Find the output: int a[] = {5, 10, 15}; [Link](a[1] * a[2]); ____ (2)

7. What is the output of [Link](arr[0]) if int arr[] = {16, 25, 36}? ____ (2)

8. Fill in the blank to complete the loop: for(int i = 0; i < __ ; i++) to iterate through array x. (1)

9. State whether true or false: An array size can be changed during run me in Java. ____ (1)

10. Give the output of the following code snippet: (3)

int m[] = {2, 4, 6, 8};for(int i = 0; i <= 2; i++) {

m[i] = m[i] * m[i+1];

[Link](m[1]);

You might also like