wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Quiz on Array

Total questions: 10

Worksheet time: 3mins

Name
Class
Date
1.

An array index starts with?

a)

-1

b)

0

c)

1

d)

2

2.

What is the output of C Program.?

int main() {

int a[];

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

printf("%d", a[0]); }

a)

1

b)

2

c)

4

d)

Compiler Error

3.

What is right way to Initialize array?

a)

int num[6] = { 2, 4, 12, 5, 45, 5 };

b)

int n{} = { 2, 4, 12, 5, 45, 5 };

c)

int n{6} = { 2, 4, 12 };

d)

int n(6) = { 2, 4, 12, 5, 45, 5 };

4.

An array elements are always stored in ________ memory locations.

a)

Sequential

b)

Random

c)

Sequential and Random

d)

None of the above

5.

What is the maximum number of dimensions an array in C may have?

a)

2

b)

8

c)

20

d)

50

e)

Theoratically no limit. The only practical limits are memory size and compilers.

6.

What will be printed after execution of the following code?

void main()

{

int arr[10] = {1,2,3,4,5};

printf("%d", arr[5]);

}

a)

Garbage Value

b)

5

c)

6

d)

0

e)

None of These

7.

Array is an example of _______ type memory allocation.

a)

Compile time

b)

Run time

8.

The parameter passing mechanism for an array is

a)

call by value

b)

call by reference

c)

call by value-result

d)

None of the above

9.

When does the ArrayIndexOutOfBoundsException occur?

a)

Compile-time

b)

Run-time

c)

Not an error

d)

Not an exception at all

10.

Which of these best describes an array?

a)

A data structure that shows a hierarchical behavior

b)

Container of objects of similar types

c)

Arrays are immutable once initialized

d)

Array is not a data structure