ICSE Class 10 Computer Application Sample Question Paper 2 with Answers

ICSE Class 10 Computer Application Sample Question Paper 2 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) State one difference between primitive literals float and double.
Answer:

Float Double
Float occupies 4 bytes in memory Double occupies 8 bytes in memory

(b) What is an infinite loop. Write a statement for infinite loop.
Answer:
An infinite loop occurs when there is no end to the iteration and loop continues to run indefinitely.
E.g. for (;;)
System.out.printIn(“10”);

(c) Arrange the operators in the order of higher precedence.
(1)++ (2)&& (3)>= (4)%
Answer:
++, % >=, &&

(d) What is final variable and static variable?
Answer:
When any variable is declared using final keyword it makes the the value of that variable as constant. It can’t be changed throughout the program.
E.g. final int temp = 90;
Static variable are those which can be used only by static methods. It has only single copy throughout the class.

(e) What is number of bytes char occupies. Write its range also.
Answer:
2 bytes and its range is 0 to 65,536

ICSE Class 10 Computer Application Sample Question Paper 2 with Answers

Question 2.
(a) What is the difference between keyword parse and function valueOf(). Give example of each.
Answer:

Parse ValueOf
It converts a variable from string data type to another.
E.g. String a = “12”;
int b = Integer.parselnt(a);
It converts only from string to int. E.g. string a = “12”;
Int b = Integer.valueOf(a);

(b) Write a program code to accept a character input and check whether its digit using its ASCII code. Print character using suitable message.
Answer:

class abc
{
public void main()
{
scanner sc = new scanner(system.in);
System.out.printIn("Enter the character to be checked");
char ch = sc.next().charAt(0);
if(ch >=91 && ch <= 97)
System.out.printIn("Digit is "+ch);
else
System.out.printIn("lts not a digit");
}
}

(c) What do you mean by block. Give one example.
Answer:
Block is a set of statements in a program.
Eg
{
System.out.printIn(“example of block statement”);
System.out.printIn(“End of block statement”);
}

(d) State the difference between entry controlled loop and exit controlled loop.
Answer:

Entry Controlled Loop Exit Controlled Loop
Here condition is checked before entering the loop.
E.g. while(i<3)
{
//some statements
}
Here condition is checked after entering the loop. First time entering in the loop is must.
E.g.
{
}while (i<3);

(e) Write two advantages of using function in the program. And explain role of void in declaring functions?
Answer:
Advantages:

  • It makes the program divides into multiple modules.
  • Each module is independent in executing its dedicated task.
  • It helps in reusability of the code once written, void makes sure that function doesn’t return anything.

ICSE Class 10 Computer Application Sample Question Paper 2 with Answers

Question 3.
(a) What do you mean by function overloading? Explain with example.
Answer:
Function overloading is called when function with the same name is used multiple times with different arguments.
Example:
class abc
{
public: area(int a);
area(int a, int b);
area(int a, int b, float c);
}

(b) What is this keyword? Also discuss the significance of it.
Answer:
This keyword is used as a reference to created object for calling its methods or member functions.
It differentiates between instance variables from the local variables when they have the same names.

(c) Attempt the following
(i) State the two features of a constructor.
Answer:
Constructor is function which has the same name as that of class without return type. It is called whenever the object is created for the class.

(ii) Write a valid java program code to print the following array in matrix form with 2 rows and 2 columns.
int mat[ ][ ] = {{2,6},{10,20}};
Answer:
for(int i =0;i<=2;i++)
{
for(int j =0;j<=2;j++)
System.out.print(mat[i][j]);
System.out.printIn();
}

(iii) State the total size in bytes of the array a[4] of char data type and p[4] of float data type.
Answer:
char a[4] it occupies 8 bytes,
float p[4] it occupies 16 bytes.

(iv) String abc = “helloR”;
StringBuffer str = new StringBuffer(abc);
int num = str.capacity();
what will variable num stores the value?
Answer:
22

(v) StringBuffer s1 = new StringBuffer(Robot”);
String s2 = s1 .reverse();
System.out.printIn(“s2 =” +s2);
System.out.printIn(“s1 =” +s1);
Answer:
toboR
toboR

(d) Write a java statement for finding and displaying the position of last space in string’str’.
Answer:
String str = “Blank”;
int a = str.lastlndexOf(‘ ‘);
System.out.printIn(a +” is the last position of”);

(e) Which one of the following returns the corresponding primitive data type object from string object?
(i) Integer
(ii) readLine()
(iii) valueOf()
(iv) endsWith()
Answer:
(i) int
(ii) String
(iii) int
(iv) boolean

(f) What do you mean by Abstraction and information hiding in java?
Answer:
Data abstraction is the act of representing the essential features of the program without involving in its complexity.
Information hiding in java means data members which can’t be accessed directly by objects instead it has access via its member functions.

SECTION – B [60 Marks]
Attempt any four questions from this Section

The answers in this Section should consist of the Programs in either the Blue 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.
Write a program to input three sides of a triangle (s1, s2, s3). Using switch case print whether a triangle is Equilateral, Isosceles, Right angled triangle or scalene.
The program should be used with menu and switch-case.
Answer:

import java.util.*;
class Triangle
{
public static void main()
{
Scanner sc = new Scanner(System.in);
System.out.printIn("Enter 3 sides of triangle ");
double si = sc.nextDoubleO;
double s2 = sc.nextDoubleO;
double s3 = sc.nextDoubleO;
char ch ='0';
double sq 1 = s1* s1;
double sq2 = s2*s2;
double sq3 = s3 * s3;
double sum1 = sq1 + sq2;
double sum2 = sq2 + sq3;
double sum3 = sq1 + sq3;
if(s1 == s2 && s2 == s3 )
ch = 'E';
if(s1 == s2 || s2 == s3 || s1 == s3)
ch = T;
if(sum1 == sq3 || sum2 == sq 1 || sum3 == sq2)
ch = 'R';
if(s1 != s2 && s2!=s3)
ch = 'S';
switch(ch)
{
case 'E': System.out.printIn("Equilateral triangle");
break;
case T: System.out.printIn("lsoscless triangle");
break;
case 'R': System.out.printIn("Right triangle");
break;
case 'S': System.out.printIn("Scalene triangle");
break;
default: break;
}
}
}

ICSE Class 10 Computer Application Sample Question Paper 2 with Answers

Question 5.
Write a program to find the sum of the following series:
x + \(\frac{x^{2}}{2 !}+\frac{x^{2}}{3 !}+\frac{x^{4}}{4 !}+\) ….n terms
Answer:

import java.util.*;
class series
{
public static void main()
{
Scanner sc = new Scanner(System.in);
System.out.printIn("Enter a number and number of terms");
int x = sc.nextInt();
int n = sc.nextInt();
int a = 1; int f;
double sum = 0.0;
forfint i =1; i<= n; i++)
{
f = 1;
for(int j = 1; j<=i;j++)
f = f*j;
sum = sum+(Math.pow(x,a)/f);
3++;
}
System.out.printIn(''sum: "+sum);
}
}

Question 6.
A number is said to be NEON number if sum of digits of square of a number is equal to the number itself.
Example:
INPUT N = 9, Output Square: 81 (where 8 + 1 = 9 so 9 is NEON number)
Write a program to find such numbers between 10 and 10000.
Answer:

import java.util.*;
class Neon
{
public static void main()
{
int a = 10;
for(int i =10;i<=10000; i++) { intal =a; long sq = a1*a1; int sum =0; while(sq >=0)
{
int k = (int)sq % 10;
sum = sum + k;
sq = sq/10;
if(sum == a)
System.out.printIn(a);
a++,ā€™
}
}

Question 7.
Write a program to perform binary search on the list of 10 integers entered by user in ascending order to search for an element input by user, if it’s found display the element along with its position else display the message “search element not found”.
Answer:

import java.util.*;
class binsearch
{
public static void main()
{
Scanner sc = new Scanner(System.in);
System.out.priintlnfEnter the 10 no.s in ascending order to be put in the array");
int[] a = new int[10];
for(int i = 0; i< 10; i++)
a[i] = sc.nextInt();
System.out.printIn(Enter the no. to be searched in the array");
int n = sc.nextInt();
int start =0,pos=0;
int last =a.length - 1;
int mid = (start + last) / 2;
int found = 0;
while(start <= last)
{
if(n == a[mid])
{
pos = mid; found = 1;
break;
}
if(n < a[mid]) mid = last - 1; if(n > a[mid]) mid = start + 1;
}
if(found == 1)
System.out.printIn(n+" found at position "+pos);
else
System.out.printIn(n+" not found");
}
}

Question 8.
Write a program to accept a word and convert into lowercase if it is in uppercase and display the new word by replacing the VOWELS with the character following it.
ex. Sample intput: VOWEL
Sample output: vpwfi
Answer:

import java.util.*;
class strlol
{
public static void main()
{
Scanner sc = new Scanner(System.in);
Systenn.out.printIn("Enter a word");
String strl = sc.next();
String str = strl .toLowerCase();
String word = "
for(int i = 0; i <= str.length()-1; i++) { char ch = str.charAt(i); if (ch != 'a' && ch !='e' && ch != T && ch != 'o' && ch!='u') word = word + ch; if(ch=='a' || ch == 'e'|| ch == 'i' || ch == 'o' || ch == 'u') { ch ++; word = word + ch; } } System.out.printIn(word); } }
int a = i-1;
for(int k = 1; k <= 5-i; k++)
System.out.print("");
for(int j = 1;j<= i;j++) { System.out.printIn(j+" "); if(a > 0)
System.out.printIn("*");
a--;
}
System.out.printIn();
}
}
}

ICSE Class 10 Computer Application Sample Question Paper 2 with Answers

Question 9.
Write a program in java to print the following output.
ICSE Class 10 Computer Applications Sample Question Paper 2 with Answers 1
Answer:

import java.util.*;
class pattern
{
public static void main()
{
for(int i = 5; i>= 1; iā€”)
{
int a = i-1;
for(int k = 1; k <= 5-i; k++)
System.out.print("");
for(int j = 1;j<= i;j++)
{
System.out.printIn(j+" ");
if(a > 0)
System.out.printIn("*");
a--;
}
System.out.printIn();
}
}
}
Variable Data Type Description
sq1,sq2, sq3 double To find squares of each side
ch char To store the type of triangle.
x, n int Number and number of terms.
f Int Factorial storing
sum double To store sum of series.
sum Int To store sum of digits of neon number.
a[ ] int To store integers in ascending order.
n int Element to be searched.
start,last mid int Positions of index of array
found int Flag to check element is found or not.
strl string For storing string.
ch char To take out each character of string.
word String For storing the required string.
a int Number of rows.

ICSE Class 10 Computer Application Question Papers with Answers

Leave a Comment