Posted Date: 25 Sep 2008      Posted By:: jawad    Member Level: Silver  Points: 5 (Rs. 1)

# 2008 ICSE Computer Applications sample paper 2008 Question paper

 Course: SSLC University/board: ICSE

ICSE Sample Paper - 2008
Computer Science
Class - X

COMPUTER APPLICATIONS- Solution 2006 TYPE

(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 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). Define encapsulation.

Encapsulation is one of the core concepts of Object Oriented Programming. It is the binding or the wrapping up of variables and functions.

(b). Explain the term object using an example.

An object is an instance of a class.

(c). Define a variable.

A variable is a memory location by a particular name.

(d). What is a wrapper Class? Give an example.

A Wrapper Class is a primitive data type. Example could be Integer, Character etc.

(e). What is the purpose of the new operator? [10]

A new operator is used to create an Object or an array.

Question 2

(a). State two kinds of data types.

The two kinds of Data Types are:

(i). Primitive
(ii). Non-Primitive Data Types.

(b). Write the corresponding expressions for the following mathematical operations:-

(i). a2 + b2

Math.pow(a,2) + Math.pow(b,2);

(ii). z= x3 + y3 - xy/ z

z = Math.pow(x,3) + Math.pow(y,3) - (x * y) / z;

(iii). Define an impure function.

An impure function is a function which changes the state of an object.

(iv). Differentiate between if and switch statements.

Switch accepts only int or character whereas if accepts any data type accordingly.

Switch statement supports equality whereas the if statement supports all other relations accordingly.

Switch examines only one condition whereas if can examine multiple conditions.

(v). What will be the output for the following program segment?

String s = new String(“abc”);
System.out.println(s.toUpperCase( )); [10]

ABC

[READ S.Chand Question Bank for ICSE by Dheeraj Mehrotra]

Question 3

(a). What is meant by private visibility of a method? [2]

The private visibility of a method means that the method can not be accessed outside the class.
(b). Find and correct the errors in the following program segment:-
int n[ ] = (2,4,6,8,10);
for (int i = 0;i<=5;i++)
System.out.println(“n[“+ i +”] + n[i]); [2]

int n[ ] = { 2,4, 6, 8, 10};
for (int i = 0; i<5; i++)
System.out.println(“n[“+i+”]”+n[i]);

It is same as Implementing Polymorphism.It is a feature that allows one interface to be used for general class of actions. The specific action is determined by the exact nature of the situation. More generally the concept of polymorphism is often expressed by the phrase “one interface, multiple methods”.

worktodo(int a, int b);
worktodo(int a);

[READ S.Chand Question Bank for ICSE by Dheeraj Mehrotra]

(d). Find the output of the following program segment, when:

(i). val = 500
(ii). val = 1600

int val, sum, n=550;
sum = n + val > 1750 ? 400 : 200;
System.out.println(sum); [2]

(i). 200

(ii). 400

if precedence is not considered:

(i). 750
(ii). 750

(e). What is a default constructor? [2]

A default constructor has no arguments, it has the same name as that of the class and is used to initialize instance variables with default values.

(f). What will be the output for the following program segment?

int a = 0,b=30,c=40;
a = --b + c++ + b; [2]
System.out.println(“a = “ +a);

a = 98.

[READ S.Chand Question Bank for ICSE by Dheeraj Mehrotra]

(g). Differentiate between compareTo( ) and equals( ) methods. [2]

compareTo( ) method is used to check less than/ greater than conditions where as equals( ) checks only equality.

(h). What is a package? Give an example. [2]

A package is a collection of related types providing access protection and name space management.
Example: io, lang, util etc.

(i). Explain the function of a return statement. [2]

The return statement returns a value to the calling method within the program. It is also used to terminate the execution of a function.

SECTION B (60 Marks)
Attempt 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 descriptions/ Mnemonic Codes such that the logic of the program is
clearly depicted.
Flow-Charts and Algorithms are not required.

[READ S.Chand Question Bank for ICSE by Dheeraj Mehrotra]

Question 4

Write a program to calculate and print the sum of odd numbers and the sum of even numbers for the first n natural numbers.
The inteter n is to be entered by the user. [15]

Solution:

