ICSE Class 10 Computer Applications Sample Question Paper 11 with Answers

ICSE Class 10 Computer Applications Sample Question Paper 11 with Answers

Section- A (40 Marks)
Attempt all questions

Question 1
(a) Give one similarity and one difference between do while and while loop.
(b) Write the java statement to find largest of 3 numbers using conditional operator.
(c) What is polymorphism?
(d) Write a function to round off any fractional number? Give one example.
(e) What is difference between infinite loop and fall through statement?
Answer:
(a) Similarity – Both while and do while loop is used when the no. of iterations are not specified. Difference: while loop is entry controlled loop and while do while loop is exit controlled.

(b) int a = (b>c)?b:c; int d = (a>e)?a:e;

ICSE Class 10 Computer Applications Sample Question Paper 11 with Answers

(c) Polymorphism is the identity to represent an object in more than one form.

(d) Math.round( )
double k = Math.round(2.9);

(e)

Infinite Loop Fall Through
Occurs for iteration statement Occurs for conditional statement.
Occurs when conditions is always satisfied. Occurs when the break statement is missing in every case statement.

ICSE Class 10 Computer Applications Sample Question Paper 11 with Answers

Question 2
(a) Compare local, instance and class variables on the basis of the given criteria.
(i) identification in program
(ii) Usage of access specifier with them.
(iii) provision of initial values.
(iv) Number of copies for each object of class.
Answer:
(a) (i) Local variables are usually used in a block of statement. Instance variables are used by a method while class variable has only one copy throughout out the class.

(ii) Local variable scope remains inside the compound statement. Inside the curly braces.
Instance variable scope remains inside the method. All access specifiers can be used in class variables. Scope is throughout the class.

(iii) Local variables is initialized in its scope.
Instance variables initialized in the method where it is used in.
Class variables are initialized after the class declaration.

(iv) local variables multiple copies can exists.
Instance variables multiple copies can exists.
Class variables single copy exists.

ICSE Class 10 Computer Applications Sample Question Paper 11 with Answers

(b) Which OOPs principle is implemented when you:
(i) use the keyword extends
(ii) create an interface
(iii) create various functions
(iv) use private data members?
Answer:
(i) Inheritance
(ii) Abstraction
(iii) Polymorphism
(iv) Encapsulation

(c) What are functions? Give one advantage using functions.
Answer:
Functions are a set of statements used to perform certain tasks. Advantage: It organizes the code into a blocks and helps in performing specific task.

(d) Differentiate between classes and objects. Why is object referred as instance of class?
Answer:
(i) Object is an identifiable entity with some characteristics and behaviour. Class is a collection of object with similar characteristics.

(ii) Object is called instance of class as object helps in accessing the class members and functions to get the required output.

ICSE Class 10 Computer Applications Sample Question Paper 11 with Answers

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

Linear Search Binary Search
The search element is compared with each element of the array. The array is sorted and divided into two halves and then search element is found accordingly.
Array need not be sorted. Array has to be sorted.

Question 3
(a) What is other name of java interpreter? Explain it.
Answer:
JVM (Java virtual machine): It is used to convert java byte code to machine code which can be understood by the computer running on any operating system.

(b) Name the java keyword
(i) used to finish the execution of the method.
(ii) used to implement the concept of inheritance.
Answer:
(i) exit or return
(ii) extends

ICSE Class 10 Computer Applications Sample Question Paper 11 with Answers

(c) Attempt the following:
(i) Assign the constant value pi as 3.14 to variable using suitable data type?
(ii) Give difference between unary and binary operators.
(iii) Give examples of each
(i) Composite date type.
(ii) Escape sequence.
(iii) Comment lines
(iv) Wrapper class
(iv) Write any two rules of naming variable
(v) Differentiate between type conversion and coericion.
(vi) State the difference between final and finally.
(vii) a. State the use of toString( ) and valueOf( ).
b. Write a statement to extract the last word of the string str.
(viii) a. What is called byte code?
b. Explicit and implicit type conversion.
Answer:
(i) double const pi =3.14;
(ii) Unary operator is is used for one operand.
Binary operator is used for two operands.
(iii) (i) Array, class
(ii) “\n”‘;\\’
(iii) //or/*java*/
(iv) Character, Integer
(iv) Variables should not be keyword and it should not start with digit or special character except for the $ and & and _. It must start with alphabet.

Type conversion Coercion
Assigning one data type to another Promotion of data type
It’s called implicit type casting Also called type promotion.

ICSE Class 10 Computer Applications Sample Question Paper 11 with Answers

(v) Final makes a variable constant throughout the program. Finally is a block which is always executed even if exception occurred or not.

(vi) a.

toString( ) valueOf( )
Converts integer to string. Converts strings to integer.

b. String word = str.substring(sr.lastlndexOf(“)+1);

(vii) a. Byte code is an specific set of instruction to be executed by the JVM.
b. Implicit type conversion: Java compiler will automatically convert one data type to another when data types are compatible.
E.g. int 1 = 10;
double b = I;
Explicit type conversion: Java compiler is to be told explicitly to do the conversion form one data type to another.
E.g.
double d = 10.0;
float f = (float)d;

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 11 with Answers

Question 4
Using switch case write a menu driven program to print the patterns.
(a)
0 0 0 0 0
2 2 2 2
6 6 6
12 12
20

(b)
X
YY
XXX
YYYY
XXXXX
Answer:

