ICSE Computer Applications 2023

COMPUTER APPLICATIONS
Maximum Marks: 100
Time allowed: Two hours
Answers to this paper must be written on the paper provided separately.
You will not be allowed to write during the first 15 minutes.
This time is to be spent in reading the question paper.
The time given at the head of this paper is the time allowed for writing the answers.

This paper is divided into two sections.
Attempt all questions from Section A and four questions from Section B.
The intended marks for questions or parts of questions are given in brackets [ ].

SECTION A (40 Marks)
(Attempt all questions from this section)

Question 1
Choose the correct answers to the questions from the given options.
(Do not copy the questions, write the correct answers only)

(i) A mechanism where one class acquires the properties of another class:
(a) Polymorphism
(b) Inheritance
(c) Encapsulation
(d) Abstraction

(ii) Identify the type of operator &&:
(a) ternary
(b) unary
(c) logical
(d) relational

(iii) The Scanner class method used to accept words with space:
(a) next()
(b) nextLine()
(c) Next()
(d) nextString()

(iv) The keyword used to call package in the program:
(a) extends
(b) export
(c) import
(d) package

(v) What value will Math.sqrt(Math.ceil(15.3)) return?
(a) 16.0
(b) 16
(c) 4.0
(d) 5.0

(vi) The absence of which statement leads to fall through situation in switch case statement?
(a) continue
(b) break
(c) return
(d) System.exit(0)

(vii) State the type of loop in the given program segment:
for(int i = 5; i != 0; i -= 2)
System.out.println(i);
(a) finite
(b) infinite
(c) null
(d) fixed

(viii) Write a method prototype name check() which takes an integer argument and returns a char:
(a) char check()
(b) void check(int x)
(c) check(int x)
(d) char check(int x)

(ix) The number of values that a method can return is:
(a) 1
(b) 2
(c) 3
(d) 4

(x) Predict the output of the following code snippet: String P = “20”, Q = “22”;
int a = Integer.parseInt(P);
int b = Integer.valueOf(Q);
System.out.println(a + ” ” + b);
(a) 20
(b) 20 22
(c) 2220
(d) 22

(xi) The String class method to join two strings is:
(a) concat(String)
(b) <string>.joint(string)
(c) concat(char)
(d) Concat()

(xii) The output of the function “COMPOSITION”.substring(3, 6):
(a) POSI
(b) POS
(c) MPO
(d) MPOS

(xiii) int x = (int)32.8; is an example of ________ typecasting.
(a) implicit
(b) automatic
(c) explicit
(d) coercion

(xiv) The code obtained after compilation is known as:
(a) source code
(b) object code
(c) machine code
(d) java bytecode

(xv) Missing a semicolon in a statement is what type of error?
(a) Logical
(b) Syntax
(c) Runtime
(d) No error

(xvi) Consider the following program segment and select the output of the same when n = 10:
switch(n){
case 10: System.out.println(n * 2);
case 4: System.out.println(n * 4); break;
default: System.out.println(n);
}
(a)
20
40

(b)
10
4
(c) 20, 40
(d)
10
10

(xvii) A method which does not modify the value of variables is termed as:
(a) Impure method
(b) Pure method
(c) Primitive method
(d) User-defined method

(xviii) When an object of a wrapper class is converted to its corresponding primitive data type, it is called as ________.
(a) Boxing
(b) Explicit type conversion
(c) Unboxing
(d) Implicit type conversion

(xix) The number of bits occupied by the value ‘a’ are:
(a) 1 bit
(b) 2 bits
(c) 4 bits
(d) 16 bits

(xx) Method which is a part of a class rather than an instance of the class is termed as:
(a) Static method
(b) Non-static method
(c) Wrapper class
(d) String method

Question 2
(i) Write the Java expression for (a + b)x.
Math.pow(a + b, x)

(ii) Evaluate the expression when the value of x = 4:
x *= –x + x++ + x;
⇒ x = x * (–x + x++ + x);
⇒ x = 4 * (3 + 3 + 4)
⇒ x = 4 * (10)
⇒ x = 40

(iii) Convert the following do…while loop to for loop:
int x = 10;
do{
x–;
System.out.print(x);
}while(x >= 1);

int x = 10;
for(; x >= 1;){
x–;
System.out.print(x);
}

