ICSE Class 10 Computer Applications ( Java ) 2011 Solved Question Paper

COMPUTER APPLCATIONS

(Theory)
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 the Paper is the time allowed for writing the answers.
This paper is divided into two Sections.
Attempt all questions from Section A and any four questions from Section B.
The intended marks for questions or parts of questions are given in bracket [ ]

SECTION – A (40 Marks)

Question 1.

(a) What is the difference between an object and a class? [2]
Ans. 1. A class is a blueprint or a prototype of a real world object. It contains instance variables and methods whereas an object is an instance of a class.
2. A class exists in the memory of a computer while an object does not.
3. There will be only one copy of a class whereas multiple objects can be instantiated from the same class.

(b) What does the token ‘keyword’ refer to in the context of Java? Give an example for keyword. [2]
Ans. Keywords are reserved words which convey special meanings to the compiler and cannot be used as identifiers. Example of keywords : class, public, void, int

(c) State the difference between entry controlled loop and exit controlled loop. [2]
Ans. In an entry controlled loop, the loop condition is checked before executing the body of the loop. While loop and for loop are the entry controlled loops in Java.
In exit controlled loops, the loop condition is checked after executing the body of the loop. do-while loop is the exit controlled loop in Java.

(d) What are the two ways of invoking functions? [2]
Ans. If the function is static, it can be invoked by using the class name. If the function is non-static, an object of that class should be created and the function should be invoked using that object.

(e) What is difference between / and % operator? [2]
Ans. / is the division operator whereas % is the modulo (remainder) operator. a / b gives the result obtained on diving a by b whereas a % b gives the remainder obtained on diving a by b.

Question 2.

(a) State the total size in bytes, of the arrays a [4] of char data type and p [4] of float data type. [2]
Ans. char is two bytes. So a[4] will be 2*4=8 bytes.
float is 4 bytes. So p[4] will be 4*4=16 bytes.

(b) (i) Name the package that contains Scanner class.
(ii) Which unit of the class gets called, when the object of the class is created? [2]

Ans. (i) java.util
(ii) Constructor

(c) Give the output of the following: [2]

String n = “Computer Knowledge”;
String m = “Computer Applications”;
System.out.println(n.substring (0,8). concat (m.substring(9)));
System.out.println(n.endsWith(“e”));

Ans. n.substring(0,8) gives “Computer”. m.substring(9) gives “Applications”. These two on concatenation gives “ComputerApplications”. n ends with “e”. So, it gives true.
The output is:

ComputerApplications
true

(d) Write the output of the following: [2]
(i) System.out.println (Character.isUpperCase(‘R’));
(ii) System.out.println(Character.toUpperCase(‘j’));

Ans. (i) true
(ii) J

(e) What is the role of keyword void in declaring functions? [2]
Ans. void indicates that the function doesn’t return any value.

Question 3

(a) Analyse the following program segment and determine how many times the loop will be executed and what will be the output of the program segment ? [2]

int p = 200;
while(true)
{
if (p<100)
break;
p=p-20;
}
System.out.println(p);

Ans.p values changes as follows : 200, 180, 160, 140, 120, 100, 80. So, the loop executes six times and value of p is 80.

(b) What will be the output of the following code? [2]
(i)

int k = 5, j = 9;
k += k++ – ++j + k;
System.out.println("k= " +k);
System.out.println("j= " +j);

Ans.

k = 6
j = 10

Explanation:
k += k++ – ++j + k
k = k + k++ – ++j + k
k = 5 + 5 – 10 + 6
k = 6
j = 10 as it has been incremented in the ++j operation.

(ii) [2]

double b = -15.6;
double a = Math.rint (Math.abs (b));
System.out.println("a= " +a);

Ans.

a =16.0

Maths.abs(-15.6) will give 15.6 and Math.rint(15.6) gives 16.0.

(c) Explain the concept of constructor overloading with an example . [2]
Ans. A class can have more than one constructor provided that the signatures differ. This is known as constructor overloading.
Example:

class Age {

    int age;

    public Age() {
        age = -1;
    }

    public Age(int age) {
        this.age = age;
    }
}

(d) Give the prototype of a function search which receives a sentence sentnc and a word wrd and returns 1 or 0 ? [2]
Ans.

public boolean function ( sentence sentnc, word wrd )

or

public int function ( sentence sentnc, word wrd )

(e) Write an expression in Java for z = (5×3 + 2y ) / ( x + y) [2]
Ans.

z = ( 5 * Math.pow ( x, 3 ) + 2 * y ) / ( x + y )