import java.util.*; 
class Main {
public static void main(String[ ] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the choice:");
int a1 = sc.nextlntO;
switch(al)
{
case 1: int a =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.println( );
}
break;
case 2: for(int i =1 ; i<=5; i++)
{
for(intj=1;j<=i;j++)
{
if(j%2 != 0)
System.out.printC'X");
else
System.out.printC'Y");
}
System.out.printlnO;
}
break;
default: System.out.println("lnvalid Choice");
}
}//end of main 
}//end of class

ICSE Class 10 Computer Applications Sample Question Paper 11 with Answers

Question 5
Write a program to print the frequency of the digits occurring in number.
Eg.2566773
Output:
2 1
5 1
6 2
7 2
3 1
Answer:

import java.util.*; 
class Main {
static int frequency(int number, int digit)
{
int count = 0;
while (number > 0)
{
if (number % 10 == digit) count++;
number = number / 10;
}
return count;
}
public static void main(String args[ ])
{
Scanner sc = new Scanner(System.in);
System.out.println(''Input the number:");
int n = sc.nextlnt( );
int a = n;
int search = 0;
int countdigit = 0;
int []arr = new int[10];
while(a >0)
{
search = a%10;
countdigit = frequency(n,search);
if(countdigit>0)
{
arr[search]=countdigit;
countdigit=0;
}
a=a/10;
}
for(int i =0; 
i<arr.length;i++)
{
if(arr[i]>0)
System.out.println(i+"\t"+arr[i]);
}
}//end of main
}//end of class

ICSE Class 10 Computer Applications Sample Question Paper 11 with Answers

Question 6
Write a class with a special member function to input a multi-digit number(max 9 digit) and print the following:
(i) total number of even and odd digits
(ii) the reverse number
(iii) total number of zeros present.
Answer:

import java.util.*; 
class Main {
public static void main(String args[ ])
{
Scanner sc = new Scanner(System.in);
System.out.priintln("lnput the number:");
long a = sc.nextlntQ;
int sumeven =0;
int sumodd =0, sum3 = 0;
String str - long a1 = a;
while(a1 <=999999999&&a1 !=0)
{
int k= (int)al %10;
str+=lnteger.toString(k);
if(k%2 == 0)
sumeven++;
else if(k%2!=0)
sumodd++;
else if (k==0)
sum3++;
else;
a 1 =a 1/10;
}
System.out.println("No. even: "+sumeven+"\t"+ "odd:"+sumodd+"\ t"+"zero: "+sum3+"\t"+"Reverse no:"+str);
}//end of main 
}//end of class

ICSE Class 10 Computer Applications Sample Question Paper 11 with Answers

Question 7
Write a class to input a string (combination of letters and digits) and replace the repecated characters with star(*) sign. Then display both old and newly created string.
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( );
for(int i=0;i<str.length( );i++)
{
char ch=str.charAt(i); if(ch!='*')
{
for(int j=str.length( )-1;j>i;j—)
{
char ch 1 =str.charAt(j); jf(ch—chi)
{
StringBuffer strl =new StringBuffer(str);
str1.setCharAt(j,'*');
str=""+strl;
}
}
}
}
System.out.println(str);
}//end of main 
}//end of class

ICSE Class 10 Computer Applications Sample Question Paper 11 with Answers

Question 8
Write a program to print the following pattern by taking the input n from the user.
Note: n determines number of rows.
Eg. n = 4
Output:
* * * *
* * *
* * * *
* * *
Answer:

import java.util.*;
class Main {
public static void main(String args[ ])
{
Scanner sc = new Scanner(System.in); 
System.out.println("lnput the number:"); 
int n = sc.nextlnt( ); 
for(int i = 1; i <=n;i++)
{
if(i%2==0)
{
for(int j =1; j<=3;j++) 
System.out.printC *");
}
else
{
for(int j =1; j<=4;j++)
System.out.printC*");
}
System.out.println( );
}
}//end of main 
}//end of class

ICSE Class 10 Computer Applications Sample Question Paper 11 with Answers

Question 9
Write a java class to calculate and print the electricity bill to be paid by a customer.
Assume that the customer pays a rent of Rs.350.00
No. of units — Charge per unit
Upto 100 units — Rs. 1.50
For the next 100 units — Rs. 2.00
For next 50 units — Rs. 2.50
Beyond 250 units — Rs. 4.00
Answer:

import java.util.*; 
class Main {
public static void main(String[ ] args)
{
Scanner sc=new Scanner(System.in); 
double fixed_price = 350.0; 
double amt = 0.0;
System.out.println("Enter a unit of electricity consumption: ");
int n=sc.nextlnt( );
if(n<=100)
amt+= amt+1.5*n;
else if(n>100&&n<=200)
amt+= 100*1,5+(n-100)*2.0;
else if(n>200&&n<=250)
amt+= 100*1.5+0 00)*2.0 + (n-200)*2.5;
else
amt+= 100*1.5+0 00)*2.0 + (50)*2.5+(n-250)*4.0;
System.out.println("Electricity bill amount: "+amt);
}//end of main 
}//end of class
Variable Data Type Description
al int Store users choice
a b int For printing pattern
ij int For looping
number int Number in which digits to be searched
digit int Digit which is to be searched.
count int Counting number of digits
n int Users input number
arr[] int Array of 10 integers.
search, countdigit int Digit to be searched and count of that digit
sumeven,sumodd,

sum3

int Sum of even digits, sum of odd digits and count of zero.
str String User input string
strl String Buffer To store modified string
ch char To store character
fixed „price, amt double For fixed price and calculating amount

ICSE Class 10 Computer Applications Question Papers with Answers

Leave a Comment