(iv) Give the output of the following Character class methods:
(a) Character.toUpperCase(‘a’)
A
(b) Character.isLetterOrDigit(‘#’)
false

(v) Rewrite the following code using the if-else statement:
int m = 400;
double ch = (m > 300)? (m / 10.0) * 2 : (m / 20.0) – 2;

int m = 400;
double ch = 0.0;
if(m > 300)
ch = (m / 10.0) * 2;
else
ch = (m / 20.0) – 2;

(vi) Give the output of the following program segment:
int n = 4279;
int d;
while(n > 0){
d = n % 10;
System.out.println(d);
n = n / 100;
}
OUTPUT:
9
2

(vii) Give the output of the following String class methods:
(a) “COMMENCEMENT”.lastIndexOf(‘M’)
8
(b) “devote”.compareTo(“DEVOTE”)
32

(viii) Consider the given array and answer the questions given below:
int x[] = {4, 7, 9, 66, 72, 0, 16};
(a) What is the length of the array?
7
(b) What is the value in x[4]?
72

(ix) Name the following:
(a) What is an instance of the class called?
Object
(b) The method which has the same name as that of the class name.
Constructor

(x) Write the value of n after execution:
char ch = ‘d’;
int n = ch + 5;

n = 105

SECTION B (60 Marks)
(Answer any four questions from this section)
The answers in this section should consist of the programs in either BlueJ environment or any program environment with Java as the base.
Each program should be written using variable description/mnemonic codes so that the logic of the program is clearly depicted.
Flowcharts and algorithms are not required.

Question 3
Design a class with the following specifications:
Class name: Student
Member variables:
name – name of the student
age – age of student
mks – marks obtained
stream – stream allocated
(Declare the variables using appropriate data types)
Member methods:
void accept(): Accept name, age and marks using methods of Scanner class.
void allocation() – Allocate the stream as per following criteria:

mksstream
>= 300Science and Computer
>= 200 and < 300Commerce and Computer
>= 75 and < 200Arts and Animation
< 75Try again

void print() – Display student name, age, mks and stream allocated.

Call all the above methods in main() method using an object.

import java.util.Scanner;
class Student{
    String name;
    int age;
    int mks;
    String stream;
    public void accept(){
        Scanner in = new Scanner(System.in);
        System.out.print("Student name: ");
        name = in.nextLine();
        System.out.print("Age: ");
        age = Integer.parseInt(in.nextLine());
        System.out.print("Marks obtained: ");
        mks = Integer.parseInt(in.nextLine());
        stream = "";
    }
    public void allocation(){
        if(mks >= 300)
            stream = "Science and Computer";
        else if(mks >= 200)
            stream = "Commerce and Computer";
        else if(mks >= 75)
            stream = "Arts and Animation";
        else
            stream = "Try again";
    }
    public void print(){
        System.out.println("Student name: " + name);
        System.out.println("Age: " + age + " years");
        System.out.println("Marks obtained: " + mks);
        System.out.println("Stream allocated: " + stream);
    }
    public static void main(String[] args) {
        Student obj = new Student();
        obj.accept();
        obj.allocation();
        obj.print();
    }
}

Question 4
Define a class to accept 10 characters from a user. Using bubble sort technique to arrange them in ascending order. Display the sorted array and original array.

import java.util.Scanner;
class Sort{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        char a[] = new char[10];
        System.out.println("Enter 10 characters:");
        for(int i = 0; i < a.length; i++)
            a[i] = in.nextLine().charAt(0);
        System.out.println("Original array:");
        for(int i = 0; i < a.length; i++)
            System.out.print(a[i] + " ");
        System.out.println();
        for(int i = 0; i < a.length; i++){
            for(int j = 0; j < a.length - 1 - i; j++){
                if(a[j] > a[j + 1]){
                    char temp = a[j];
                    a[j] = a[j + 1];
                    a[j + 1] = temp;
                }
            }
        }
        System.out.println("Sorted array:");
        for(int i = 0; i < a.length; i++)
            System.out.print(a[i] + " ");
        System.out.println();
    }
}