(f) Write a statement each to perform the following task on a string: [2]
(i) Find and display the position of the last space in a string s.
(ii) Convert a number stored in a string variable x to double data type
Ans.
(i) System.out.println(s.lastIndexOf(” “);
(ii) Double.parseDouble(x)

(g) Name the keyword that: [2]
(i) informs that an error has occurred in an input/output operation.
(ii) distinguishes between instance variable and class variables.
Ans.
(i) throw
(ii) static

(h) What are library classes ? Give an example. [2]
Ans.
Library classes are the predefined classes which are a part of java API. Ex: String, Scanner

(i) Write one difference between Linear Search and Binary Search . [2]
Ans.
Linear search can be used with both sorted and unsorted arrays. Binary search can be used only with sorted arrays.

SECTION – B (60 Marks)

Attempt any four questions from this Section.

The answers in this Section should consist of the Programs in either Blue J environment or any program environment with Java as the base.
Each program should be written using Variable descriptions/Mnemonic Codes such that the logic of the program is clearly depicted.
Flow-Charts and Algorithms are not required.

Question 4.

Define a class called mobike with the following description: [15]
Instance variables/data members: int bno – to store the bike’s number
int phno – to store the phone number of the customer
String name – to store the name of the customer
int days – to store the number of days the bike is taken on rent
int charge – to calculate and store the rental charge
Member methods:
void input( ) – to input and store the detail of the customer.
void computer( ) – to compute the rental charge
The rent for a mobike is charged on the following basis.
First five days Rs 500 per day;
Next five days Rs 400 per day
Rest of the days Rs 200 per day
void display ( ) – to display the details in the following format:
Bike No. PhoneNo. No. of days Charge

Ans.

import java.util.Scanner;

public class mobike {

    int bno;
    int phno;
    String name;
    int days;
    int charge;

    public void input() {
        Scanner scanner = new Scanner(System.in);
        System.out.print("Enter bike number: ");
        bno = scanner.nextInt();
        System.out.print("Enter phone number: ");
        phno = scanner.nextInt();
        System.out.print("Enter your name: ");
        name = scanner.next();
        System.out.print("Enter number of days: ");
        days = scanner.nextInt();
    }

    public void compute() {
        if (days <= 5) {
            charge = 500 * days;
        } else if (days <= 10) {
            charge = 5 * 500 + (days - 5) * 400;
        } else {
            charge = 5 * 500 + 5 * 400 + (days - 10) * 200;
        }
    }

    public void display() {
        System.out.println("Bike No. \tPhone No. \t No. of Days \t Charge");
        System.out.println(bno + "\t" + phno + "\t" + days + "\t" + charge);
    }
}

Question 5.

Write a program to input and sort the weight of ten people. Sort and display them in descending order using the selection sort technique. [15]

Ans.

import java.util.Scanner;

public class SelectionSort {

    public void program() {
        Scanner scanner = new Scanner(System.in);
        int[] weights = new int[10];
        System.out.println("Enter weights: ");
        for (int i = 0; i < 10; i++) {
            weights[i] = scanner.nextInt();
        }
        for (int i = 0; i < 10; i++) {
            int highest = i;
            for (int j = i + 1; j < 10; j++) {                 if (weights[j] > weights[highest]) {
                    highest = j;
                }
            }
            int temp = weights[highest];
            weights[highest] = weights[i];
            weights[i] = temp;
        }
        System.out.println("Sorted weights:");
        for (int i = 0; i < 10; i++) {
            System.out.println(weights[i]);
        }
    }
}

Question 6.

Write a program to input a number and print whether the number is a special number or not. (A number is said to be a special number, if the sum of the factorial of the digits of the number is same as the original number). [15]

Ans.

import java.util.Scanner;

public class SpecialNumber {

    public int factorial(int n) {
        int fact = 1;
        for (int i = 1; i <= n; i++) {             fact = fact * i;         }         return fact;     }     public int sumOfDigita(int num) {         int sum = 0;         while (num > 0) {
            int rem = num % 10;
            sum = sum + rem;
            num = sum / 10;
        }
        return sum;
    }

    public boolean isSpecial(int num) {
        int fact = factorial(num);
        int sum = sumOfDigita(fact);
        if (sum == num) {
            return true;
        } else {
            return false;
        }
    }

    public void check() {
        Scanner scanner = new Scanner(System.in);
        System.out.print("Enter a number: ");
        int num = scanner.nextInt();
        if (isSpecial(num)) {
            System.out.println("It is a special number");
        } else {
            System.out.println("It is not a special number");
        }
    }

}

Question 7

Write a program to accept a word and convert it into lowercase if it is in uppercase, and display the new word by replacing only the vowels with the character following it. [15]

Example
Sample Input : computer
Sample Output : cpmpvtfr

Ans.

import java.util.Scanner;

public class StringConversion {

    public static void convert() {
        Scanner scanner = new Scanner(System.in);
        System.out.print("Enter a String: ");
        String input = scanner.next();
        input = input.toLowerCase();
        String answer = "";
        for (int i = 0; i < input.length(); i++) {
            char c = input.charAt(i);
            if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
                answer = answer + (char) (c + 1);
            } else {
                answer = answer + c;
            }
        }
        System.out.println(answer);
    }

}

