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

  1. Q1Multiple choice1 mark
    In a bubble sort algorithm operating on a single-dimensional integer array of size nn, how many passes are required in the worst-case scenario to fully sort the array?
    1. (a)n²
    2. (b)n - 1
    3. (c)n
    4. (d)n / 2
    Show answer and step marks
    1. Correct option: (b) n - 1+1
    Answer: (b)
  2. Q2Multiple choice1 mark
    How many total elements are created in memory when a double-dimensional array is instantiated using the statement `int matrix[][] = new int[3][4];`?
    1. (a)3
    2. (b)4
    3. (c)7
    4. (d)12
    Show answer and step marks
    1. Correct option: (d) 12+1
    Answer: (d)
  3. Q3Multiple choice1 mark
    Which of the following statements correctly declares and initialises a single-dimensional array of integers in Java?
    1. (a)int[] arr = new int(4);
    2. (b)int arr[] = {1, 2, 3, 4};
    3. (c)int arr = new int[4];
    4. (d)int arr{} = {1, 2, 3};
    Show answer and step marks
    1. Correct option: (b) int arr[] = {1, 2, 3, 4};+1
    Answer: (b)
  4. Q4Multiple choice1 mark
    What is the primary prerequisite for applying a binary search algorithm on a single-dimensional array in Java?
    1. (a)The array must be sorted in ascending or descending order.
    2. (b)The array size must be a power of 2.
    3. (c)The array must contain only positive integers.
    4. (d)The array must be declared as static.
    Show answer and step marks
    1. Correct option: (a) The array must be sorted in ascending or descending order.+1
    Answer: (a)
  5. Q5Long answer4 marks
    Write a program in Java to accept 1010 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
    1. Class with `main`, a `Scanner` object, an `int` array of size 1010 and sum variables `evenSum` and `oddSum` initialised to 00.+1
    2. A loop that reads the 1010 elements into the array with `sc.nextInt()`.+0.5
    3. Even check `a[i] % 2 == 0` adding the element to `evenSum`.+1
    4. `else` branch (or `a[i] % 2 ≠ 0`, not `== 1`, so negative odd numbers are counted) adding the element to `oddSum`.+0.5
    5. Display of the sum of even integers with a message.+0.5
    6. 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); } }
  6. Q6Long answer4 marks
    Write a program in Java to accept 1010 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
    1. Class with `main`, a `Scanner` object and an `int` array of size 1010 filled in a loop with `sc.nextInt()`.+1
    2. Maximum: `max` initialised to `a[0]` (not 00) and replaced whenever `a[i] > max`.+0.5
    3. Prime test for each element: numbers less than 22 are not prime, and a number is prime if no `j` from 22 up to its square root (or up to n−1n-1, or a factor count of exactly 22) divides it.+1
    4. `count` incremented for each element found prime.+0.5
    5. Display of the maximum element.+0.5
    6. 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
See a sample marked answer sheet

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

More Class 10 Computer Applications mock tests