Class numbers
{
int sumeven=0;
int sumodd = 0;
public void work(int n)
{
for (int i=1; i {
if (i%2 == 0)
sumeven = sumeven+i;
else
sumodd = sumodd + i;
}
System.out.println(“Sum of odd numbers is “+sumodd;
System.out.println(“Sum of even numbers is “+sumeven;
}
}

[READ S.Chand Question Bank for ICSE by Dheeraj Mehrotra]

Question 5

A cloth showroom has announced the following festival discounts on the purchase of items, based on the total cost of the items purchased: -
Total Cost Discount (in Percentage)

Less than Rs. 2000 5%
Rs. 2001 to Rs. 5000 25%
Rs. 5001 to Rs. 10000 35%
Above Rs. 10000 50%

Write a program to input the total cost and to compute and display the amount to be paid by the customer after availing the discount. [15]

Solution:

class abcd
{
public void check(int totalcost)
{
double cost = 0, amount = 0, discount = 0;
if (totalcost<=2000)
discount = 5;
else if (totalcost<=5000)
discount = 25;
else if (totalcost<10000)
doscount = 35;
else
discount = 50;
amount = totalcost - totalcost*discount/ 100;
System.out.println(“The Amount being paid by the customer is “+ amount);
}
}

Question 6

Consider the following statement:-
“January 26 is celebrated as the Republic Day of India”.

Write a program to change 26 to 15, January to August, Republic to Independence and finally print “August 15 is celebrated as the Independence Day of India”. [15]

SOLUTION:

public class replace
{

public void convert()
{
String str="26 january is celebrated as republic day ";
String sent="";
String newstring="";
int len=str.length();
for(int i=0;i {
char b=str.charAt(i); //extract characters
if(b!=' ') // till we do not get a space add characters to sent
sent=sent+b;
else
{ // compare the word extracted with the words to be changed
int c=sent.compareTo("26");

int d=sent.compareTo("republic");
int e=sent.compareTo("january");
if(c==0) // if the word exist replace with given words
newstring=newstring+" 15 ";
else if(d==0)
newstring=newstring+" independence ";
else if(e==0)
newstring+=" "+" august ";
else // otherwise add the word as it is to newstring
newstring+=" "+sent;
sent="";
}
}
System.out.println(newstring);
}
}

Question 7

Write a program that outputs the results of the following evaluations based on the number entered by the user.

(i). Natural Logarithm of the number.
(ii). Absolute value of the number.
(iii). Square root of the number.
(iv). Random numbers between 0 and 1. [15]

SOLUTION:

class random
{
public void numbers()
{
System.out.println("1. Natural Logarithm");
System.out.println("2. Absolute Value");
System.out.println("3. Square Root");
System.out.println("4. Random Numbers between 0-1");
System.out.println("Enter choice and a number");
}
/* Enter choice and number */
public void calculate(int choice, double number)
{
double n;
switch(choice)
{
case 1: n = Math.log(number);
System.out.println("The result is "+n);

break;
case 2: n = Math.abs(number);
System.out.println("The result is "+n);

break;
case 3: n = Math.sqrt(number);
System.out.println("The result is "+n);

break;
case 4: n = Math.random();
System.out.println("The result is "+n);

break;
}
}
}

Question 8

The marks obtained by 50 students in a subject are tabulated as follows:

Name Marks
* *
* *
Write a program to input the names and marks of the students in the subject.

Calculate and display:-

(i). The subject average marks (subject average marks = subject total / 50 )

(ii). The highest mark in the subject and the name of the student.
(The maximum marks in the subject are 100) [15]

Solution:

class highest
{

// enter name and percentage of 50 children.

String n;

int high=0; // To store the highest percentage.
public void calculate(String nam[],int perc[])

{

for(int i=0;i {
// To find the highest percentage and similarly store the name
// in N.
if(perc[i]>high)
{
high=perc[i];
n=nam[i];
}
}
System.out.println("highest percentage :"+high);
System.out.println("name of the child :"+n);
}
}

Question 9

Write a program to accept 15 integers from the keyboard, assuming that no integer entered is zero. Perform selection sort on the integers and then print them in ascending order. [15]

Solution:

class array
{// input 15 integers
public void compute(int a[])
{
// selection sorting
for(int i=0;i {
for(int j=i+1;j {
if(a[i]>a[j])
{
int t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
// display
for(int i=0;i System.out.println(a[i]);
}
}

### Related Question Papers:

• B.COM PART 1- ECONOMIC ENVIRONMENT

• CBSE SOCIAL STUDIES SET-3

• CBSE SOCIAL STUDIES SET-2

• CBSE SOCIAL STUDIES SET-1

• CBSE SCIENCE

• ### Categories

Submit Previous Years University Question Papers and make money from adsense revenue sharing program

Are you preparing for a university examination? Download model question papers and practise before you write the exam.

### Subscribe to Email

• Get Jobs by Email
• Forum posts by Email
• Articles by Email