ICSE Class 10 Computer Application Sample Question Paper 12 with Answers

ICSE Class 10 Computer Application Sample Question Paper 12 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) What do you mean by reusability feature.
Answer:
Reusability feature is related to inheritance in java where derived class can use the methods and common data from the base class.

(b) Write the java expression for the roots of the quadratic equation.
Answer:
double r1 = (-b + Math.sqrt(b * b – 4 * a * c)) / (2 * a); double r2 = (-b – Math.sqrt(b * b – 4 * a * c)) / (2 * a);

(c) Name any two jump statments and their usages.
Answer:
(i) break;
(ii) continue
for(int i =1; i< 10; i++)
{
if(i*3 == 9) break;
}
for(int i =1; i< 10; i++)
{
if(i%2 == 0) continue;
System.out.println(i);
}

(d) (i) Name the mathematical function which is used to find the cosine of an angle given in radians.
(ii) Name a string functions which removes the blank spaces provided in the prefix and suffix of a string.
Answer:
Math.cos(b)
trim().

(e) What do you mean by dynamic initialization of an array? Give an example.
Answer:
When the array is initialized during the run time of program its called dynamic initialization of array. E.g.
int a[] = new int[10];

ICSE Class 10 Computer Application Sample Question Paper 12 with Answers

Question 2.
(a) Consider the following code
class lol
{
public static int m=3,y=4; public int a =10,b = 15;
}
(i) Name the variables for which each of object of the class will have its own distinct copy.
Answer:
m and y

(ii) Name the variables that are common to all the objects of the class.
Answer:
a and b.

(b) Distinguish between constructor and method.
Answer:

Constructor Method
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.

(c) What are the values of a and b after the following function is executed if values passed are 30 and 50.
void pass(inta, int b)
{
a = a+b; b= a-b; a = a-b;
System.out.println(“a=”+a+””b=”+b);
}
Answer:
a = 50 b = 30

(d) Rewrite the following statement using if-else statement amount = (x!=50)?((x<50)?(4.0/100*x):(l 0.0/100*x)):500;
Answer:
if(x!=50)
{
if(x<50)
amount = 4.0/100*x; else
amount = 10/100*x;
}
else
amount = 500;

(e) Name any two tokens of java.
Answer:
variables and constants.

Question 3.
(a) What are the different keywords that checks the visibility of a member of the class? What are they called?
Answer:
private, public, protected

(b) Determine how many times loop will be executed and print the output.
int a=1, b=2;
while(++b<6)a*b;
System.out.println(a);
Answer:
3 times 60

(c) Attempt the following:
(i) A package that is involved to manipulate character as well as String?
Answer:
java.lang

(ii) Name a data type that can hold 16 bit Unicode characters.
Answer:
byte

(iii) What is the output of code below:
charc = ‘A’; int m = 5;
System.out.println(char(c+m));
System.out.println(c+m);
Answer:
F 70

(iv) Write statements to show how finding the length of a character array char[ ] differs from finding the lengths of string object str.
Answer:
array.length and str.length()

(v) Give the output of the following functions System.out. println(“MALAYALAN”.indexOf(‘A,)+”Sidharth”.lastlndexOf(‘h’));
Answer:
8

(vi) double a = Math.pow(“200”.index0f(‘0’),2);
System.out.println(a);
Answer:
1.0

(vii) Differentiate between linear search and binary search.
Answer:

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.

(viii) Evaluate the following expression:
int p, k= 8,m=11,r=7; p = (r++%7)+(–m%5)+k*(++k-8);
Answer:
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.
Write a program in java to input a number and check whether it is a pronic number or Heteromecic number or not.
Pronic number: A pronic number, oblong number, rectangular number or heteromecic number is a number which is the product of two consecutive integers i.e n(n+1)
The first few Pronic numbers are:
0, 2, 6, 12, 20, 30, 42, 56, 72.
Answer:

import java.util.*;
class Main
{
public static void main(String[ ] args)
{
Scanner sc = new Scanner(System.in);
System.out.print("Input a number:");
int n = sc.nextInt();
int result = 0;
for(int i=0; i<n; i++)
{
if(i*(i+1) == n)
{
result = 1;
break;
}
}
if(result == 1)
System.out.printIn("Pronic Number."+n);
else
System.out.printIn("Not a Pronic Number."+n);
}//end of main
}//end of class

ICSE Class 10 Computer Application Sample Question Paper 12 with Answers

Question 5.
Write a program to input a word from the user and remove the duplicate characters present in it.
Example:
input: crcricicket
output: criket
Answer:

