ICSE · Class 10 · Computer Applications
Class 10 Arrays Mock Test (ICSE)
6 practice questions from Arrays, in the style of your board paper, each with a worked answer and the marks for every step. Then take a full chapter test on paper, snap the pages and get every step marked.
Topics in Arrays
- Single-dimensional arrays
- Declaration, initialisation and input
- Linear search and binary search
- Selection sort and bubble sort
- Double-dimensional arrays
- Row, column and diagonal operations
Arrays practice questions with answers
- Q1Multiple choice1 markIn a bubble sort algorithm operating on a single-dimensional integer array of size , how many passes are required in the worst-case scenario to fully sort the array?
- (a)n²
- (b)n - 1
- (c)n
- (d)n / 2
Show answer and step marks
- Correct option: (b) n - 1+1
Answer: (b) - Q2Multiple choice1 markHow many total elements are created in memory when a double-dimensional array is instantiated using the statement `int matrix[][] = new int[3][4];`?
- (a)3
- (b)4
- (c)7
- (d)12
Show answer and step marks
- Correct option: (d) 12+1
Answer: (d) - Q3Multiple choice1 markWhich of the following statements correctly declares and initialises a single-dimensional array of integers in Java?
- (a)int[] arr = new int(4);
- (b)int arr[] = {1, 2, 3, 4};
- (c)int arr = new int[4];
- (d)int arr{} = {1, 2, 3};
Show answer and step marks
- Correct option: (b) int arr[] = {1, 2, 3, 4};+1
Answer: (b) - Q4Multiple choice1 markWhat is the primary prerequisite for applying a binary search algorithm on a single-dimensional array in Java?
- (a)The array must be sorted in ascending or descending order.
- (b)The array size must be a power of 2.
- (c)The array must contain only positive integers.
- (d)The array must be declared as static.
Show answer and step marks
- Correct option: (a) The array must be sorted in ascending or descending order.+1
Answer: (a) - Q5Long answer4 marksWrite a program in Java to accept integer elements into a single-dimensional array. Calculate and print: 1. The sum of all even integers present in the array. 2. The sum of all odd integers present in the array. Assume all standard packages are imported.
Show answer and step marks
- Class with `main`, a `Scanner` object, an `int` array of size and sum variables `evenSum` and `oddSum` initialised to .+1
- A loop that reads the elements into the array with `sc.nextInt()`.+0.5
- Even check `a[i] % 2 == 0` adding the element to `evenSum`.+1
- `else` branch (or `a[i] % 2 ≠ 0`, not `== 1`, so negative odd numbers are counted) adding the element to `oddSum`.+0.5
- Display of the sum of even integers with a message.+0.5
- Display of the sum of odd integers with a message.+0.5
Answer: import java.util.Scanner; class EvenOddSum { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int a[] = new int[10]; int evenSum = 0, oddSum = 0; System.out.println("Enter 10 integers:"); for (int i = 0; i < 10; i++) { a[i] = sc.nextInt(); } for (int i = 0; i < 10; i++) { if (a[i] % 2 == 0) evenSum = evenSum + a[i]; else oddSum = oddSum + a[i]; } System.out.println("Sum of even integers = " + evenSum); System.out.println("Sum of odd integers = " + oddSum); } } - Q6Long answer4 marksWrite a program in Java to accept integer elements into a single-dimensional array. Using these elements, perform the following tasks: (i) Find and display the maximum element present in the array. (ii) Count and display the total number of prime numbers stored in the array.
Show answer and step marks
- Class with `main`, a `Scanner` object and an `int` array of size filled in a loop with `sc.nextInt()`.+1
- Maximum: `max` initialised to `a[0]` (not ) and replaced whenever `a[i] > max`.+0.5
- Prime test for each element: numbers less than are not prime, and a number is prime if no `j` from up to its square root (or up to , or a factor count of exactly ) divides it.+1
- `count` incremented for each element found prime.+0.5
- Display of the maximum element.+0.5
- Display of the number of primes.+0.5
Answer: import java.util.Scanner; class MaxPrime { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int a[] = new int[10]; System.out.println("Enter 10 integers:"); for (int i = 0; i < 10; i++) { a[i] = sc.nextInt(); } int max = a[0]; int count = 0; for (int i = 0; i < 10; i++) { if (a[i] > max) max = a[i]; int n = a[i]; boolean prime = (n ≥ 2); for (int j = 2; j ≤ n / j; j++) { if (n % j == 0) { prime = false; break; } } if (prime) count++; } System.out.println("Maximum element = " + max); System.out.println("Number of prime numbers = " + count); } }
Take a full Arrays test
PrepitUp writes a fresh paper on this chapter at the length you pick. Write it on paper with a timer, photograph the pages, and see the marks for every step and what to practise next.
- 15 min10 marks
- 30 min20 marks
- 1.5 hr40 marks
- 3 hr80 marks
Get your Arrays answers marked
Sign in, pick this chapter and a length, write the test on paper and get every step marked.
Sign in to take this test