Chapter 14 - Arrays - Solutions For Class 10 ICSE Logix Kips Computer Applications With BlueJ Java - KnowledgeBoat
Chapter 14 - Arrays - Solutions For Class 10 ICSE Logix Kips Computer Applications With BlueJ Java - KnowledgeBoat
Home / Class 10 - Logix Kips ICSE Computer Applications with BlueJ / Arrays
Chapter 14
Arrays
Class 10 - Logix Kips ICSE Computer Applications with BlueJ
Question 1
1. {}
2. [] ✓
3. ()
4. All of these
Question 2
Given array int x[] = {11, 22, 33, 44}; the value of x[1] is ........... .
1. 11
2. 22 ✓
3. 33
4. Invalid value
Question 3
Given array int x[] = {11, 22, 33, 44}; the value of x[1+2] is ........... .
1. 11
2. 22
3. 33
4. 44 ✓
Question 4
1. 3
2. 5
3. 4 ✓
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/2ll16/arrays 1/29
5/20/24, 1:34 PM Chapter 14: Arrays | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
4. Cannot be determined
Question 5
Given array int z[] = {15, 16, 17}; It will occupy ........... bytes in
memory.
1. 3
2. 12 ✓
3. 24
4. 64
Question 6
Question 7
A binary search
Question 8
Question 9
In ........... search, the algorithm uses the middle value of the array
for the search operation.
1. Binary ✓
2. Linear
3. Bubble
4. Selection
Question 10
1. 8th
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/2ll16/arrays 2/29
5/20/24, 1:34 PM Chapter 14: Arrays | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
2. 9th
3. 10th ✓
4. 11th
Assignment Questions
Question 1
Write a program to initialise the given data in an array and find the
minimum and maximum values along with the sum of the given
elements.
Numbers: 2, 5, 4, 1, 3
Output:
Minimum value: 1
Maximum value: 5
Sum of the elements: 15
Answer
sum += arr[i];
}
Output
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/2ll16/arrays 3/29
5/20/24, 1:34 PM Chapter 14: Arrays | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
Question 2
Answer
Array declaration tells the compiler about the size and data type of
the array so that the compiler can reserve the required memory for
the array. This reserved memory is still empty. Array Initialisation
assigns values to the array elements i.e. it stores values in the
memory reserved for the array elements.
Answer
int a[10] is an array of int data type that can hold 10 integer values
whereas char a[10] is an array of char data type that can hold 10
characters.
Answer
Sorting Searching
Answer
Answer
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/2ll16/arrays 4/29
5/20/24, 1:34 PM Chapter 14: Arrays | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
Question 3
How does the linear search find an element in the array? Explain
your answer with a suitable example.
Answer
Question 4
Answer
9 5 2 3
Pass 1
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/2ll16/arrays 5/29
5/20/24, 1:34 PM Chapter 14: Arrays | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
5 9 2 3
5 2 9 3
5 2 3 9
At the end of first pass, the highest element of the array is at the
last position.
Pass 2
2 5 3 9
2 3 5 9
At the end of first pass, the second highest element of the array is
in its correct position.
Pass 3
2 3 5 9
With this, the third and final pass ends and the elements of the
array are in sorted order.
Question 5
Answer
Selection Sort divides the array into two parts — sorted sub-array
and unsorted sub-array. In each pass, it finds the minimum
element of the unsorted sub-array and swaps it with the leftmost
unsorted element moving the sorted sub-array one element to the
right.
9 5 2 3
Pass 1
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/2ll16/arrays 6/29
5/20/24, 1:34 PM Chapter 14: Arrays | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
2 5 9 3
At the end of the first pass, the smallest element is in its correct
position. Length of sorted sub-array is 1 and unsorted sub-array is
3.
Pass 2
2 3 9 5
Pass 3
2 3 5 9
With this, the third and final pass ends and the elements of the
array are in sorted order.
Question 6
Answer
Question 7
Answer
As Binary Search repeatedly divides the array into two halves and
performs the search in only one of those two halves, it needs to
make fewer comparisons relative to Linear Search hence it is
faster than Linear Search.
Question 8
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/2ll16/arrays 7/29
5/20/24, 1:34 PM Chapter 14: Arrays | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
Answer
import java.util.Scanner;
sum += arr[i];
}
Output
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/2ll16/arrays 8/29
5/20/24, 1:34 PM Chapter 14: Arrays | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
Question 9
Answer
Question 10
Answer
int c = 0;
for (int i = 0; i < 50; i++) {
if (x[i] == 42) {
c++;
}
}
System.out.println("Frequency of 42 = " + c);
Question 11
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/2ll16/arrays 9/29
5/20/24, 1:34 PM Chapter 14: Arrays | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
Answer
Array index starts at 0 not 1. In the given program, the for loop run
from 1 to 4 whereas the indexes of the array range from 0 to 3.
When i becomes 4, the program tries to access an index of arr that
is not present in the array and this causes the program to crash.
The correct way will be to run the for loop from 0 to 3 instead of 1
to 4.
Question 12
Answer
double sum = 0;
for (int i = 0; i < 50; i++) {
if (numb[i] > 0) {
sum += numb[i];
}
}
System.out.println("Sum of positive real numbers = " + sum);
Question 13
Write a code segment that finds the largest integer in this two-
dimensional array.
Answer
int l = data[0][0];
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5; j++) {
if (data[i][j] > l) {
l = data[i][j];
}
}
}
System.out.println("Largest Element = " + l);
Question 14
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/2ll16/arrays 10/29
5/20/24, 1:34 PM Chapter 14: Arrays | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
ii. Write an output statement that prints the value of the tenth
element of the array name.
iii. Write a for statement that fills the array name with spaces.
Answer
i. name[0] = 'D';
ii. System.out.println(name[9]);
Question 15
Answer
Question 16
ii. Assign the value 10.5 to the last element in the array.
iii. Display the sum of the first and the last element.
iv. Write a loop that computes the sum of all elements in the array.
Answer
ii. Assign the value 10.5 to the last element in the array.
arr[14] = 10.5;
iii. Display the sum of the first and the last element.
iv. Write a loop that computes the sum of all elements in the array.
double sum = 0;
for (int i = 0; i < 15; i++) {
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/2ll16/arrays 11/29
5/20/24, 1:34 PM Chapter 14: Arrays | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
sum += arr[i];
}
System.out.println("Sum = " + sum);
Question 17
Answer
import java.util.Scanner;
if (idx == -1)
System.out.println("Record does not exist");
else
System.out.println("Record exists");
}
}
Output
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/2ll16/arrays 12/29
5/20/24, 1:34 PM Chapter 14: Arrays | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
Question 18
Write a program that reads ten integers and displays them in the
reverse order in which they were read.
Answer
import java.util.Scanner;
System.out.println("Enter 10 integers:");
for (int i = 0; i < 10; i++) {
arr[i] = in.nextInt();
}
Output
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/2ll16/arrays 13/29
5/20/24, 1:34 PM Chapter 14: Arrays | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
Question 19
Write a program that reads a long number, counts and displays the
occurrences of each digit in it.
Answer
import java.util.Scanner;
while (num != 0) {
int d = (int)(num % 10);
dCount[d] = dCount[d] + 1;
num /= 10;
}
System.out.println("Digit\tOccurence");
for (int i = 0; i < 10; i++) {
if (dCount[i] != 0) {
System.out.println(i + "\t" + dCount[i]);
}
}
}
}
Output
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/2ll16/arrays 14/29
5/20/24, 1:34 PM Chapter 14: Arrays | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
Question 20
Answer
import java.util.Scanner;
//Bubble Sort
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (arr[j] < arr[j + 1]) {
int t = arr[j];
arr[j] = arr[j+1];
arr[j+1] = t;
}
}
}
System.out.println("Sorted Array:");
for (int i = 0; i < n; i++) {
System.out.print(arr[i] + " ");
}
}
}
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/2ll16/arrays 15/29
5/20/24, 1:34 PM Chapter 14: Arrays | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
Output
Question 21
Answer
import java.util.Scanner;
if (index == -1) {
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/2ll16/arrays 16/29
5/20/24, 1:34 PM Chapter 14: Arrays | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
System.out.println("Search element not found");
}
else {
System.out.println(n + " found at position " + ind
}
}
}
Output
Question 22
P[ ] Q[ ] R[ ]
4 19 4
6 23 6
1 7 1
Search by lesson title
2 8 2
CONTENTS
Chapter 1
Object Oriented Programming Concepts 3 3 Multiple Choice Questions
Assignment Questions
Chapter 2
Introduction to Java
10 10 Video Explanations
Chapter 3
19
Values and Data Types
Chapter 4
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/2ll16/arrays 17/29
5/20/24, 1:34 PM Chapter 14: Arrays | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
Chapter 4
Operators in Java
Input Input Output
Chapter 5
User-Defined Methods 23
Chapter 6
Input in Java 7
Chapter 7
8
Mathematical Library Methods
Chapter 8
Conditional Constructs in Java
Answer
Chapter 9
Iterative Constructs in Java import java.util.Scanner;
Chapter 10
Nested for loops public class Kboat3Arrays
{
Chapter 11
public static void main(String args[]) {
Constructors
i = 0;
while(i < P.length) {
R[i] = P[i];
i++;
}
int j = 0;
while(j < Q.length) {
R[i++] = Q[j++];
}
Output
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/2ll16/arrays 18/29
5/20/24, 1:34 PM Chapter 14: Arrays | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
Question 23
Answer
import java.util.Scanner;
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/2ll16/arrays 19/29
5/20/24, 1:34 PM Chapter 14: Arrays | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
System.out.print("Subject A Marks: ");
sA[i] = in.nextInt();
System.out.print("Subject B Marks: ");
sB[i] = in.nextInt();
System.out.print("Subject C Marks: ");
sC[i] = in.nextInt();
avg[i] = (sA[i] + sB[i] + sC[i]) / 3.0;
}
Output
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/2ll16/arrays 20/29
5/20/24, 1:34 PM Chapter 14: Arrays | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
Question 24
Answer
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/2ll16/arrays 21/29
5/20/24, 1:34 PM Chapter 14: Arrays | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
import java.util.Scanner;
sum += febTemp[i];
}
Output
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/2ll16/arrays 22/29
5/20/24, 1:34 PM Chapter 14: Arrays | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
Question 25
Answer
import java.util.Scanner;
sum += febTemp[i][j];
}
}
Output
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/2ll16/arrays 23/29
5/20/24, 1:34 PM Chapter 14: Arrays | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
Question 26
Employee 0 8 5 1 11 1 0 0
Employee 1 11 6 0 2 2 2 4
Employee 2 4 5 4 10 4 3 1
Employee 3 4 7 3 12 6 2 0
Employee 4 3 8 3 2 4 4 0
Answer
import java.util.Scanner;
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/2ll16/arrays 24/29
5/20/24, 1:34 PM Chapter 14: Arrays | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
int empArr[] = new int[numEmps];
int hours[] = new int[numEmps];
t = empArr[i];
empArr[i] = empArr[index];
empArr[index] = t;
}
Output
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/2ll16/arrays 25/29
5/20/24, 1:34 PM Chapter 14: Arrays | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
Question 27
− − −
(x1 − x)2 + (x2 − x)2 + ... + (xN − x)2
s=
N
−
The variable x is the average of N input values x1 through xN .
The program first prompts the user for N and then declares an
array of size N.
Answer
import java.util.Scanner;
System.out.print("Enter N:");
int n = in.nextInt();
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/2ll16/arrays 26/29
5/20/24, 1:34 PM Chapter 14: Arrays | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
a[i] = in.nextDouble();
}
double sum = 0;
for (int i = 0; i < n; i++) {
sum += a[i];
}
Output
Video Explanations
Prev Next
Encapsulation and Inheritance String Handling
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/2ll16/arrays 27/29
5/20/24, 1:34 PM Chapter 14: Arrays | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
fr
Class - 6 Effective History & Civics Solutions Java Number Programs (ICSE Classes 9 / 10) Privacy Policy
Class - 6 APC Understanding Computers Solutions Java Number Programs (ISC Classes 11 / 12) Terms of Service
Class - 7 Concise Physics Selina Solutions Output Questions for Class 10 ICSE Computer Applications
Class - 7 Concise Chemistry Selina Solutions Algorithms & Flowcharts for ICSE Computers
Class - 7 Dalal Simplified Middle School Chemistry Solutions ICSE Class 8 Computers Differentiate Between the Following
Class - 7 Living Science Biology Ratna Sagar Solutions Class - 8 NCERT Science Solutions
Class - 7 Around the World Geography Solutions Class - 9 NCERT Science Solutions
Class - 7 Veena Bhargava Geography Solutions Class - 9 NCERT Geography Contemporary India 1 Solutions
Class - 7 Effective History & Civics Solutions Class - 9 Sumita Arora Computer Code 165 Solutions
Class - 7 APC Understanding Computers Solutions Class - 9 Kips Cyber Beans Computer Code 165 Solutions
Class - 8 Dalal Simplified Middle School Chemistry Solutions Class - 10 NCERT Geography Contemporary India 2 Solutions
Class - 8 Concise Biology Selina Solutions Class - 10 NCERT History India & Contemporary World 2 Solutions
Class - 8 Living Science Biology Ratna Sagar Solutions Class - 10 Sumita Arora Computer Code 165 Solutions
Class - 8 Around the World Geography Solutions Class - 10 Kips Cyber Beans Computer Code 165 Solutions
Class - 8 Veena Bhargava Geography Solutions Class - 11 CBSE Sumita Arora Python Solutions
Class - 8 Effective History & Civics Solutions Class - 12 CBSE Sumita Arora Python Solutions
Class - 8 APC Understanding Computers Solutions Class - 12 CBSE Preeti Arora Python Solutions
Class - 8 Kips Logix Computers Solutions Class - 12 NCERT Computer Science Solutions
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/2ll16/arrays 28/29
5/20/24, 1:34 PM Chapter 14: Arrays | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
Class - 10 Concise Chemistry Selina Solutions
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/2ll16/arrays 29/29