ICSE Class 10 Computer Application Sample Question Paper 9 with Answers

ICSE Class 10 Computer Application Sample Question Paper 9 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 is return of following function.
(i) equals()
Answer:
boolean

(ii) rint().
Answer:
double

(b) What do you mean by compound statement. When do you need it.
Answer:
A set or a block of statement in a program is called compound statement. It can be used to divide the program into segments and organise the data accordingly.

(c) Explain difference between character constant and string constant.
Answer:

Character Constant String Constant
Enclosed in single quotes E.g. ‘A’, ‘e’ Enclosed in double quotes E.g. “hello”, “1” like JAVA”

(d) State any two features of constructor.
Answer:
It has same name as that of class. It has no return type.

(e) Define abstraction.
Answer:
Abstraction is the act of representing the essential features of a program without involving in its complexity.

Question 2.
(a) Explain the term object using example?
Answer:
Object is an identifiable entity with some particular characteristics and behaviour.
E.g.TV, characteristics: Big, small etc.
Behaviour: Show different channels, off/on etc.

(b) What is the wrapper class. Justify with example?
Answer:
The class which helps in converting primitive data types to object type is called wrapper class. Eg. Character, Integer etc.

(c) State the purpose of new operator?
Answer:
The ‘new’ keyword supports instantiation. It allocates memory for the newly created object.

(d) Write java expression for
sin x + \(\sqrt[2]{a x^{2}+b x+c}\)
Answer:
double z = Math.sin(x)+Math.sqrt(a*x*x + b*x + c);.

(e) Explain the concept of constructor overloading with example.
Answer:
class lol
{
int a;
lolO
{
a = 1;
}
lol(int b)
{
a = b
}
void main()
{
lol obj = new lol();
lol objl= new lol(3);
}
}

ICSE Class 10 Computer Application Sample Question Paper 9 with Answers

Question 3.
(a) Explain the concept of constructor overloading with example.
Answer:
class lol
{
int a;
lolO
{
a = 1;
}
lol(int b)
{
a = b
}
void main()
{
lol obj = new lol();
lol objl= new lol(3);
}
}

(b) Differentiate between equalsO and compareTo().
Answer:

Equals() CompareTo()
It returns boolean value It returns integer value
Compares the whole string at once. It compares the ASCII values of each character of the string.

(c) Attempt the following:
(i) Differentiate between call by value and call by reference.
Answer:

Call by Value Call by Reference
Actual parameters are copied into the formal parameters. Actual parameters alias are created in the formal parameters.
Changes made by the formal parameters is not reflected back to the actual parameter Changes made by the formal parameter directly affects the actual parameters.

(ii) What is an identifier. Give example
Answer:
Identifiers are those quantities which change their values during the execution of the program. E.g. Int a, b;

(iii) Name the package that contains the scanner class. Which unit or class gets called when object is created.
Answer:
java.util and constructor.

(iv) What is meant by encapsulation.
Answer:
Encapsulation: Wrapping of data and its associated functions into a single unit.

(v) What is meant by inheritance.
Answer:
Inheritance is the method of inheriting the properties of one class from another class. The class which derives its own properties is called base class and the class which derives the properties of another class is called sub class.

(vi) char a[ ]={‘a’,’b’,,c’}; System.out.println(a); What will be the output.
Answer:
Address of array a[]

(vii) char a[]={‘a’,’b’,’c’}; System.out.println(a[1]++); System.out. println(++a[1]);
Answer:
b d

(viii) inta[]={1,2,3};System.out.println(a[1]++);System.out.println(++a[1]);
Answer:
2

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 to print the sum of prime digits from given number.
E.g. 134667
Output: 1+3+7=11
Answer:

import java.util.*;
class Main
{
public static void main(String[ ] args)
{
Scanner sc = new Scanner(System.in);
System.out.printIn("enter the number:");
int a = sc.nextIntO;
int a 1 = a;
int sum = 0;
while (a 11=0)
{
int count = 0;
int k = a1%10;
for(int i=1; i<=k; i++)
{
if(k%i==0)
count++;
}
if(count==2)
sum+=k;
a 1 /=10;
}
System.out.printIn("sum = "+sum);
}//end of main
}//end of class

ICSE Class 10 Computer Application Sample Question Paper 9 with Answers

Question 5.
Write a program to print the longest word from the sentence and print the number of characters of the longest word.
Answer:

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

Question 6.
Write a program to find sum of negative numbers, sum of positive odd numbers and sum of positive even numbers entered by user and list terminates when user enters 0.
Answer:

