ICSE Class 10 Computer Application Sample Question Paper 1 with Answers

ICSE Class 10 Computer Application Sample Question Paper 1 with Answers

Max Marks: 80
[2 Hours]

General Instructions

  • 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. O 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 Question

Question 1.
(a) Name any four tokens of Java. [2]
Answer:
Integer, boolean, double and character.

(b) Give the difference between actual parameter and formal parameter. [2]
Answer:
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.
}

(c) What is an identifier? [2]
Answer:
Identifiers are names of the variables, strings, classes and packages. Its values can change throughout the program.

(d) Write an expression in Java for sin x + √a2 + √b3. [2]
Answer:
Math.sin(x) + Math.sqrt(a*a + b*b*b);

(e) What is the result produced by 2 – 10*3 + 100/11 ? Show the steps. [2]
Answer:
Step 1:2- 10*3 + 9
Step 2:3 – 30+9
Step 3: 3-21
Step 4: -19

ICSE Class 10 Computer Application Sample Question Paper 1 with Answers

Question 2.
(a) What is the difference between local variable and instance variable? [2]
Answer:

Local VariableInstance 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.

(b) int x = 20, y = 10, z;
What is the value of z in
z = ++x * (y – -) – y ?
Show the steps. [2]
Answer:
int x =20, y = 10, z;
z = ++x * (y – -) – y ?
Step 1:21 * 10-9
Step 2: 210 – 9
Step 3: 201

(c) What is the purpose of default in a switch? [2]
Answer:
Default in the switch statement means when no matching case is encountered by the controller it executes the default case.

(d) Give the difference between linear search and binary search. [2]
Answer:

Linear SearchBinary 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) 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:
8.0
7.0

ICSE Class 10 Computer Application Sample Question Paper 1 with Answers

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

If-else LadderSwitch Case
Works on more than one variableIt works on only one variable or constant
It can hold many conditionsIt 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]
Answer:
0application

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

(iii) int a = 0; if(a>0 && a<20) d++; else a-; ‘ System.out.println(a); [2] Answer: -1 (iv) int a- 5, b = 2,c; if (a>b || a ! = b) c = ++a+-b;
System.out.print(c+ ” “+a+” “+b); [2]
Answer:
7 6 1

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

(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 FunctionMember Function
Automatically called during the creation of the object.Class object needs to explicitly call the member functions.
It bears the same name as that of class.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 FunctionNon Static Member Function
It has the keyword static before the function name.It doesn’t have static keyword before the function name.
It can be called by static member functions only.It can be called by any function.

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 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 kmRs.25
1 < km < 6Rs. 10
6 < km <12Rs. 15
12 < km <18Rs. 20
>18 kmRs.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 inputQ
{
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 displayO
{
System.out.priintln("Taxino "+"Name "+" kilometers travelled "+"Bill amount ");
System.out.priintln(taxino+ ""+name+" "+" "+fare);
}
public void main()
{
taximeter obj == new taximeterO;
obj.input();
obj.calculate();
obj.display();
}//end of main
}//end of class

ICSE Class 10 Computer Application 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………… upton 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. (use switch-case). [15]
Answer:

import java.util.*;
class abc {
public void main()
{
Scanner sc = new Scanner(System.in);
double sum = 0.0;
System.out.println("Input 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("Input N value for for the series");
int n = sc.next.Int();
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.printIn("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.printIn(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 Application 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.printIn(Enter 10 numbers:");
for(int i = 0; i < 10; i++)
a[i] = sc.nextlntO;
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.printIn("Largest of number in array is "+largest);
System.out.printIn(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++)
!
l
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.printIn(sum of all prime numbers is:"+sum);
}//end of main
}//end of class

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 mainQ
{
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.nextO;
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];
atj] = temp;
}
}
for(int i = 0; i < a.length; i++)
System.out.println(a[i]);
}//end of main
}//end of class
VariableData TypeDescription
strStringInput a string
wordStringTo extract character from string
chcharTo store character
a[ ]intTo store integer array
tempintTemporary variable for swapping
countintTo count the number of factors.
sumintTo add the sum of prime numbers
nintNumber to be checked whether its prime or not
largestintTo store the largest value
smallestintTo store the smallest value
a[]StringTo read all the names in capital letters.
fjintFor looping
tempStringFor storing temporarily

ICSE Class 10 Computer Application Question Papers with Answers

Leave a Comment