Question 5
Define a class to overload the function print() as follows:
void print() to print the following format
1 1 1 1
2 2 2 2
3 3 3 3
4 4 4 4
5 5 5 5
void print(int n) to check whether the number is a lead number. A lead number is the one whose sum of even digits are equal to sum of odd digits.
e.g. 3669
odd digits sum = 3 + 9 = 12
even digits sum = 6 + 6 = 12
3669 is a lead number.

import java.util.Scanner;
class Overload{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.println("1. Pattern");
        System.out.println("2. Lead number");
        System.out.print("Enter your choice: ");
        int choice = Integer.parseInt(in.nextLine());
        switch(choice){
        case 1:
            print();
            break;
        case 2:
            System.out.print("Enter the number: ");
            int n = Integer.parseInt(in.nextLine());
            print(n);
            break;
        default:
            System.out.println("Invalid choice!");
        }
    }
    public static void print(){
        for(int i = 1; i <= 5; i++){
            for(int j = 1; j <= 5; j++)
                System.out.print(i + " ");
            System.out.println();
        }
    }
    public static void print(int n){
        int even = 0;
        int odd = 0;
        while(n != 0){
            int d = n % 10;
            if(d % 2 == 0)
                even += d;
            else
                odd += d;
            n /= 10;
        }
        if(even == odd)
            System.out.println("Lead number!");
        else
            System.out.println("Not a lead number.");
    }
}

Question 6
Define a class to accept a string and print the number of digits, alphabets and special characters in the string.
Example: S = “KAPILDEV@83”
Output:
Number of digits = 2
Number of alphabets = 8
Number of special characters = 1

import java.util.Scanner;
class Overload{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.print("Enter the string: ");
        String s = in.nextLine();
        int digits = 0;
        int alphabets = 0;
        int special = 0;
        for(int i = 0; i < s.length(); i++){
            char ch = s.charAt(i);
            if(Character.isLetter(ch))
                alphabets++;
            else if(Character.isDigit(ch))
                digits++;
            else
                special++;
        }
        System.out.println("Number of digits = " + digits);
        System.out.println("Number of alphabets = " + alphabets);
        System.out.println("Number of digits = " + special);
    }
}

Question 7
Define a class to accept values into an array of double data type of size 20. Accept a double value from user and search in the array using linear search method. If value is found display message “Found” with its position where it is present in the array. Otherwise display message “not found”.

import java.util.Scanner;
class Search{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        double a[] = new double[20];
        System.out.println("Enter the numbers: ");
        for(int i = 0; i < a.length; i++)
            a[i] = Double.parseDouble(in.nextLine());
        System.out.print("Enter value to be searched: ");
        double key = Double.parseDouble(in.nextLine());
        int i = 0;
        while(i < a.length){
            if(key == a[i])
                break;
            i++;
        }
        if(i == a.length)
            System.out.println("not found");
        else
            System.out.println("Found at position " + i);
    }
}

Question 8
Define a class to accept values in integer array of size 10. Find sum of one-digit number and sum of two-digit numbers entered. Display them separately.
Example:
Input: a[] = {2, 12, 4, 9, 18, 25, 3, 32, 20, 1}
Output:
Sum of one-digit numbers: 2 + 4 + 9 + 3 + 1 = 19
Sum of two-digit numbers: 12 + 18 + 25 + 32 + 20 = 107

import java.util.Scanner;
class Find{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int a[] = new int[10];
        System.out.println("Enter the integers: ");
        for(int i = 0; i < a.length; i++)
            a[i] = Integer.parseInt(in.nextLine());
        int oneDigit = 0;
        int twoDigit = 0;
        for(int i = 0; i < a.length; i++){
            int num = Math.abs(a[i]);
            if(num >= 0 && num <= 9)
                oneDigit += a[i];
            else if(num >= 10 && num <= 99)
                twoDigit += a[i];
        }
        System.out.println("Sum of one-digit numbers: " + oneDigit);
        System.out.println("Sum of two-digit numbers: " + twoDigit);
    }
}

2 thoughts on “ICSE Computer Applications 2023

    • Integer.parseInt() java.lang me hota hai. Maine nextLine() use kiya hai jo Scanner class me hi hota hai. io package me to readLine() hota hai. I hope I’ve made myself clear Bhai.

Leave a Reply to Dinesh sahu Cancel reply

Your email address will not be published. Required fields are marked *