ICSE Computer Applications Question Paper 2007 Solved for Class 10

ICSE Computer Applications Previous Year Question Paper 2007 Solved for Class 10

ICSE Paper 2007
COMPUTER APPLICATIONS

(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 any 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)

Question 1:
(a) Name two types of Java Programs. [2]
(b) Define Instance Variable. Give an example of the same. [2]
(c) Differentiate between Binary Search and. Linear Search. [2]
(d) Assign the value of pie (i.e. 3.142) to a variable with requisite data type. [2]
(e) Explain with an example the if-else-if construct. [2]

Answer:
(a) Two types of Java Programs:
(i) Java applets
(ii) Java applications

(b) Instance variables are variables that are created for each instance of a class. These variables represent property/state of object.
e.g.
class text
{
int data 1; // These are instance
int data 2; // variables
:
:
}

(c) Binary Search—Array should be sorted before and less iteration required.
Linear Search—Array may or may not be sorted before and large number of iterations required.

(d) double pie=3.142;

(e) if (a>b && a>c)
System.out.println (a):
else if (b>a && b>c)
System.out.println(b);
else
System.out.println(c);

Question 2:
(a) Differentiate between Formal Parameter and Actual Parameter.
(b) Why do we need a constructor as a class member ?
(c) Explain the term type casting.
(d) Name of following :
(i) A package that is invoked by default.
(ii) A keyword, to use the classes defined in package.
(e) Name the class that is used for different mathematical functions. Give an example of a mathematical function. [10]

Answer:
(a) The parameter listed in the function prototype are termed as the formal parameters whereas the parameter used in the function call statement are the actual parameters.

(b) We need a constructor as a class member to initialize value for a class variable arid to create objects.

(c) Type Casting: Explicit Conversion of one data type to another is called type casting. It is done by type casting operators.
Example:
int a;
double b = 9.8
a = (int) b;

(d) (i) java.lang;
(ii) import

(e) Math class is used for mathematical function.
E.g. sqrt(), abs();

Question 3:
(a) State the difference between = and ==. [2]

(b) Write an equivalent Java Syntax for the following expression:
\(a=\frac { 0.05-2{ y }^{ 3 } }{ x-y } \) [2]

(c) Rewrite the following using ternary operator:
if (income < = 10000)
tax = 0;
else
tax = 12; [2]

(d) Write a statement for each of the following :
(i) Store a number 275 as a string.
(ii) Convert the string to a numeric value.
(iii) Add it to the existing total of 1000 to update the total. [3]

(e) (i) What is the role of the keyword void in declaring functions ?
(ii) If a function contains several return statements, how many of them will be executed ?
(iii) Which OOP principle implements function overloading ? [3]

(f) What is the output of the following :
(i) System.out.println (“four:” + 4 + 2);
System.out.println (“four:” + (2+2)); [2]
(ii) String S1 = “Hi”;
String S2 = “Hi”;
String S3 = “there”;
String S4 = “HI”;
System.out.println (S1 + “equals” + S2 + “→” + S1.equals(S2));
System.out.println (S1 +“equals” + S3 + “→” + S1.equals(S3));
System.out.println (S1 +“equals” + S4 + “→” + S1.equals(S4));
System.out.println (S1 + “EquallgnoreCase” + S4 + “→” + S1.EqualsIgnoreCase(S4)); [4]

(g) Evaluate the following expressions, if the values of the variables are a = 2, b = 3 and c = 9.
(i) a – (b++) *( – – c)
(ii) a * (++b) % c [2]

Answer:
(a) = is an assignment operator. Used to a assign value into variable.
== is an relational operator. Used to compare two values for equality.

(b) a=(0.05 – (2*y*y*y))/(x – y)

(c) tax=income <=10000 ? 0 :12;

(d) (i) String s=“275”;
(ii) int a=Integer.parseInt(s);
(iii) total=1000+a;

(e) (i) void—This keyword indicates that the function will not return value.
(ii) one
(iii) polymorphism

(f) (i) four:4 2
four:4
(ii) HiequalsHiTrue → True
Hiequalsthere → False
HiequalsHI → False
HiEqualsIgnoreCaseHI → True

(g) (i) 2 – 3*8
2-24
-22
(ii) 2 * 4 % 9
8 % 9
8

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 salary described as below :
Data Members: Name, Address, Phone, Subject Specialisation, Monthly Salary, Income Tax.
Member methods:
(i) To accept the details of a teacher including the monthly salary.
(ii) To display the details of the teacher.
(iii) To compute the annual Income Tax as 5% of the annual salary above Rs. 1,75,000/-.
Write a main method to create object of a class and call the above member method. [15]