Question 8.
Design a class to overload a function compare ( ) as follows: [15]
(a) void compare (int, int) – to compare two integer values and print the greater of the two integers.
(b) void compare (char, char) – to compare the numeric value of two character with higher numeric value
(c) void compare (String, String) – to compare the length of the two strings and print the longer of the two.

Ans.

public class Overloading {

    public void compare(int a, int b) {
        int max = Math.max(a, b);
        System.out.println(max);
    }

    public void compare(char a, char b) {
        char max = (char) Math.max(a, b);
        System.out.println(max);
    }

    public void compare(String a, String b) {
        if (a.length() > b.length()) {
            System.out.println(a);
        } else if (a.length() < b.length()) {
            System.out.println(b);
        } else {
            System.out.println(a);
            System.out.println(b);
        }
    }
}

Question 9
Write a menu driven program to perform the following . (Use switch-case statement) [15]
(a) To print the series 0, 3, 8, 15, 24 ……. n terms (value of ‘n’ is to be an input by the user).
(b) To find the sum of the series given below:
S = 1/2+ 3/4 + 5/6 + 7/8 … 19/20

Ans.

Series 1 : The ith term is i2-1.

import java.util.Scanner;

public class Menu {

    public void series1(int n) {
        for (int i = 1; i <= n; i++) {
            int term = i * i - 1;
            System.out.print(term + " ");
        }
    }

    public double series2(int n) {
        double sum = 0;
        for (int i = 1; i <= n; i++) {
            sum = sum + (double) (2 * i - 1) / (2 * i);
        }
        return sum;
    }

    public void menu() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("1. Print 0, 3, 8, 15, 24... n tersm");
        System.out.println("2. Sum of series 1/4 + 3/4 + 7/8 + ... n terms");
        System.out.print("Enter your choice: ");
        int choice = scanner.nextInt();
        System.out.print("Enter n: ");
        int n = scanner.nextInt();
        switch (choice) {
            case 1:
                series1(n);
                break;
            case 2:
                double sum = series2(n);
                System.out.println(sum);
                break;
            default:
                System.out.println("Invalid choice");
        }
    }

    public static void main(String[] args) {
        Menu menu = new Menu();
        menu.menu();
    }
}

9 thoughts on “ICSE Class 10 Computer Applications ( Java ) 2011 Solved Question Paper

  1. Yashvi Kandoi

    What is the answer to question 9, series one of the 2011 icse board paper of computer science of class 10?

    Reply
    1. ICSE Java Post author

      The series is 0, 3, 8, 15, 24. We have incorrectly mentioned it as 0, 3, 7, 15, 24. The error has been corrected and the solution has also been updated.

  2. leharika

    Sir,in Q3 a) once p is evaluated to 100 then wont the condition(p<100)turn false?how is p again deducted to 80?I am not understanding..kindly help…

    Reply
    1. ICSE Java Post author


      while(true){
      if (p<100)
      break;
      p=p-20;
      }

      Consider the iteration when p is 120. p < 100 i.e. 120 < 100 is false, so break will not be excuted. The statement p = p - 20 will make p 100.

      When p becomes 100, the condition p <100 is false. ( 100 is not less than 100. 100 is equal to 100 ) . As the 'if' condition is false, the break statement won't be executed. The statement p = p - 20 will be executed which will reduce p to 80.

      Now, p < 100 i.e. 80 < 100 is true. So, the break statement will be executed and control will come out of the loop.

  3. Mandarin

    ICSE Computers 2011: Question 6 (Program to check for special no.) :

    The program given is incorrect. There is no need to find sum of digits. Instead, we have to find sum of factorials of digits.

    Reply
  4. tulip

    Answer to Q-3 d part is incorrect because sentence and word is not a return type . Return type should be String.

    Reply
    1. Ranjith Post author

      ‘sentence’ and ‘word’ are class types as per the question.

      The question says
      … receives a sentence sentnc …
      According to the question, sentence is a class type and the variable accepted by the method is sentence of type sentnc.

Leave a Reply

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


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>