ICSE Computer Applications Question Paper Solved for Class 10

Solving ICSE Class 10 Computer Applications Previous Year Question Papers ICSE Class 10 Computer Applications Question Paper 2012 is the best way to boost your preparation for the board exams.

ICSE Class 10 Computer Applications Question Paper 2012 Solved

[Section – A (40 Marks)]
(Attempt all Questions)

Question 1.
(a) Give one example each of a primitive data type and a composite data type [2]
Answer:
ICSE 2012 Computer Applications Question Paper Solved for Class 10 1

ICSE 2012 Computer Applications Question Paper Solved for Class 10

(b) Give one point of difference between unary and binary operators. [2]
Answer:

Uniary Operators Binary Operators
The operators which act upon a single operand are called unary operators. The operators which require two operands for their action are called binary operators.
They are preincrement and post increment (++) They are mathematical operators and relational operators.

(c) Differentiate between call by value or pass by value and call by reference or pass by reference. [2]
Answer:
Pass by reference means, passing the address itself rather than passing the value. Pass by value means passing a copy of the value.
Primitive data types are always passed by call by value whereas all objects, arrays are passed by call by reference.

(d) Write a Java expression for \(\sqrt{2 a s+\mu^2}\) [2]
Answer:
y = Math.sqrt(2*a*s+Math.pow(u,2)) ;

(e) Name the type of error (syntax, runtime or logical error) in each case given below:
(i) Division by a variable that contains a value of zero.
(ii) Multiplication operator used when the operation should be division.
(iii) Missing semicolon. [2]
Answer:
(i) Runtime error
(ii) Logical error
(iii) Syntax error

Question 2.
(a) Create a class with one integer instance variable. Initialize the variable using:
(i) default constructor.
(ii) parameterized constructor. [2]
Answer:
class IntegCons {
int num;
//default constructor IntegConsO {
num = 0; //initialization of variable
}
//parameterized constructor
IntegCons(int n) {
num = n;
}
}

(b) Complete the code below to create an object of Scanner class.
Scanner sc = _________ Scanner (_________).
(ii) parameterized constructor. [2]
Answer:
Scanner sc = new Scanner(System.in);

(c) What is an array ? Write a statement to declare an integer array of 10 elements. [2]
Answer:
An array is a series of elements of the same type placed in contiguous memory locations that can be individually referenced by adding an index to a unique identifier.
int number = new int[10];

ICSE 2012 Computer Applications Question Paper Solved for Class 10

(d) Name the search or sort algorithm that:
(i) Makes several passes through the array, selecting the next smallest item in the array each time and placing it where it belongs in the array.
(ii) At each stage, compares the sought key value with the key value of the middle element of the array. [2]
Answer:
(i) Selection Sort
(ii) Binary Search

(e) Differentiate between public and private modifiers for members of a class. [2]
Answer:
Access specifiers are keywords that determine the type of access to the member of a class. These keywords are for allowing privileges to parts of a program such as functions and variables.
Public: accessible to all classes
Private : accessible only to the class to which they belong.

Question 3.
(a) What are the values of x and y when the following statements are executed ? [2]
int a = 63, b = 36;
boolean x=(a>b)? true false;
int y = (a<b)?a:b;
Answer:
(i) True
(ii) 36

(b) State the values of n and ch. [2]
char c = ‘A’;
int n = c+I;
char ch = (char)n;
Answer:
66

(c) What will be the result stored iri x after evaluating the following expression ? [2]
in x = 4; x+=(x++)+(++x)+x;
Answer:
20

(d) Give the output of the following program segment: double x = 2.9, y = 2.5;
System.out.println(Math.min(Math. floor(x),y));
System.out.println(Math.max(Math. ceil(x),y)); [2]
Answer:
(i) 2.0
(ii) 3.0

(e) State the output of the following program segment.
String s=”Examination
int n=s.length():
System.out.println(s.startsWith(s. substring(5,n)));
System.out.println(s.charAt(2)==s. charAt(6)); [2]
Answer:
(i) false
(ii) false

(f) State the method that:
(i) Converts a string to a primitive float data type
(ii) Determines if the specified character is an uppercase character. [2]
Answer:
(i) Float.valueOf()
(ii) isUpperCase() Method

ICSE 2012 Computer Applications Question Paper Solved for Class 10

(g) State the data type and values of a and b after the following segment is executed.
String si=”Computer”,
s2=”Applications”;
a =(s1.compareTo(s2));
b =(s1.equals(s2));
Answer:
Data type of a is int and for b is boolean. a = 2, b = false

(h) What will the following code output ? [2]
String s=”malayalam”;
System. out.println(s. indexOff(‘m’));
System. outprintln(s. lastlndexOff(‘m’));
Answer:
(i) 0
(ii) 8

(i) Rewrite the following program segment using while instead of for statement, [2]
int f = I, i; ,
for(i = 1; i <= 5; i++)
{f*=i; System.out.println(f);} [2]
Answer:
int f = 1;
int i = 1;
while(i<=5) {
f*= i;
System.out.println(f);
i++;
}

