ICSE Class 10 Computer Applications Sample Question Paper 1 with Answers

ICSE Class 10 Computer Applications Sample Question Paper 1 with Answers

Section – A [40 Marks]
Attempt all questions

Question 1
(a) Name any four tokens of Java. [2]
(b) Give the difference between actual parameter and formal parameter. [2]
(c) What is an identifier? [2]
(d) Write an expression in Java for sin x + √a2+ b3. [2]
(e) What is the result produced by 2 – 10*3 + 100/11 ? Show the steps. [2]
Answer:
(a) Integer, boolean, double and character.

(b) Formal parameters are used in the function definition and Actual parameters are used when function is being called.

E.g. void sum(int a, int b) // a and b are formal parameters
{
System.out.println(a+b);
}
Public static void main( )
{
Sum(2,4); // 2,4 are actual parameters.
}

ICSE Class 10 Computer Applications Sample Question Paper 1 with Answers

(c) Identifiers are names of the variables, strings, classes and packages. Its values can change throughout the program.

(d) sin(x) + Math.sqrt(a*a + b*b*b);

(e) Step 1:2- 10*3 + 9
Step 2:3 – 30 + 9
Step 3: 3 – 21
Step 4: – 19

Question 2
(a) What is the difference between local variable and instance variable? [2]
(b) intx = 20, y = 10, z;
What is the value of z
in z = ++x * (y –     – y ?
Show the steps. [2]
(c) What is the purpose of default in a switch? [2]
(d) Give the difference between linear search and binary search. [2]
(e) What will be the output of the following code?
float x = 7.87;
System.out.println(Math.ceil(x));
System.out.println(Math.floor(x)); [2]
Answer:
(a)

Local Variable Instance Variable
Its scope remains inside a function or the block. Its scope remains throughout the methods of the class.
Multiple copies of this variable are used throughout the program. Every object has separate copies of this variable.

ICSE Class 10 Computer Applications Sample Question Paper 1 with Answers

(b) int x =20, y = 10, z;
z = ++x * (y – – y )- y?
Step 1:21 * 10 – 9
Step 2: 210 – 9
Step 3: 201

(c) Default in the switch statement means when no matching case is encountered by the controller it executes the default case.

(d)

Linear Search Binary Search
It compares each element of the array with rest of the elements in the array. It’s based on divide and conquer rule. Array is sorted in this search. Element is searched only in the selected halves.

e. 8.0
7.0

ICSE Class 10 Computer Applications Sample Question Paper 1 with Answers

Question 3.
(a) State the difference between if-else if ladder and switch…case. [2]
Answer:

If-else Ladder Switch Case
Works on more than one variable It works on only one variable or constant
It can hold many conditions It can hold only one condition.

(b) Explain the concept of constructor overloading with an example. [2]
Answer:
Function name same as that of class name without return type is called Constructor. Constructor overloading is when same name constructor is used with different arguments list is called constructor overloading.
Example:

Class lol
{
lol ( )
{
//write something ...
}
lol(int a)
{
//write something
}
lol(int a, int b)
{
//write something
}

(c) What will be the output of the following program segments?
(i) String s = “application”;
int p = s.indexOf(‘a’);
System.out.println(p);
System.out.println(p+s); [2]

(ii) String st = “PROGRAM”;
System.out.println(st.indexOf(st.charAt(4))); [2]

ICSE Class 10 Computer Applications Sample Question Paper 1 with Answers

(iii) int a = 0;
if(a>0 && a<20)
d++;
else a-;
System.out.println(a); [2]

(iv) int a- 5, b = 2,c;
if (a>b || a ! = b)
c = ++a+-b;
System.out.print(c+ ” “+a+” “+b); [2]

(v) int i = 1;
while(i++<=1)
{
i++;
System.out.print(i + “”);
}
System.out.print(i); [2]
Answer:
(i) Oapplication
(ii) 1
(iii) -1
(iv) 76 1
(v) 34

ICSE Class 10 Computer Applications Sample Question Paper 1 with Answers

(d) Differentiate between isUpperCase(char) and toUpperCase(char). [2]
Answer:

isUpperCase( ) toUpperCase( )
It checks whether the character is uppercase or not. It changes the character into uppercase
Return value is boolean. Return value is String

(e) What is the difference between a constructor function and a member function of a class? [2]
Answer:

Constructor Function Member Function
1. Automatically called during the creation of the object.
2. It bears the same name as that of class.
1. Class object needs to explicitly call the member functions.
2. It doesn’t have same name.

(f) What is the difference between a static member function and a member function which is not static? [2]
Answer:

Static Member Function Non Static Member Function
1. It has the keyword static before the function name.
2. It can be called by static member functions only.
1. It doesn’t have static keyword before the function name.
2. It can be called by any function.

Section – B  (60 Marks)
Attempt any four questions

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.

ICSE Class 10 Computer Applications Sample Question Paper 1 with Answers

Question 4
Define a class taximeter having the following description:
Data members/instance variables
int taxino – to store taxi number
String name – to store passenger’s name
int km – to store number of kilometres travelled
Member functions:
taximeter( ) – constructor to initialize taxino to 0, name to” “and b to 0.
input( ) – to store taxino,name,km
calculate( )  – to calculate bill for a customer according to given conditions kilometers travelled(km) Rate/km
<1 km                    Rs.25
1 < km < 6             Rs. 10
6 < km <12           Rs. 15
12 < km <18         Rs. 20
>18 km                  Rs.25
display ( ) – To display the details in the following format
Taxino Name Kilometres travelled Bill amount
Create an object in the main method and call all the above methods in it. [15]
Answer:

import java.util.*; 
class taximeter 
{
int taxino;
String name;
int km; 
double fare; 
public taximeter ( ) 
{
taxino = 0; 
name =" "; 
km = 0; 
fare = 0.0;
}
public void input( ) 
{
Scanner sc = new Scanner(System.in);
System.out.primtlnC'Enter taxi number"); 
taxino = sc.nextlnt( ) ;
System.out.primtln("Enter passenger's name"); 
name = sc.nextLine( );
System.out.priintln("Enter number of kms travelled"); 
km = sc.nextlnt( );
}
public void calculate( ) 
{
int Rate =0; 
if (km <= 1) 
fare = 25.0 * km; 
else if(l < km && km <= 6) 
fare = 10.0 * km; 
else if(6 < km && km <= 12) 
fare = 15.0 * km; 
else if(12 < km && km <= 18) 
fare = 20.0 * km; else
fare = 25.0 * km;
}
public void display( ) 
{
System.out.priintln("Taxino "+"Name "+" kilometers travelled "+"Bill amount ");
System.out.priintln(taxino+ ""+name+""+" "+fare);
}
public void main( )
{
taximeter obj == new taximeter( ) ;
obj.input( );
obj.calculate( );
obj.display( );
} //end of main 
} //end of class

ICSE Class 10 Computer Applications Sample Question Paper 1 with Answers

Question 5
Write a menu driven program to find the sum of the following series depending on the user choosing 1 or 2
1. S=1/4+1/8+1/12………….. up to n terms
2. S=1/1!-2/2!+3/3!………….. upto n terms
where ! stands for factorial of the number and the factorial value of a number is the product of all integers from 1 to that number, e.g. 5! = 1* 2* 3* 4* 5.
Answer:

import java.util.*; class abc
 {
public void main( )
{
Scanner sc = new Scanner(System.in); 
double sum = 0.0;
System.out.println
("lnput 1 for sum first series and input 2 for sum of second series"); 
int a = sc.next.lnt(); switch(a)
{
case 1:
{
System.out.println("lnput N value for for the series"); 
int n = sc.next.lnt( ); for(int i = 1; i<= n;i++)
{
sum+ = 1,0/(4.0*i);
}
System.out.println{"sum of 1st series is "+sum);
}
break; 
case 2:
{
System.out.println("lnput N value for for the series"); 
int n = sc.next.Int( ); 
for(int i = 1; i<=n; i++)
{
int fact = 1; 
for(int j = 1; j<=i;j++)
fact*= j; 
if(i % 2 ==1) 
sum+= (double)i/fact; 
else
sum-= (double)i/fact;
}
System.out.println("sum of 2nd series is "+sum);
}
break;
default: System.out.println("not valid choice"); 
break;
} //end of switch 
}//end of main
 }//end of class

Question 6
Write a program to accept a sentence and print only the first letter of each word of the sentence in capital letters separated by a full stop.
Example:
INPUT SENTENCE :”This is a cat”
OUTPUT :T.I.A.C. [15]
Answer:

import java.util.*; 
class abc 
{
public static void main( )
{
Scanner sc = new Scanner(System.in);
System.out.println('Enter a sentence");
String str = sc.nextLine( ); 
str = str+" ";
String word = " " ;
for(int i = 0; i <=str.length( )-1;i++)
{
char ch = str.charAt(i);
 if(ch!='')
{
word = word + ch;
}
else
{
System.out.println(word.charAt(0)+"."); 
word ="";
}
}
}// end of main 
}//end of class

ICSE Class 10 Computer Applications Sample Question Paper 1 with Answers

Question 7
Write a program to create an array to store 10 integers and print the largest integer and the smallest integer in that array. [15]
Answer:

import java.util.*; 
class abc 
{
public static void main( )
{
Scanner sc = new Scanner(System.in); 
int a[ ] = new int[10];
System.out.printlnC'Enter 10 numbers:");
for(int i = 0; i < 10; i++)
a[i] = sc.nextlnt ( );
int largest = 0;
int smallest = 0;
for (int i = 0; i < 10; i++)
{
if(largest < a[i]) 
largest = a[i];
 if(smallest > a[i]) 
smallest = a[i];
}
System.out.println("Largest of number in array is "+largest); 
System.out.printlnC'Smallest of number in array is "+smallest); 
}//end of main 
}//end of class

Question 8
Write a program to calculate the sum of all the prime numbers between the range of 1 and 100. [15]
Answer:

import java.util.*; 
class prime 
{
public static void main( )
{
int sum = 0;
for(int i = 2; i <=100; i++)
{
int mid = i/2; 
int count = 0; 
for (int j = 1; j <=mid; j++)
{
if (i%j ==0)
 count++;
}
if(1 == count) 
sum+= i;
}
System.out.printlnC'sum of all prime numbers is:"+sum); 
}//end of main 
}//end of class

ICSE Class 10 Computer Applications Sample Question Paper 1 with Answers

Question 9
Write a program to store 10 names in an array. Arrange these in alphabetical order by sorting. Print the sorted list. Take single word names, all in capital letters,
E.g. SAMSON, AJAY, LUCY, etc. [15]
Answer:

import java.util.*; 
class prime
{
public static void main( ) 
{
String temp;
Scanner sc = new Scanner(System.in);
String a[ ] = new String [10];
System.out.println("Enter 10 names all in capital letters");
for (int i = 0; i < a.length; i++) 
a[i] = sc.next ( ); 
for(int i = 0; i < a.length; i++) 
for(int j = i+1;j < a.length; j++) 
{
if(a[i].compareTo(a[j])>0)
{
temp = a[i]; 
a[i] = a[j]; 
a[j] = temp;
}
}
for(int i = 0; i < a.length; i++) 
System.out.println(a[i]); 
}//end of main 
}//end of class
Variable Data Type Description
str String Input a string
word String To extract character from string
ch char To store character
a[ ] int To store integer array
temp int Temporary variable for swapping
count int To count the number of factors.
sum int To add the sum of prime numbers
n int Number to be checked whether its prime or not
largest int To store the largest value
smallest int To store the smallest value
a[] String To read all the names in capital letters.
fj int For looping
temp String For storing temporarily

ICSE Class 10 Computer Applications Question Papers with Answers

Leave a Comment