import java.util.*;
class Main
{
public static void main(String[ ] args)
{
Scanner sc=new Scanner(System.in);
System.out.printIn("Enter a sentence:");
String str=sc.nextLine();
String word = " ";
char c = str.charAt(O);
word+=c;
for(int i=0;i<str.iength();i++)
{
char ch=str.charAt(i);
boolean flag=false;
for(int j = 0; j<word.length();j++)
{
if(ch==word.charAt(j))
{
flag = true;
}
}
if(flag == false)
word+=ch;
}
System.out.printIn(word);
}//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.
e.g.
INPUT Sentence: Sid is a cricket
output: S.I.A.C
Answer:

import java.util.*;
class Main
{
public static void main(String[ ] args)
{
Scanner sc=new Scanner(System.in);
System.out.printIn("Enter a sentence: ");
String str=sc.nextLine();
str = "" +str;
str = str.toUpperCase();
String word = " ";
for(int i = 0; i < str.length(); i++)
{
char ch = str.charAt(i);
if(ch =='')
{
word+=str.charAt(i+1)+".";
}
}
System.out.printIn(word);
} //end of main
}//end of class

Question 7.
Write a program to accept name and corresponding age in two different single dimensional array. Display the records in descending order of age using bubble sort.
Answer:

import java.util.*;
class Main
{
public static void main(String[ ] args)
{
int temp;
String tempi;
String a[ ] = new String[15];
int age[] = new int[15];
Scanner sc = new Scanner(System.in);
System.out.printIn("Enter a 15 names and their ages:");
for(int i =0; i<a.length; i++)
{
System.out.print("Enter name"+ (i+1) a[i] =sc.next();
System.out.print("Enter age"+ (i+1) +":");
age[i]=sc.nextInt();
}
for(int i = 0;i<age.length; i++)
{
for(int j =0; j<age.length—i—1 ;j++)
{
if(age[j]<(age[j+1]))
{
temp = age[j];
tempi = a[j];
age[j]=age[j+1];
a[j] = a[j+1 ];
age[j+1] = temp;
a[j+1]=temp1;
}
}
}
for(int i =0; i <a.length;i++)
{
System.out.printIn(a[i]+"\t"+age[i]);
}
}//end of main
}//end of class

ICSE Class 10 Computer Application Sample Question Paper 12 with Answers

Question 8.
Write a menu driven program to find area of an Equilateral triangle, an isosceles triangle and a scalene triangle as per the users choice.
(i) Equilateral triangle = A = \(\)
(ii) Isosceles triangle = 1/2*b*√a2 – b2/4
(iii) Scalene triangle = \(\sqrt{s(s-a)(s-b)(s-c)}\)
Answer:

import java.util.*;
class Main
{
public static void main(String[ ] args)
{
Scanner sc = new Scanner(System.in);
int n;
float a,c,s,b;
double area;
System.out.priintIn("1 .Area of equilateral triangle");
System.out.priintIn("2.Area of isosceles triangle");
System.out.priintIn("3.Area of scalene triangle");
n=sc.nextInt();
switch(n)
{
case 1:
System.out.printIn("Enter side of an equilateral triangle");
s=sc.nextFloat();
area=Math.sqrt(3.0*s*s)/4.0;
System.out.printIn("Area="+area);
break;
case 2:
System.out.printInC'Enter the side and base of isosceles triangle”);
a=sc.nextFloat();
b=sc.nextFloat();
area=b/4.0*(Math.sqrt(4.0*a*a-b*b));
System.out.printIn("Area="+area);
break;
case 3:
System.out.printInC'Enter the 3 sides of scalene triangle");
a=sc.nextFloat();
b=sc.nextFloat();
c= sc.nextFloatO;
s= (a+b+c)/2;
area=Math.sqrt(s*(s-a)*(s-b)*(s-c));
System.out.printIn(”Area="+area);
break;
default:
System.out.printIn("Wrong choice");
}
}//end of main
}//end of class

ICSE Class 10 Computer Application Sample Question Paper 12 with Answers

Question 9.
Define a class to overload a function Sum() as follows:
(i) int Sum(int a, int b) – with integer arguments a and b.
Calculate and return sum of all even numbers in the range of a and b.
Sample input: a = 4, b = 16
Sample output: sum = 4 + 6 + 8 + 10 + 12 + 16
(ii) double Sum(double n) – with one double argument n. Calculate and return the product of the following series:
sum = 1.0*1.2*1.4*…*n
(iii) int Sum(int n) – with one integer argument n. Calculate and return sum of only odd digits of the number n.
Sample input: n = 43961
Sample output: sum = 3 + 9 + 1 = 13
Answer:

import java.util.*;
class Main
{
public int sum(int a, int b)
{
int sum= 0;
for(int i=a; i<=b;i++)
{
if(i%2==0)
sum+=i;
}
return sum;
}//end of sum
public double sum(double n)
{
double prod=1.0;
for(double i =1.0; i<=n; i+=0.2)
prod*=i;
return prod;
}
public int sum(int n)
{
int sum = 0;
int a = n;
int digit;
while(a>0)
{
digit = a%10;
if(digit%2!=0)
sum+=digit;
a=a/10;
}
return sum;
}
public static void main(String args[ ])
{
Main s = new Main();
System.out.printIn(s.sum(1,5));
System.out.printIn(s.sum(10.0));
System.out.printIn(s.sum(10935));
}//end of main
} //end of class
Variable Data Type Description
n int Users input integer value
result int Flag to check pronic number
c char To store first character
flag boolean To check character is present in word or not
str String User input string.
word String Modified string
a[] string To store 15 names
age[] int To store integer number
temp int Temporary variable for swapping
tempi String Temporary variable for swapping
n int Users choice
a c s b float S = side of equilateral triangle A b side and base of issocless triangle Abe sides of scalene triangle
area double To store area
prod double Store product of decimal number in series
digit int To store digit of number

ICSE Class 10 Computer Application Question Papers with Answers

Leave a Comment