[go: up one dir, main page]

KISA ICSE Computer Applications- AK

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

KARNATAKA ICSE SCHOOLS ASSOCIATION

ICSE STD. X Preparatory Examination 2025


Subject – Computer Applications(Answer Key)

Duration : 2 hours Maximum Marks : 100 Date: 16.01.2025

Question 1
i. 1
d) Polymorphism
ii. b) Java Virtual Machine (JVM)
iii. b)Within the same package and by subclasses 1

iv. b) Pre-increment (++i) 1


v. a) byte = 1 byte, short = 2 bytes, int = 4 bytes, long = 8 bytes 1

vi. 25.0 1
vii. b) Removes spaces at the beginning and end of a string 1

viii. c) Compilation error occurs 1

ix. a) Both Assertion and Reasoning are true, and Reasoning is the correct 1
explanation of Assertion.

x. a) A primitive type is automatically converted to a corresponding wrapper 1


class object.
xi int sum = 0; 1
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < arr[i].length; j++) {
sum += arr[i][j];
}
}
xii. c) Assertion is false, but Reasoning is true. 1

xiii. c) 49 1
xiv.
d) 3,2 d) 3,2,4,1,5 1

xv.
b) anta 1

xvi. a)final 1
xvii.
a) import d) Defining a constructor with a return type. 1
xviii. a) import 1
xix
c) Impu
c) Impure method

xx b) 4 1
Question 2
i. 27 2
ii. Math.cbrt(Math.pow((a+b),4)/Math.pow(a,2)) 2
iii. Statement with error- if(i%2==0) 2
break;
Replace break with continue
iv. a. miniart 2
b.-4
v. The loop will be executed 5 times. The output of the code is as follows. 2
1
7
13
19
25
6
vi. String eligibility=(age>=18)?”Adult”:”Minor”; 2
vii. Runtime error. These functions cannot be performed on alpha numeric 2
strings
viii. a. Position of 5 is a[1][1] 2
b. 15
ix. a. e 2
b. 89
x. a. Value of a=2 and b=10. 2
b. Class variables x and y
Question 3

import java.util.Scanner; [15]


class FashionCourier
{ String name; int wt; double charge;
FashionCourier()
{ name = "";
wt = 0; charge = 0.0; }
void accept()
{ Scanner sc = new Scanner(System.in);
System.out.print("Enter the customer's name: ");
name = sc.nextLine();
System.out.print("Enter the weight of the parcel (in kg): ");
wt = sc.nextInt(); }
void compute()
{ double baseCharge = 0.0;
if (wt < 5)
{ baseCharge = wt * 50; }
else if (wt >= 5 && wt < 10)
{ baseCharge = wt * 150; }
else if (wt >= 10 && wt < 20)
{ baseCharge = wt * 200; }
else if (wt >= 20)
{ baseCharge = wt * 350; }
double surcharge = baseCharge * 0.05;
surcharge charge = baseCharge + surcharge; }
void display()
{ System.out.println();
System.out.println("Name\t\tWeight\t\tBill Amount");
System.out.println("*****\t\t*****\t\t**********");
System.out.printf("%s\t\t%d\t\tRs. %.2f\n", name, wt, charge); }
public static void main()
{
FashionCourier obj = new FashionCourier();
obj.accept()
obj.compute();
obj.display();} }
Question 4 import java.util.Scanner;
public class SelectionSort
{
public static void main()
{
int[] arr = new int[15];
Scanner sc = new Scanner(System.in);
System.out.println("Enter 15 integers:");
for (int i = 0; i < 15; i++)
{
System.out.print("Enter integer " + (i + 1) + ": ");
arr[i] = sc.nextInt();
}
for (int i = 0; i < 14; i++)
{
int minIndex = i;
for (int j = i + 1; j < 15; j++)
{ if (arr[j] < arr[minIndex])
{ minIndex = j; } }
if (minIndex != i)
{
int temp = arr[i]; arr[i] = arr[minIndex]; arr[minIndex] = temp; } }
System.out.println("\nThe integers in ascending order are:"); for (int i =
0; i < 15; i++) { System.out.print(arr[i] + " "); } } }
Question 5 import java.util.Scanner; 15
class String2
{
void main()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the string");
String str=sc.nextLine();
int x=str.length();String s=" ";char ch;
for(int i=x-1;i>=0;i--)
{ ch=str.charAt(i);
s=s+ch;
}
if(str.equals(s))
System.out.println("The given string is a palindrome");
else
if(str.charAt(0)==str.charAt(x-1))
System.out.println("The given string is a special word") ;
else
System.out.println("The given string is neither a palindrome nor a
special word");
}
}
Question 6 import java.util.Scanner; 15

