ICSE Class 10 Computer Applications Sample Question Paper 12 with Answers

ICSE Class 10 Computer Applications Sample Question Paper 12 with Answers

Section -A (40 Marks)
Attempt all questions

Question 1
(a) What do you mean by reusability feature.
(b) Write the java expression for the roots of the quadratic equation.
(c) Name any two jump statments and their usages.
(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.
(e) What do you mean by dynamic initialization of an array? Give an example.
Answer:
(a) Reusability feature is related to inheritance in java where derived class can use the methods and common data from the base class.

ICSE Class 10 Computer Applications Sample Question Paper 12 with Answers

(b) 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) (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);
}

ICSE Class 10 Computer Applications Sample Question Paper 12 with Answers

(d) Math.cos(b) trim( ).
Answer:
Math.cos(b)
trim( ).

(e) When the array is initialized during the run time of program its called dynamic initialization of array.
E.g.
int a[ ] = new int[10];

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.
(ii) Name the variables that are common to all the objects of the class.
Answer:
(i) m and y
(ii) 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

ICSE Class 10 Computer Applications Sample Question Paper 12 with Answers

(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.

ICSE Class 10 Computer Applications Sample Question Paper 12 with Answers

Question 3
(a) What are the different keywords that checks the visibility of a member of the class? What are they called?
(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);
(c) Attempt the following:
(i) A package that is involved to manipulate character as well as String?
(ii) Name a data type that can hold 16 bit Unicode characters.
(iii) What is the output of code below:
charc = ‘A’; int m = 5;
System.out.println(char(c+m));
System.out.println(c+m);
(iv) Write statements to show how finding the length of a character array char[ ] differs from finding the lengths of string object str.
(v) Give the output of the following functions System.out. println(“MALAYALAN”.indexOf(‘A,)+”Sidharth”.lastlndexOf(‘h’));
(vi) double a = Math.pow(“200”.index0f(‘0’),2);
System.out.println(a);
(vii) Differentiate between linear search and binary search.
(viii) Evaluate the following expression:
int p, k= 8,m=11,r=7; p = (r++%7)+(-m%5)+k*(++k-8);
Answer:
(a) private, public, protected
(b) 3 times 60
(c) (i) java.lang
(ii) byte
(iii) F 70
(iv) array.length and str.length( )
(v) 8
(vi) 1.0
(vii)

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) 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.

ICSE Class 10 Computer Applications Sample Question Paper 12 with Answers

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-t-l)
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("lnput a number:"); 
int n = sc.nextlnt( ); 
int result = 0; for(int i=0; i<n; i++)
{
if(i*(i+1) == n)
{
result = 1; break;
}
}
if(result == 1)
System.out.println(''Pronic Number."+n); 
else
System.out.println("Not a Pronic Number."+n);
}//end of main 
}//end of class

ICSE Class 10 Computer Applications 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.printlnC'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.println(word);
}//end of main 
}//end of class

ICSE Class 10 Computer Applications Sample Question Paper 12 with Answers

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.println(''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.println(word);
} //end of main 
}//end of class

ICSE Class 10 Computer Applications Sample Question Paper 12 with Answers

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 temp 1;
String a[ ] = new String[15];
int age[ ] = new int[15];
Scanner sc = new Scanner(System.in); 
System.out.printlnC'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.nextlnt( );
}
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.println(a[i]+"\t"+age[i]);
}
}//end of main 
}//end of class

ICSE Class 10 Computer Applications 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.
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.priintln("1 .Area of equilateral triangle"); System.out.priintln("2.Area of isosceles triangle");
System.out.priintln("3.Area of scalene triangle");
n=sc.nextlnt( );
switch(n)
{

case 1:
System.out.printlnC'Enter side of an equilateral triangle");
s=sc.nextFloat( );
area=Math.sqrt(3.0*s*s)/4.0;
System.out.println("Area="+area);
break;

case 2:
System.out.printlnC'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.println("Area="+area);
break;

case 3:
System.out.printlnC'Enter the 3 sides of scalene triangle");
a=sc.nextFloat( );
b=sc.nextFloat( );
c= sc.nextFloat( );
s= (a+b+c)/2;
area=Math.sqrt(s*(s-a)*(s-b)*(s-c));
System.out.println(”Area="+area);
break-
default:
System.out.println("Wrong choice");
}
}//end of main 
}//end of class

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

ICSE Class 10 Computer Applications Sample Question Paper 12 with Answers

(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;
Wend 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.println(s.sum(1,5));
System.out.println(s.sum(10.0));
System.out.println(s.sum(10935));
}//end of main
} //end of class

ICSE Class 10 Computer Applications Sample Question Paper 12 with Answers

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 Applications Question Papers with Answers

Leave a Comment