(j) In the program given below, state the name and the value of the
(i) method argument or argument variable
(ii) class variable
(iii) local variable
(iv) instance variable
class myClass {
static int x = 7;
int y=2;
public static void main(String args[]){
myClass obj = new myClass();
System.out.println(x);
obj.sampleMethod(5);
int a = 6;
System.out.println(a);
}
void sampleMethod(int n) {
System.out.println(n);
System.out.println(y);
}
}
Answer:
(i) method argument = int n
(ii) class variable = static int x;
(iii) local variable = int a;
(iv) instance variable = int y;
Output of the program-
7
5
2
6

ICSE 2012 Computer Applications Question Paper Solved for Class 10

Section – B (60 Marks)
(Attempt any Four questions from this section)

Question 4.
Define a class called Library with the following description :
Instance variables/data members :
int acc_um – stores the accession number of the book
String title – stores the title of the book
String author – stores the name of the author

Member methods:
(i) void input()To input and store the accession number, title and author.
(ii) void compute()To accept the number of days late, calculate and display the fine charged at the rate of Rs. 2 per day.
(iii) void display()To display the details in the following format:
Accession Number Title Author
Write a main method to create an object of the class and call the above member methods. [15]
Answer:

import java.io.*;
class Library {
int acc_num;
String title;
String author;
static int days;
static double fine;
void input(int num, String tit, String auth) {
acc_num = num;
title=tit;
author=auth;
}
static void compute(int d){
days = d;
System.out.println("Enter the number of days (late days)" + days);
fine = days*2;
System.out.println("Fine is=" +fine);
}
public void display() {
System.out.println("Accession Number" + "\t" + "Title"+ "\t" + "Author");
System.out.println(acc_num + "\t" +title +"\t" + author);
}
public static void main(String args[]) throws IOException {
BufferedReader reader = new
BufferedReadeifnew InputStreamReader(System.in));
Library lib = new Library();
System.out.println("Enter the number of days (late days)");
String a = reader.readLine();
int d = Integer.parselnt(a);
lib.compute(d);
}
}

ICSE 2012 Computer Applications Question Paper Solved for Class 10

Question 5.
Given below is a hypothetical table showing rates of Income Tax for male citizens below the age of 65 years:

Taxable Income (TI) in Rs. Income Tax in Rs.
Does not exceed Rs. 1,60,000 Nil
Is greater than Rs. 1,60,000 & less than or equal to Rs. 5,00,000 (TI-1,60,000) × 10%
Is greater than Rs. 5,00,000 & less than or equal to Rs. 8,00,000 [(TI – 5,00,000) × 20%] + 34,000
Is greater than Rs. 8,00,000 [(TI – 8,00,000) × 30%] + 94,000

Write a program to input the age, gender (male or female) and Taxable Income of a person.
If the age is more than 65 years or the gender is female, display “wrong category”.
If the age is less than or equal to 65 years and the gender is male, compute and display the Income Tax payable as per the table given above. [15]
Answer:

import java.io.*;
class IncomeTax {
public static void main(String args[]) throws IOException{
int age;
int gender;
double income;
double tax;
double p,d,net;
String name,address;
System.out.println("********* INCOME TAX **********");
System.out.println("Enter Age of the Person::");
InputStreamReader reader = new InputStream Reader(System.in);
BufferedReader input = new Buffered Reader(reader);
String x = input.readLine();
age = Integer.parselnt(x);
System.out.println("Enter Income of the Person::");
String y = input.readLine();
income=Double.parseDouble(y);
System.out.println("M. Enter M for Male");
System.out.println("F. Enter F for Female");
System.out.println();
System.out.println("Enter your choice::");
char choice;
choice=(char)System.in.read();
switch(choice) {
case 'M': if(age<=65 && income<=160000) {
System.out.println("Tax Amount - Nil");
}
else if(age<=65 && income>160000 && income<=500000){
tax=(income-160000)*0.1;
System.out.println("Income Tax in Rupees=" +tax);
}
else if(age<=65 && income> 500000 && income <= 800000) {
tax=(income-500000)*0.2+34000;
System.out.println("____________");
System.out.println("Income Tax in Rupees=" +tax);
System.out.println("____________");
}
else if(age<=65 && income>800000) {
tax=(income-800000)*0.3+64000;
System.out.println("Income Tax in Rupees-' +tax);
}
break;
case 'F': if(age>65) {
System.out.println("____________");
System.out.println("Wrong Category");
System.out.println("___________");
}
break;
}
}
}

Question 6.
Write a program to accept a string. Convert the string to uppercase. Count and output the number of double letter sequences that exist in the string.
Sample Input: “SHE WAS FEEDING THE LITTLE RABBIT WITH AN APPLE” [15]
Answer:

import java.io.*;
public class DoubleLetter {
public static void main(String args[]) throws IOException {
InputStreamReader reader
= new InputStreamReader(System.in);
BufferedReader in
= new BuflferedReader(reader);
int x,y;
x=0;
y=0;
int count=0;
String a;
char ch1, ch2;
System.out.println(“Enter String::”);
a=in.readLine();
x=a.length0; if(a = null)
return;
String strUpper = a.toUpperCase();
System.out.println("Original String:" +a);
System.out.println("String changed to uppercase: "+ strUpper);
for(y=0;y<x-1;y++) {
ch1=strUpper.charAt(y);
ch2=strUpper.charAt(y+1);
if((int)ch1=(int)ch2)
System.out.println(ch1 +" " +ch2 +" is a duplicate sequence");
}
}
}

ICSE 2012 Computer Applications Question Paper Solved for Class 10

Question 7.
Design a class to overload a Junction polygonQ as follows :
(i) void polygon(int n, char ch) with one integer argument and one character type argument that draws a filled square of side n using the character stored in ch.
(ii) void polygon(int x, inty) with two integer arguments that draws a filled rectangle of length x and breadth y, using the symbol ‘@’
(iii) void polygon() with no argument that draws a filled triangle shown below.

Example:
(i) Input value of n-2, ch=’O’
ICSE 2012 Computer Applications Question Paper Solved for Class 10 2

(ii) Input value of x = 2, y=5
Output:
@@@@@
@@@@@

(iii) Output:
*
* *
* * *
Answer:

import java.io.*;
class Polygon {
void polygon(int n,char ch) throws IOException {
for(int i=1; i<=n; i++) {
System.out.println();
for(int j=1 y <=n; j++) {
System.out.print(ch);
}
}
}
void polygon(int x, int y) {
for(int i=1;i<=x; i++) {
System.outprintln();
for(int j=1 y<=y; j++) {
System.out.print("@" + " ");
}
}
}
void polygon() {
for(int i=1; i<4; i++) {
System.out.println();
for(int j=l; j<=i; ++j) {
System.out.print("*" + " ");
}
}
}
}

Question 8.
Using the switch statement, write a menu driven program to :
(i) Generate and display the first 10 terms of the Fibonacci series 0, 1, 1, 2, 3, 5 ………………
The first two Fibonacci numbers are 0 and 1, and each subsequent number is the sum of the previous two.

(ii) Find the sum of the digits of an integer that is input. [15]
Sample Input: 15390
Sample Output: Sum of the
digits=18
For an incorrect choice, an appropriate error message should be displayed.
Answer:

import java.io.*;
class UseSwitch {
public static void main(String args[]) throws IOException {
int ch;
int n=0, j;
double m;
InputStreamReader read = new Input StreamReader(System.m);
BufferedReader in = new Buffered Reader(read);
System.out.println("l. Series 1");
System.out.println("2. Series 2");
System.out.println("Enter your choice");
ch = Integer.parseInt(in.readLine());
System.out.println("Enter die number try {
DatalnputStream d = new Datalnput Stream(System.in);
n=Integer.parseInt(d.readLine());
}
catch(Exception e) {
System.out.println("Input Error!");
System.exit(0);
}
switch(ch){
case 1:
int a=0, b=1,c,i;
System.out.println("Fibonacci Series is \n" +a);
System.out.println(b);
for(i=!;i<=n-2;i-H-) {
c=a+b;
System.outprintln(c);
a=b;
b=c;
}
break;

case 2:
System.out.println("Sum of Digits of the Number ");
{
int q=1, s=0;
for(; q!=0;) {
int r = n%10;
q = n/10;
n = q;
s = s + r;
}
System.out.print(s);
}
break;
default:
System.out.println("Wrong choice");
}
}
}

ICSE 2012 Computer Applications Question Paper Solved for Class 10

Question 9.
Write a program to accept the names of 10 cities in a single dimension string array and their STD (Subscribers Trunk Dialing) codes in another single dimension integer array. Search for a name of a city input by the user in the list. If found, display “Search Successful” and print the name of the city along with its STD code, or else display the message “Search Unsuccessful, No such city in the list”. [15]
Answer:

import java.io.*;
class NameCity {
private String a[] = new String[10];
private int b[] = new int[10];
public void inputdata(String name[], int std[]) {
for(int i=0; i<name.length;i++)
a[i]=name[i];
for(int j=0; j<std.length;j++)
b[j]=std[j];
}
public void data() thrdws IOException {
boolean value = false;
System.out.println("Enter City You want to Search");
BufferedReader reader = new Buffered Reader(new InputStream Reader(System.in));
String x = reader.readLine();
for(int i=0; i<10; i++) {
if(x.compareTo(a[i]) = 0) {
value = true;
System.out.println("Search Successful!");
System.out.println("Name of the city is ::" + a[i]);
System.out.println("STD Code of" +a[i] + " is ::" +b[i]);
}
}
if(value == false){
System.out.println("Search Unsuccessful. No Such city in the list");
data();
}
}
}