wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Class 10 Arrays

Total questions: 50

Worksheet time: 25mins

Name
Class
Date
1.

Which keyword is used to declare an array?

a)

arr

b)

array

c)

new

d)

list

2.

What is the index of first element in an array?

a)

0

b)

1

c)

-1

d)

Depends on type

3.

What is size of int[] a = new int[5]?

a)

4

b)

5

c)

6

d)

Undefined

4.

Which is valid declaration?

a)

int a[] = new int[10];

b)

int[10] a;

c)

array a = new int[10];

d)

int new a[10];

5.

What is default value of int array elements?

a)

0

b)

null

c)

undefined

d)

garbage

6.

What is default value of boolean array elements?

a)

false

b)

true

c)

null

d)

0

7.

What is length of array a declared as int[] a = new int[7];?

a)

6

b)

7

c)

8

d)

Error

8.

How to access third element of array a?

a)

a[2]

b)

a(3)

c)

a{2}

d)

a<3>

9.

What happens if array index out of bounds?

a)

0 returned

b)

null returned

c)

ArrayIndexOutOfBoundsException

d)

Compile error

10.

Which property gives number of elements in array?

a)

size

b)

length

c)

count

d)

capacity

11.

Which loop is best for traversing arrays?

a)

for

b)

while

c)

do-while

d)

all

12.

Which search technique is faster for sorted arrays?

a)

Linear search

b)

Binary search

c)

Hashing

d)

Jump search

13.

Which sorting algorithm repeatedly swaps adjacent elements?

a)

Selection sort

b)

Bubble sort

c)

Insertion sort

d)

Quick sort

14.

Which sort places smallest element in front each pass?

a)

Bubble

b)

Selection

c)

Insertion

d)

Merge

15.

What is time complexity of linear search?

a)

O(1)

b)

O(log n)

c)

O(n)

d)

O(n^2)

16.

What is time complexity of binary search?

a)

O(1)

b)

O(log n)

c)

O(n)

d)

O(n^2)

17.

Array is a collection of:

a)

Similar data types

b)

Different data types

c)

Objects only

d)

Primitives only

18.

What is true about arrays?

a)

Fixed size

b)

Dynamic size

c)

Resizable

d)

All

19.

What is output of int[] a=new int[3]; System.out.print(a[0]);?

a)

0

b)

null

c)

Error

d)

Garbage

20.

Which is valid initialization?

a)

int[] a = {1,2,3};

b)

int a = {1,2,3};

c)

array a = [1,2,3];

d)

int[] a = new {1,2,3};

21.

Which error occurs if negative size array declared?

a)

NegativeArraySizeException

b)

NullPointerException

c)

IndexOutOfBoundsException

d)

Error

22.

How many elements in int[] a=new int[0];?

a)

0

b)

1

c)

Error

d)

Null

23.

Which statement about array is true?

a)

Array length can be changed

b)

Array length fixed after creation

c)

Array is dynamic

d)

Array grows automatically

24.

How to get last element of array a?

a)

a[length-1]

b)

a[size]

c)

a[-1]

d)

a[length]

25.

Which type of array is supported in ICSE syllabus?

a)

1D

b)

2D

c)

Jagged

d)

All

26.

Output? int[] a={1,2,3}; System.out.println(a[1]);

a)

1

b)

2

c)

3

d)

Error

27.

Output? int[] a=new int[4]; System.out.println(a.length);

a)

3

b)

4

c)

0

d)

Error

28.

Output? int[] a={10,20,30}; for(int i=0;i

a)

10 20 30

b)

20 30 40

c)

0 0 0

d)

Error

29.

Output? int[] a=new int[3]; a[0]=5; System.out.println(a[0]);

a)

0

b)

5

c)

null

d)

Error

30.

Output? int[] a={1,2,3}; System.out.println(a[a.length-1]);

a)

1

b)

2

c)

3

d)

Error

31.

Output? int[] a=new int[2]; a[0]=1; a[1]=a[0]+2; System.out.println(a[1]);

a)

1

b)

2

c)

3

d)

Error

32.

Output? int[] a={5,10,15}; int sum=0; for(int x:a) sum+=x; System.out.println(sum);

a)

15

b)

25

c)

30

d)

Error

33.

Output? int[] a={2,4,6}; System.out.println(a[3]);

a)

6

b)

0

c)

Error

d)

Exception

34.

Output? int[] a=new int[5]; System.out.println(a);

a)

address/hashcode

b)

0

c)

null

d)

Error

35.

Output? int[] a={1,2,3}; System.out.println(a==a);

a)

true

b)

false

c)

Error

d)

null

36.

Assertion (A): Array index starts from 0. Reason (R): Because offset of first element is zero.

a)

A

b)

B

c)

C

d)

D

37.

Assertion (A): Array size can be changed at runtime. Reason (R): Arrays in Java are dynamic.

a)

A

b)

B

c)

C

d)

D

38.

Assertion (A): Array elements are stored in contiguous memory. Reason (R): This allows direct access using index.

a)

A

b)

B

c)

C

d)

D

39.

Assertion (A): Length is a property of array. Reason (R): Because arrays are objects in Java.

a)

A

b)

B

c)

C

d)

D

40.

Assertion (A): new keyword allocates memory for array. Reason (R): Array is object in heap.

a)

A

b)

B

c)

C

d)

D

41.

Assertion (A): Binary search can be applied on unsorted array. Reason (R): Binary search works only if array is sorted.

a)

A

b)

B

c)

C

d)

D

42.

Assertion (A): for-each loop can modify array elements. Reason (R): for-each provides reference to elements.

a)

A

b)

B

c)

C

d)

D

43.

Assertion (A): Negative index is allowed in Java arrays. Reason (R): Because index can be positive or negative.

a)

A

b)

B

c)

C

d)

D

44.

Assertion (A): ArrayIndexOutOfBoundsException occurs at runtime. Reason (R): Compiler does not check index.

a)

A

b)

B

c)

C

d)

D

45.

Assertion (A): Arrays are objects. Reason (R): They have properties and methods.

a)

A

b)

B

c)

C

d)

D

46.

Which is best for searching in sorted array?

a)

Linear search

b)

Binary search

c)

Bubble sort

d)

Selection sort

47.

If an array is partially filled, how to track number of valid elements?

a)

Using length property

b)

Using counter variable

c)

Using null check

d)

Impossible

48.

Which is more efficient for checking duplicates in small array?

a)

Nested loops

b)

HashSet

c)

Binary search

d)

Sorting

49.

What happens if we assign one array to another?

a)

Copy elements

b)

Copy reference

c)

Error

d)

New array created

50.

To reverse an array efficiently, which technique?

a)

Swap from ends

b)

Nested loops

c)

Sorting

d)

Rotate