public class NormOfNumber {


public static void main(String[] args) {
Scanner sc = new Scanner(System.in);

// Input the number


System.out.print("Enter a number: ");
int number = sc.nextInt();

int sumOfSquares = 0;

// Loop to extract each digit and calculate the sum of squares of the
digits
while (number > 0) {
int digit = number % 10; // Extract the last digit
sumOfSquares += digit * digit; // Add the square of the digit to
sum
number /= 10; // Remove the last digit
}

// Calculate the square root of the sum of squares


double norm = Math.sqrt(sumOfSquares);

// Output the result


System.out.println("The norm of the number is: " + (int) norm);

}
}
Question 7 import java.util.Scanner;

public class MatrixColumnSum {


public static void main(String[] args) {
Scanner sc = new Scanner(System.in);

// Accept the size of the matrix (m x m)


System.out.print("Enter the size of the matrix (m): ");
int m = sc.nextInt();

int[][] matrix = new int[m][m]; // 2D array of order m x m

// Accept elements of the matrix


System.out.println("Enter the elements of the matrix:");
for (int i = 0; i < m; i++) {
for (int j = 0; j < m; j++) {
System.out.print("Element at (" + i + "," + j + "): ");
matrix[i][j] = sc.nextInt();
}
}

// Print the matrix in matrix format


System.out.println("\nThe matrix is:");
for (int i = 0; i < m; i++) {
for (int j = 0; j < m; j++) {
System.out.print(matrix[i][j] + "\t");
}
System.out.println();
}

// Calculate and print the sum of elements of each column


System.out.println("\nSum of elements of each column:");
for (int j = 0; j < m; j++) {
int columnSum = 0;
for (int i = 0; i < m; i++) {
columnSum += matrix[i][j];
}
System.out.println("Column " + (j + 1) + ": " + columnSum);
}
}
}
Question 8 import java.util.Scanner;
public class OverloadResult {
// Method 1: Print the series A, C, E, G... n terms
void result() {
Scanner sc = new Scanner(System.in);
System.out.print("Enter the number of terms for the series A, C, E,
G...: ");
int n = sc.nextInt();

char ch = 'A'; // Starting character


System.out.println("The series is:");
for (int i = 0; i < n; i++) {
System.out.print(ch + " ");
ch += 2; // Increment by 2 to skip letters
}
System.out.println();
}

// Method 2: Print the sum of the given series a/1 + a/2 + ... n terms
void result(int a, int n) {
double sum = 0.0;
for (int i = 1; i <= n; i++) {
sum += (double) a / i; // Add each term of the series
}
System.out.printf("The sum of the series is: %.2f\n", sum);
}

// Method 3: Print the pattern using $ and @


void result(char ch1, char ch2) {
System.out.println("The pattern is:");
for (int i = 1; i <= 4; i++) { // Rows of the pattern
for (int j = 1; j <= i; j++) { // Columns of the pattern
if (j % 2 != 0) // Odd position
System.out.print(ch1 + "\t");
else // Even position
System.out.print(ch2 + "\t");
}
System.out.println();
}
}

// Main method
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
OverloadResult obj = new OverloadResult();
// Call the first result() method
obj.result();

// Call the second result() method


System.out.print("\nEnter the value of 'a' and number of terms 'n' for
the series a/1 + a/2 + ...: ");
int a = sc.nextInt();
int n = sc.nextInt();
obj.result(a, n);

// Call the third result() method


System.out.println("\nPattern using '@' and '$':");
obj.result('@', '$');
}
}

You might also like