Answer:
import java.io.*;
class salary
{
String name, address, phone, subject;
double salary, it;
void get(String na, String add, String ph, String sub, double sal)
{
name=na;
address=add;
phone=ph;
subject=sub;
salary=sal;
}
void display()
{
System.out.println (“Name=”+name);
System.out.println (“Address=”+address);
System.out.println (“Phone Number =”+phone);
System.out.println (“Subject Specialization =”+subject);
System.out.println (“Monthly Salary=”+salary);
System.out.println (“Income Tax=”+it);
}
void compute()
{
if((salary*12)>175000)
it=0.05*(salary*12);
else
} it=0;
}
class callsalary
{
public static void main(String[ ]args)throws IOException
{
InputStreamReader IR=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(IR);
salary obj=new salary();
String na,add,ph,sb;
double sal;
System.out.print(“Enter the Name”);
na=br.readLine();
System.out.print(“Enter the Address”);
add=br.readLine();
System.out.print(“Enter the Phone Number”);
ph=br.readLine();
System.out.print(“Enter the Subject Specialization”);
sb=br.readLine();
System.out.print(“Enter the Monthly Salary”);
sal=Double.parseDouble(br.readLine());
obj.get(na,add,ph,sb,sal);
obj.compute();
obj. display();
}
}

Question 5:
Write a program to compute and display the sum of the following series:
icse-previous-papers-with-solutions-for-class-10-computer-applications-2007-1

Answer:
class series
{
public static void main (int num)
{
double s=0;
double n=1;
double d=1;
for(int i=2; i<=num; i++)
n=n+i;
d=d*i;
s=s+n/d;
}
System.out.println(“The Sum of the series is”+s);
}
}
import java.io.*;
class series
{
public static void main() throws IOException
{
InputStreamReader IR=new InputStreamReader(System.in);
BufferedReader br=new BufFeredReader(IR);
int num;
System.out.print(“Enter the Limit of Series:”);
num=Integer.parseInt(br.readLine());
double s=0;
double n=1;
double d=1;
for(int i=2; i<=num; i++)
{
n=n+i;
d=d*i;
s=s+n/d;
}
System.out.println(“The Sum =” +s);
}
}

Question 6:
Write a program to initialize 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  [15]

Answer:
class maxmin
{
public static void main()
{
int [ ]n = {2,5,4,1,3};
int h=n[0];
int l=n[0];
int s=0;
for(int i=0; i<n.length; i++)
{
if(h<n[i])
{
h=n[i]
}
if(l<n[i])
{
l=n[i];
}
s=s+n[i];
}
System.out.println(“Minimum Value :”+l);
System.out.println(“Maximum Value :”+h);
System.out.println(“The Sum of the elements :”+s);
}
}

Question 7:
Write a program to enter a sentence from the keyboard and count the number of times a particular word occurs in it. Display the frequency of the search word.
Example:
INPUT:
Enter a sentence : the quick brown fox jumps over the lazy dog.
Enter a word to be searched : the
OUTPUT :
Searched word occurs : 2 times. [15]

Answer:
import java.io.*;
class abc
{
public static void main() throws IOException
{
InputStreamReader ir=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(ir);
String str, word, wrd=“ ”;
char ch;
int c=0;
System.out.println(“Enter A sentence”);
str=br.readLine( );
str=str.trim( );
System.out.println(“Enter a word to be searched”);
word=br.readLine( );
str=str + “ ”;
for(int i=0; i<str.length( ); i++)
{
ch=str.charAt(i);
if (ch! = ‘ ’)
{
wrd=wrd+ch;
}
else
{
if(word.equals(wrd))
{
c++;
}
wrd=“ ”;
}
}
System.out.println(“searched word occurs”+c);
}
}

Question 8:
Using a switch statement, write a menu driven program to convert a given temperature from Fahrenheit to Celsius and vice versa. For an incorrect choice, an appropriate error message should be displayed.
(HINT : C = \(\frac { 5 }{ 9 } \) × (F – 32) and F = 1.8 × (C + 32) [15]

Answer:
import java.io.*;
class Temp
{
public static void main(String arg[ ])throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int choice;
double f=0, c=0;
System.out.println(“Menu”);
System.out.printing(“Fahrenheit to Celsius”);
System.out.println(“2.Celsius to Fahrenheit”);
System.out.println(“3.Wrong choice.Re-enter”);
System.out.println(“Enter your choice(l-3):”);
choice=Integer.parseInt(br.readLine());
switch(choice)
{
case 1 : System.out.println(“Enter the value of Fahrenheit”);
f=Double.parseDouble(br.readLine());
c=5/9 * (f-32);
System.out.println(“Temperature Fahrenheit to Celsius =”+c);
break;
case 2 : System.out.println(“Enter the value of Celsius”);
c=Double.parseDouble(br.readLine());
f=1.8*(c+32);
System.out.println(“Celsius to Fahrenheit =”+f);
break;
default :
System.out.println(“Wrong choice! Re-enter”);
break;
}
}
}

Question 9:
Write a program using a method Palin(), to check whether a string is a Palindrome or not. A Palindrome is a string that reads the same from left to right and vice versa.
E.g. MADAM, ARORA, ABBA, etc. [15]

Answer:
class palin
{
public static void palin(String s)
{
int l=s.length();
int i, j=l-1;
int x=0;
for(i=0; i<l/2; i++)
{
if(s.charAl(i)!=s.charAt(j))
{
x=l; break;
}
j – – ;
}
if(x==0)
{
System.out.println(“The word is Palindrome”);
}
else
{
System.out.println(“The word is not Palindrome”);
}
}

ICSE Class 10 Computer Applications Previous Years Question Papers

Leave a Comment