import java.util class Main
{
public static void main(String[ ] args)
{
Scanner sc = new Scanner(System.in);
int sum = 0, sum1 = 0, sum2 = 0;
System.out.printIn("Enter the number to calculate and 0 for exit:");
int n = sc.nextInt();
int a = n;
while(a!=0)
{
if(a>0)
{
if(a%2 == 0)
sum1+=a;
else
sum2+=a;
}
else
{
sum+=a;
}
System.out.printIn("Enter the next number and 0 to exit:");
a = sc.nextInt();
}
System.out.printIn("Positive even sum: "+suml+"\t"+"Positive odd sum:"+sum2+"\t"+"Negative sum:"+sum);
} //end of main
}//end of class

ICSE Class 10 Computer Application Sample Question Paper 9 with Answers

Question 7.
Using switch case write a menu driven program to print the patterns.
ICSE Class 10 Computer Application Sample Question Paper 9 with Answers 1
Answer:

import java.util.*;
class Main
{
public static void main(String[ ] args)
{
Scanner sc = new Scanner(System.in);
System.out.printInC'Enter the choice:");
intal = sc.nextInt();
switch(a1)
{
case 1: inta = 0;
int b = 2;
for(int i =5;i>= 1;i—)
{
for(int j=1; j<=i;j++)
System.out.print(a+"");
a+=b;
b+=2;
System.out.printIn();
}
break;
case 2:
for(int i =1; i<=5; i++)
{
for(int j=1;j<=i;j++)
{
if(j%2 != 0)
System.out.print(''X");
else
System.out.printC'Y'');
}
System.out.printIn();
}
break;
default: System.out.printIn("Invalid Choice");
}
}//end of main
}//end of class

Question 8.
Write a program to find using binary search method from list of roll numbers entered by user in ascending order. If the search is successful print “you are selected to go” else print “Try next time”.
Answer:

import java.util.*;
class Main
{
public static void main(String args[ ])
{
int first, last, middle, n, search, array! ];
Scanner sc = new Scanner(System.in);
System.out.printIn("Enter total number of students");
n = sc.nextInt();
array = new int[n];
System.out.printInC'Enter" + n + " integers");
for (int i = 0; i<n; i++)
arrayti] = sc.nextInt();
System.out.printInC'Enter value to find");
search = sc.nextIntO;
first = 0;
last = n - 1;
middle = (first + last)/2;
while(first <= last)
{
if (array[middle] < search)
first = middle + 1;
else if (array[middle] == search)
{
System.out.printIn(search + " you are selected to go " + (middle + 1) + ".");
break;
}
else
last = middle - 1;
middle = (first + last)/2;
}
if (first > last)
System.out.printIn(search + " Try next timeAn");
}//end of main
}//end of class

ICSE Class 10 Computer Application Sample Question Paper 9 with Answers

Question 9.
Write a program to input sentence and print in the lowercase letters and replace all the words like “is” and “are” with “were” and “had” and “has” with “had”.
Answer:

import java.util.*;
class Main
{
public static void main(String[ ] args)
{
Scanner sc = new Scanner(System.in);
System.out.printIn("Enter the sentence:");
String str = sc.nextLine();
String str1 = str.toLowerCase();
String word = str1 +="";
String str2 ="";
for(int i =0;i<str1.length(); i++)
{
char ch = strl .charAt(i); if(ch!='') word+=ch;
else
{
if(word ,equals("is")) str2=str2+"were"+"";
else if(word.equals("are"))
str2=str2 + "had"+"";
else if(word.equals("has"))
str2=str2+"had" +"";
else
str2=str2+word+" ";
word = " ";
}
}
System.out.printIn(str2);
}//end of main
}//end of class
Variable Data Type Description
a int Store input integer from user
a1,sum int For modifying digits and to calculate sum of digits
str String Store input string from user
ch char Store the character
count int Count number of blank spaces
word String To store new word
temp String Temporary storage for swapping strings.
a[ ] String Array of strings.
n int Store integer from user
a int For modifying value
sum1,sum2,sum3 int Even number sum Positive odd sum Negative sum
b int For printing even pattern
i j int For looping
first last middle n search array[] int First last and middle are Index of array N is total number of elements Search is number to be searched in array. Array[] array of sorted roll numbers
str1 String Store lowercase word
str2 String To store the modified sentence.

ICSE Class 10 Computer Application Question Papers with Answers

Leave a Comment