NEW
Font size
WorksheetsClass 10 Arrays
Total questions: 50
Worksheet time: 25mins
Which keyword is used to declare an array?
arr
array
new
list
What is the index of first element in an array?
0
1
-1
Depends on type
What is size of int[] a = new int[5]?
4
5
6
Undefined
Which is valid declaration?
int a[] = new int[10];
int[10] a;
array a = new int[10];
int new a[10];
What is default value of int array elements?
0
null
undefined
garbage
What is default value of boolean array elements?
false
true
null
0
What is length of array a declared as int[] a = new int[7];?
6
7
8
Error
How to access third element of array a?
a[2]
a(3)
a{2}
a<3>
What happens if array index out of bounds?
0 returned
null returned
ArrayIndexOutOfBoundsException
Compile error
Which property gives number of elements in array?
size
length
count
capacity
Which loop is best for traversing arrays?
for
while
do-while
all
Which search technique is faster for sorted arrays?
Linear search
Binary search
Hashing
Jump search
Which sorting algorithm repeatedly swaps adjacent elements?
Selection sort
Bubble sort
Insertion sort
Quick sort
Which sort places smallest element in front each pass?
Bubble
Selection
Insertion
Merge
What is time complexity of linear search?
O(1)
O(log n)
O(n)
O(n^2)
What is time complexity of binary search?
O(1)
O(log n)
O(n)
O(n^2)
Array is a collection of:
Similar data types
Different data types
Objects only
Primitives only
What is true about arrays?
Fixed size
Dynamic size
Resizable
All
What is output of int[] a=new int[3]; System.out.print(a[0]);?
0
null
Error
Garbage
Which is valid initialization?
int[] a = {1,2,3};
int a = {1,2,3};
array a = [1,2,3];
int[] a = new {1,2,3};
Which error occurs if negative size array declared?
NegativeArraySizeException
NullPointerException
IndexOutOfBoundsException
Error
How many elements in int[] a=new int[0];?
0
1
Error
Null
Which statement about array is true?
Array length can be changed
Array length fixed after creation
Array is dynamic
Array grows automatically
How to get last element of array a?
a[length-1]
a[size]
a[-1]
a[length]
Which type of array is supported in ICSE syllabus?
1D
2D
Jagged
All
Output? int[] a={1,2,3}; System.out.println(a[1]);
1
2
3
Error
Output? int[] a=new int[4]; System.out.println(a.length);
3
4
0
Error
Output? int[] a={10,20,30}; for(int i=0;i
10 20 30
20 30 40
0 0 0
Error
Output? int[] a=new int[3]; a[0]=5; System.out.println(a[0]);
0
5
null
Error
Output? int[] a={1,2,3}; System.out.println(a[a.length-1]);
1
2
3
Error
Output? int[] a=new int[2]; a[0]=1; a[1]=a[0]+2; System.out.println(a[1]);
1
2
3
Error
Output? int[] a={5,10,15}; int sum=0; for(int x:a) sum+=x; System.out.println(sum);
15
25
30
Error
Output? int[] a={2,4,6}; System.out.println(a[3]);
6
0
Error
Exception
Output? int[] a=new int[5]; System.out.println(a);
address/hashcode
0
null
Error
Output? int[] a={1,2,3}; System.out.println(a==a);
true
false
Error
null
Assertion (A): Array index starts from 0. Reason (R): Because offset of first element is zero.
A
B
C
D
Assertion (A): Array size can be changed at runtime. Reason (R): Arrays in Java are dynamic.
A
B
C
D
Assertion (A): Array elements are stored in contiguous memory. Reason (R): This allows direct access using index.
A
B
C
D
Assertion (A): Length is a property of array. Reason (R): Because arrays are objects in Java.
A
B
C
D
Assertion (A): new keyword allocates memory for array. Reason (R): Array is object in heap.
A
B
C
D
Assertion (A): Binary search can be applied on unsorted array. Reason (R): Binary search works only if array is sorted.
A
B
C
D
Assertion (A): for-each loop can modify array elements. Reason (R): for-each provides reference to elements.
A
B
C
D
Assertion (A): Negative index is allowed in Java arrays. Reason (R): Because index can be positive or negative.
A
B
C
D
Assertion (A): ArrayIndexOutOfBoundsException occurs at runtime. Reason (R): Compiler does not check index.
A
B
C
D
Assertion (A): Arrays are objects. Reason (R): They have properties and methods.
A
B
C
D
Which is best for searching in sorted array?
Linear search
Binary search
Bubble sort
Selection sort
If an array is partially filled, how to track number of valid elements?
Using length property
Using counter variable
Using null check
Impossible
Which is more efficient for checking duplicates in small array?
Nested loops
HashSet
Binary search
Sorting
What happens if we assign one array to another?
Copy elements
Copy reference
Error
New array created
To reverse an array efficiently, which technique?
Swap from ends
Nested loops
Sorting
Rotate
