## ICSE Class 10 Question Papers with Answers | ICSE Solved Question Papers for Class 10

• ICSE Class 10 Maths Question Papers with Answers
• ICSE Class 10 Physics Question Papers with Answers
• ICSE Class 10 Chemistry Question Papers with Answers
• ICSE Class 10 Biology Question Papers with Answers
• ICSE Class 10 English Language Question Papers with Answers
• ICSE Class 10 English Literature Question Papers with Answers
• ICSE Class 10 Hindi Question Papers with Answers
• ICSE Class 10 History and Civics Question Papers with Answers
• ICSE Class 10 Geography Question Papers with Answers
• ICSE Class 10 Computer Applications Question Papers with Answers

## ICSE Class 10 Computer Application Sample Question Paper 11 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) Give one similarity and one difference between do while and while loop.
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) Write the java statement to find largest of 3 numbers using conditional operator.
int a = (b>c)?b:c;
int d = (a>e)?a:e;

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

(d) Write a function to round off any fractional number? Give one example.
Math.round()
double k = Math.round(2.9);.

(e) What is difference between infinite loop and fall through statement?

 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. Question 2.
(a) Compare local, instance and class variables on the basis of the given criteria.
(i) identification in program
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) Usage of access specifier with them.
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) provision of initial values.
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) Number of copies for each object of class.
local variables multiple copies can exists.
Instance variables multiple copies can exists.
Class variables single copy exists.

(b) Which OOPs principle is implemented when you:
(i) use the keyword extends
Inheritance

(ii) create an interface
Abstraction

(iii) create various functions
Polymorphism

(iv) use private data members?
Encapsulation

(c) What are functions? Give one advantage using functions.
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?
(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.

(e) Differentiate between linear search and binary search.

 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.
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.
exit or return

(ii) used to implement the concept of inheritance.
extends

(c) Attempt the following:
(i) Assign the constant value pi as 3.14 to variable using suitable data type?
double const pi =3.14;

(ii) Give difference between unary and binary operators.
Unary operator is is used for one operand.
Binary operator is used for two operands.

(iii) Give examples of each
(i) Composite date type.
(ii) Escape sequence.
(iii) Comment lines
(iv) Wrapper class
(i) Array, class
(ii) “\n”;\\’
(iii) //or/*java*/
(iv) Character, Integer

(iv) Write any two rules of naming variable
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.

(v) Differentiate between type conversion and coericion.

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

(vi) State the difference between final and finally.
Final makes a variable constant throughout the program. Finally is a block which is always executed even if exception occurred or not.

(vii) a. State the use of toStringO and valueOf().

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

b. Write a statement to extract the last word of the string str.
String word = str.substring(sr.lastlndexOf(‘ ‘)+1);

(viii) a. What is called byte code?
Byte code is an specific set of instruction to be executed by the JVM.

b. Explicit and implicit type conversion.
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.

Question 4.
Using switch case write a menu driven program to print the patterns. import java.util.*;
class Main
{
public static void main(String[ ] args)
{
Scanner sc = new Scanner(System.in);
System.out.printIn("Enter the choice:");
int a1 = sc.nextInt();
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.printIn();
}
break;
case 2: for(int i =1 ; i<=5; i++)
{
for(intj=1;j<=i;j++)
{
if(j%2 != 0)
System.out.print("X");
else
System.out.print("Y");
}
System.out.printIn();
}
break;
default: System.out.printIn("Invalid Choice");
}
}//end of main
}//end of class 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

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.printInC'Input the number:");
int n = sc.nextInt();
int a = n;
int search = 0;
int countdigit = 0;
int []arr = new int;
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.printIn(i+"\t"+arr[i]);
}
}//end of main
}//end of class

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.

import java.util.*;
class Main
{
public static void main(String args[ ])
{
Scanner sc = new Scanner(System.in);
System.out.priintIn("Input the number:");
long a = sc.nextInt();
int sumeven =0;
int sumodd =0, sum3 = 0;
String str = " ";
long a1 = a;
while(a1 <=999999999&&a1!=0)
{
int k= (int)a1 %10;
str+=Integer.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.printIn("No. even: "+sumeven+"\t"+ "odd:"+sumodd+"\ t"+"zero: "+sum3+"\t"+"Reverse no:"+str);
}//end of main
}//end of class 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.

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();
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);
if(ch—chi)
{
StringBuffer strl =new StringBuffer(str);
str1.setCharAt(j,'*');
str=""+strl;
}
}
}
}
System.out.printIn(str);
}//end of main
}//end of class

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: import java.util.*;
class Main
{
public static void main(String args[ ])
{
Scanner sc = new Scanner(System.in);
System.out.printIn("Input the number:");
int n = sc.nextIntO;
for(int i = 1; i <=n;i++)
{
if(i%2==0)
{
for(int j =1; j<=3;j++)
System.out.print("*");
}
else
{
for(int j =1; j<=4;j++)
System.out.print("*");
}
System.out.printIn();
}
}//end of main
}//end of class 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

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.printIn("Enter a unit of electricity consumption: ");
int n=sc.nextInt();
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.printIn("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 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.
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.
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.
(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.
Math.cos(b)
trim().

(e) What do you mean by dynamic initialization of an array? Give an example.
When the array is initialized during the run time of program its called dynamic initialization of array. E.g.
int a[] = new int; 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.
m and y

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

(b) Distinguish between constructor and method.

 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);
}
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;
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.
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?
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);
3 times 60

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

(ii) Name a data type that can hold 16 bit Unicode characters.
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);
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.
array.length and str.length()

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

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

(vii) Differentiate between linear search and binary search.

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

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

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

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.

import java.util.*;
class Main
{
public static void main(String[ ] args)
{
int temp;
String tempi;
String a[ ] = new String;
int age[] = new int;
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 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)}$$

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

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 Sample Question Paper 10 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 abstraction.
Abstraction is the act of representing the essential features of the program without involving in its complexity.
Eg. While using computer user is not concerned about the different parts of the computer only needs to know about usage.

(b) Using an example explain the term object.
Characteristics (big, small, flat etc)

(c) What is wrapper class.
Wrapper class is a class which helps to convert a primitive data type to object type. E.g. Integer, Short etc

(d) State the use of new operator.
New operator supports instantiations. It is used to allocate memory space to the newly created object.
E.g. Scanner sc = new Scanner(System.in)

(e) Write a java expression for square root of sinx.
double d = Math.sin(x*3.14/180);

Question 2
(a) Differentiate between local variable and global variable.

 Local Variable Global Variable Scope remains only inside a block or a function. Scope remains throughout the class. Multiple copies of the variable are used throughout the class. Only a single copy of the variable is used throughout the class.

(b) What is the purpose of default in switch statement?
When none of the cases of the switch statement are satisfied, the default case is used and executed in the program.

(c) Define an impure function.
An impure function is a function where values of the arguments keep changing during the execution of the program.

(d) What is called default constructor?
A default constructor is a constructor without any parameters. It is used to assign a default value to the class variables.

class lol
{
int a; int n;
lol()
{
a=0;
}
lol(int c)
{
a=1;
}
public static void main()
{
lol obj = new lol();
lol obj1=new lol(2);
}
} Question 3.
(a) How java make use of formal and actual parameter?
Formal parameters are used in the function defin ition of the program while actual parameters are used in the function call statement.

(b) State the java concept that is implemented into smaller groups
(i) Dividing a long set of instruction into smaller groups and modules.
object oriented programming

(ii) Wrapping up of data and its associated function into a class.
Encapsulation

(c) Attempt the following:
(i) What is role of access specifier?
Access specifiers are used to moderate the accessibility of the data according to user’s choice.

(ii) Why is java platform independent?
Java is platform independent because the JVM can interpret the byte code which can run on any platform.

(iii) Differentiate between public and private visibility label.
Public: It can be accessed anywhere.
Private: It can be accessed only inside the class.

(iv) Int a = 7,b = 6; b = a>b?a!=0?3:b<10?9:4:8; System.out.printIn(b);
3

(v) Int a = 7,b = 6; b=++a+ ++a/ ++a; System.out.printIn(b);
b=8+9/10=8+0=8

(vi) What are functions? Give one advantage of using functions.
A function is block of statements in a java program used to perform certain tasks. It organizes the data into segments and helps in performing tasks easily.

(vii) How do objects communicate with each other?
Objects communicate with each other using methods.

(viii) What are two types of methods? Give two concrete differences between them and include example of each type of function from java.lang.Math class.

 Pure Function Impure Function Functions where the value of variables don’t change Function where the values of the variables changes. Depends on the actual parameters passed in the function call. Depends on where created object calls the functions. E.g. Math.sqrtO E.g. Math.random(i)

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.
A Smith number is a composite number, the sum of whose digits is the sum of the digits of its prime factors obtained as a result of prime factorization(excluding 1).
The first few such numbers are 4, 22, 27, 58, 85, 94, 121 …………..
eg.666
Prime factors are 2,3,3 and 37
Sum of the digits are (6+6+6) = 18
Sum of the digits of the factors (2+3+3+3+7)=18
Write a program to input a number and display whether the number is a Smith number or not.

import java.util.*;
class Main
{
int sumDig(int n)
{
int sum=0; while(n>0)
{
sum+=n%10;
n=n/10;
}
return sum;
}
int sumPrimeFact(int n)
{
int i=2, sum=0;
while(n>1)
{
if(n%i-=0)
{
sum=sum+sumDig(i);
n=n/i;
}
else
i++;
}
return sum;
}
public static void main(String[ ] args)
{
Main ob=new Main();
Scanner sc = new Scanner(System.in);
System.out.print("Enter a Number:");
int n=sc.nextInt();
int a=ob.sumDig(n);
int b=ob.sumPrimeFact(n);
if(a==b)
System.out.print("lt is a Smith Number");
else
System.out.print("It is Not a Smith Number");
}//end of main
}//end of class Question 5.
Write a program to assign a full path and file name as given below. Using library functions, extract and output the file path, file name and file extension separately as shown.
Input: C:\users\sid\pictures\cricket.jpg
output: C:\users\sid\pictures
File name: Cricket
Extension: jpg

import java.util.*;
class Main
{
public static void main(String args[ ])
{
Scanner sc = new Scanner(System.in);
System.out.priintIntInput the file path:");
String str = sc.nextLine();
String strl = str.substring(0,str.lastIndexOf('\V));
String str2 = str.substring(str.lastIndexOf('\V)+1);
String str3 = str2.substring(str2.indexOf(' ')+1);
System.out.printIn("Path:"+str1);
System.out.printIn("Filename:"+str2);
System.out.printIn("Extension:"+str3);
}//end of main
}//end of class Question 6.
Write a program to input a word from user and remove the consecutive repeated characters by replacing the sequence of repeated characters by its single occurrence.
input: ssiiddaarrtth
Output: sidarth

import java.util.*;
class Main
{
public static void main(String args[ ])
{
String word =
Scanner sc = new Scanner(System.in);
System.out.printIn("Input the sentence:");
String str = sc.nextLine();
char chprev='';
for(int i =0;i<str.length();i++)
{
char ch = str.charAt(i);
if(chprev!=ch)
{
word+=ch;
chprev = ch;
}
else
continue;
}
System.out.printIn("word without successive repeated characters is:"+word);
}//end of main
}//end of class

Question 7.
Write a program in java to input a number and check whether it is Duck number or not.
Note: A Duck number is a number which has zeroes present in it, but there should be no zero present in the beginning of the number. For example 3210, 7056, 8430709 are all duck numbers whereas 08237,04309 are not.

import java.util .*;
class Main
{
public static void main(String args[ ])
{
Scanner sc = new Scanner(System.in);
System.out.printInC'Input the number:");
int a = sc.nextInt();
int a 1 = a; int count =0;
String str = Integer.toString(a);
while(a1!=0)
{
if (str.cha rAt(0)==0)
break;
else
{
int k = a 1 %10;
if(k==0)
count++; a1/=10;
}
}
if(count>=1)
System.out.printIn("Duck no."); else
System.out.printIn("Not Duck no.");
}//end of main
}//end of class

Question 8.
Write a program in java to input a number in Decimal number system and convert it into its equivalent number in the octal number system.
Note: Octal number system is a number system which can represent a number in any other number system in terms of digits ranging from 0 to 7 only. This number system consists of only eight basic digits i.e. 0,1,2,3,4,5,6 and 7.
eg. 25 in the decimal number system can be represented as 31 in the octal number system.

import java.util.*;
class Main
{
public static void main(String args[ ])
{
Scanner sc = new Scanner(System.in);
System.out.printIn("Input the decimal number:");
int a = sc.nextIntO;
int a1 =a%8;
int a2 = a/8;
String str="";
int a3=a2%8;
String strl = Integer.toString(al);
String str2 = Integer.toString(a3);
str=str2+str1;
int ah = Integer.parseInt(str);
System.out.print(ah);
}//end of main
}//end of class Question 9.
Using Scanner class, write a program to input a string and display all those words of the strings which begins with capital letter and end with a small letter.
Sample Input: We all love Java for School Students because of its Uniqueness
Sample Output: We Java School Students Uniqueness

import java.util.*;
class Main
{
public static void main(String args[ ])
{
String word = " ";
Scanner sc = new Scanner(System.in);
System.out.printIn("Input the sentence:");
String str = sc.nextLineO;
str+="";
for(int i =0;i<str.length();i++)
{
char ch = str.charAt(i);
if(ch!='')
word+=ch;
else
{
jf(Character.isUpperCase(word.charAt(0))&&Character.isLowerCase(word. charAt(word.lengthO-1)))
{
System.out.print(word+"");
}
word = " ";
}
}
} //end of main
}//end of class
 Variable Data Type Description sum int To store sum of digits of number n int Number whose digits are to be added sum int To store sum i int To start with 2 b int Store sum of prime factors a int Store sum of digits str String Store the string strl String To store the path str2 String To store filename str3 String Store file extension word String To store modified word ch char to store character chprev char To store previous character a al count int Users input number, modified number and count number of 0 a1 int To store octal number last digit a2 int Quotient after dividing by 8 a3 int Quotient after dividing by 8 strl String To store a 1 as string str2 String To store a2 as string ah int Store converted integer from string.

## ICSE Class 10 Computer Application Sample Question Paper 8 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 an array. Write the ground syntax for declaring the array.
Array is set of data of the same type.
Eg. inta[] = {1,2,3,4,5};

(b) What is conditional /selection statement in java? Name the operator used for condition checking in java.
Conditional statements are used to check a condition and print the output accordingly. Ternary operator.

(c) What is composite data type. Explain using example.
A set of primitive data type is a composite datatype. Eg. Array, Class etc.

(d) Which elements of java program represents characteristics and functions of an object.
Methods and data

(e) Define Polymorphism. Which part of the function differentiates between overloaded functions?
The ability to represent a thing in more than one form. The parameters of the function differentiates between the overloaded functions.

Question 2.
(a) What do you mean by function signature in java?
Function signature is the part which defines the return type, parameters and visibility of a method.

(b) Public static void main() why is main method declared as static?
Main method is declared static because only one copy of the main method is used in the program.

(c) int i=3; i+=(i++*2)+ —i*i++ + ++i/2; System.out.println(i); what is the output of the above code?.
3 + 6 + 9 + 2 = 20.

(d) Why is the string class called as immutable class.
String is immutable because once it is stored, it cannot be altered during the execution of the program.

(e) What’s the use of exception handling in java code:
try{ //code here }catch(IO Exception e) {//some code here }what is the use of e.
It is used to find the run time errors and catch those errors gracefully, e is object of IO exception class it is used as input to the catch function. Question 3.
(a) Why is binary search called as divide and conquer.
Binary search is called divide and conquer because it divides the array into the equal halves and finds the search element in the lower half and upper half of array accordingly.

(b) Differentiate between private and protected access modifiers.
Private: accessibility of data or methods is only inside class.
Protected: accessibility of data or methods is only in subclass and package.

(c) Attempt the following:
(i) Find the output of the following code .
int a=5,b=6,c=9; int g = a>b?a>c?a:c:(b>c)?b:c;
9

(ii) Differentiate between length and length() function.
length is used to find the length of array.
Length() is used to find length of string.

(iii) Define class variable vs instance variable

 Class Variable Instance Variable Only one copy of these variable is used through out the class. Multiple copies of these variables are used throughout the class. Delcared inside the class and outside the methods Declared inside the methods.

(iv) Write java expression for the following;
$$\frac{\cos x+\sin x}{3.14^{*} \sqrt{x}}$$
double x = (Math.cos(x*3.14/180) + Math.sin(x*3.14/180))/ (3.14*Math.sqrt(x));

(v) What is the source code in java and what is its extension.
Source code in java is the set of commands in java to be executed by the JVM. Extension is .java.

(vi) Write one difference between
(i) char type and String type

 CharType String Type Declared using single quotes”. Declared using double quotes”” Compared by operator == Compared by the help of string functions

(ii) “true” and true.
“true” → String value
true → boolean value

(vii) State the escape sequence for vertical tab and new line feed.
“\t”and”\n”

(viii) Which unit of the class gets called when object is created? Give an example
Constructor
E.g.
Class lol
{
Int a;
lol()
{
a=10;
}
Public static void main()
{
lol obj = new lol();
}
}

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 accept the word from user and print the pattern as shown below:
Sample input: COMP
Output:
C
CO
COM
COMP
COM
CO
C

import java.util.*;
class lol
{
public static void main()
{
Scanner sc = new Scanner(System.in);
System.out.printIn("Enter a word");
String str = sc.next();
for(int i =0; i<str.length(); i++)
{
for(int j =0; j<=i; j++)
{
char ch = str.charAt(i);
System.out.print(ch+" ");
}
System.out.printIn();
}
for(int i = str.length()-2; i<=0; i--)
{
for(int j = 0; j<=i; j--)
{
charch = str.charAt(j);
System.out.print(ch+" ");
}
System.out.printIn();
}
}//end of main
}//end of class Question 5
Using switch…case write a menu driven program to print
‘p’:S
SS
ASS
LASS
CLASS

‘x’:
$$x^{1}+\frac{1}{2 !} x^{2}+\frac{1}{3 !} x^{3}+\ldots \frac{1}{n !} x^{n}$$

import java.util.*;
class Main
{
public static void main(String[ ] args)
{
Scanner sc = new Scanner(System.in);
System.out.printIn("Enter p for printing pattern and x for summation series");
charch = sc.next().charAt(0);
switch(ch)
{
case 'p': String str ="CLASS";
for(int i = 0; i<str.length(); i++)
{
for(int j =str.length()-1 -i; j<str.length(); j++)
{
System.out.print(str.charAt(j));
}
System.out.printIn();
}
break;
case 'x': System.out.printIn("Enter the value of x and n");
double x = sc.();
int n = sc.nextInt();
double sum = 0.0; for(int i =1; i <=n; i++)
{
double fact = 1;
for(int j = 1; j <=i; j++) fact*=j;
sum=sum+Math.pow(x/i)/fact;
}
System.out.printIn("sum:" +sum);
break;
default: System.out.printIn("Error");
break;
}
}
}

Question 6.
Write a program to accept sentence from user and print number of words which starts with vowel and ends with vowel.
Input: india is greatest country
Output: 1

import java.util.*;
class lol
{
public static void main()
{
int count =0;
Scanner sc = new Scanner(System.in);
System.out.printIn("Enter a sentence:");
String str = sc.nextLine(), word ="";
for(int i =0; i<str.length(); i++)
{
char ch = str.charAt(i);
if(ch!='')
word = word + ch;
else
{
char ch1 =word.charAt(0);
char ch2 = word.charAt(word.length()-1);
if((ch1=='a' || ch1=='A' || ch1 == 'e'|| ch1 == 'E' || chi =='i,||ch1==T|| ch1 -='u'||ch1 =='U'||ch1 =='o'||ch1 =='0')&&(ch2=='a' || ch2==A' || ch2 == 'e'|| ch2 == 'E' || ch2=='i,||ch2==T||ch2=-,u,||ch2=='U'||ch2==,o,|| ch2=='0'))
{
count++;
}
word
}
}
System.out.printIn(count);
}//end of main
}//end of class Question 7.
Write a program to accept a sentence from the user and convert it into uppercase and display the isogram words available in the sentence and also display the count of such words.
(Isogram are words without repetition of the characters)
Input: An important part of life
Output: An part of life

import java.util.*;
class Main
{
public static void main(String [jargs)
{
int count =0;
Scanner sc = new Scanner(System.in);
System.out.printIn("Enter a sentence:");
String str_ = sc.nextLineO, word ="";
String str = str_.toUpperCase();
for(int i =0; i<str.length(); i++)
{
char ch = str.charAt(i);
if(ch!='')
word = word + ch;
else
{
char [ ]str1 = word.();
for(int k = 0; k<str1 .length-1; k++)
{
for(int j = 0; j<str1 .length—k—1; j++)
{
if(str1[j]>str1[j+1])
{
char temp = strltj];
str 1 [j] = str 1 [j+1 ];
str1 [j+1] = temp;
}
}
}
int flag = 0;
for(int m =0; m < str1 .length-1; i++)
{
if(str1[m] == strl [m+1 ])
{
flag = 1;
break;
}
}
if(flag==0)
{
System.out.print(str1+"");
count++;
}
word
}
}
System.out.priintIn(count);
}//end of main
}//end of class

Question 8.
Write a program to accept names of 20 students and the total marks scored by them. Arrange the names as per the rank list with maximum marks at the top. Display the final names of the students along with their total marks scored.

import java.util.*;
class lol
{
public static void main()
{
String temp; double temp1;
Scanner sc = new Scanner(System.in);
String at ] = new String;
double b[ ] = new double;
for(int i =0; ka.length; i++)
{
System.out.printIn("Enter name & marks:");
a[i] = sc.nextLine();
b[i] = sc.nextDouble();
}
for(int i =0; ka.length; i++)
{
for(int j=0;j<a. length-1 -i; j++)
{
if(b[j] <b[j+1])
{
temp = a[j];
a[j] = a[j+1 ];
a[j+1] = temp;
tempi = b[j];
b[j] = b[j+l];
b[j+1] = temp1;
}
}
}
System.out.printIn("Name" + "\t" + "Marks");
for(int i =0; i<a.length; i++) System.out.printIn(a[i]+"\t"+b[i]);
} //end of function main
}//end of class Question 9.
Write a program to accept a word in upper case and display the position of each alphabet i.e A as 1 B as 2 …Y as 25 and Z as 26.
Sample Input: CAT
Sample Output:
C 3
A 1
T 20

import java.util.*;
class lol
{
public static void main()
{
Scanner sc = new Scanner(System.in);
System.out.printIn("Enter a word:");
String str = sc.next();
String strl = str.toUpperCase();
forfint i =0; i<str.length(); i++)
{
char ch = str.charAt(i);
int a = ch-64;
System.out.printIn(ch+"\t"+a);
}
}//end of function main
}//end of class
 Variable Data Type Description ch char For option porx str String To store “CLASS” X double Variable in the series sum double Stores the sum of series fact double Factorial of number it stores Str_ String Stores the word given by user Str1[] char String converted into the character array. temp char Temporary storage for character for swapping flag int To check for next consecutive same characters. m int For looping a[] String String array to store 20 strings. b[] double Array to store 20 marks str1 String Store all the capital letter word. a int Store the ascii value of character

## 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()
boolean

(ii) rint().
double

(b) What do you mean by compound statement. When do you need it.
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.

 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.
It has same name as that of class. It has no return type.

(e) Define abstraction.
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?
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?
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?
The ‘new’ keyword supports instantiation. It allocates memory for the newly created object.

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

class lol
{
int a;
lolO
{
a = 1;
}
lol(int b)
{
a = b
}
void main()
{
lol obj = new lol();
lol objl= new lol(3);
}
} Question 3.
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().

 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.

 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
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.
java.util and constructor.

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

(v) What is meant by inheritance.
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.

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

(viii) inta[]={1,2,3};System.out.println(a++);System.out.println(++a);
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

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 Question 5.
Write a program to print the longest word from the sentence and print the number of characters of the longest word.

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.

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 Question 7.
Using switch case write a menu driven program to print the patterns. 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”.

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

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"))
else if(word.equals("has"))
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 Sample Question Paper 7 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) (i) Name the keyword that makes the variable constant in a program.
final

(ii) Name the keyword that makes the system to report an error.
throws

a. Differentiate between equals() and equalslgnoreCase()

 equals() equalslgnoreCase() Compare two strings character by character. Eq: String si = “lol”, s2 = “lol1”; System.out.print(s1.equals(s2)); Compares two strings ignoring the case of the letters. Eg: String s1 = “lol”,s2=”lol”; System.out.print(s1. equalslgnoreCase(s2);

b. What is the use of access specifier. Name any two.
Access specifiers are used to limit the visibility of data according to the users choice.
Eg. private, public.

c. String s1 = “computer” , s2 =”computers”; System.out.
printIn(s1.compareTo(s2);
-1

d. Differentiate between linear search and binary search.

 Linear Search Binary Search One by one search element is compared with all elements of the array. The array is sorted and then divided into two halves and then search element is compared to the middle element of the array, if its greater than middle element then search is to be done in upper halves and its its lesser than middle element search to be done in lower halves. The array need not to be sorted. The array must be sorted.

Question 2.
(a) Write the memory occupied in computer in bytes for array a of character data type.
10 bytes 24 bytes

(b) Differentiate between length() and length functions.

 Length() Length The method is applicable for finding the length of string. This is used for finding the array length.

(c) What is error? How logical error differ from syntax error?
When there is an improper use of statement or statement is logically incorrect then an error is displayed.
Syntax error is displayed when there is improper use of basic java statements.
Logical error is displayed when statement is not giving correct output after execution.

(d) Name the methods of scanner class that:
(i) Is used to input an integer data from standard input stream.
nextInt()

(ii) Is used to input a string data from standard input stream.
nextLine() or next()

(e) Write the statement to perform the following task:
(i) To find and display the position of the first space in the string str
System.out.printIn(“COMP IS FUN”.indexOf(”));

(ii) To find and display the position of the last space in string str.
System.out.printIn(“COMP IS FUN”.lastindexOf(”)); Question 3.
(a) The arguments of the function given in the function definition are called
formal parameters

(b) Why JVM is required for running java program. Justify your answer.
JVM is used to convert the byte code into machine language which can be run on any machine. In java, the compiler produces machine code for a particular system. Java compiler produces code for a Virtual Machine known as Java Virtual Machine.

(c) Attempt the following:
(i) What is called type casting in java. Explain with example.
The conversion of data from one data type to another datatype is called typecasting.
Eg. char ch =’A’;
Int ch 1 = ch;

(ii) Write all the possible correct syntaxes of declaring array.
int a[ ] = new int ;
int a[ ];
int a[] = {1,2,3};

(iii) What is the purpose of new operator. Why is it useful?
The purpose of new operator is to allocate memory to the object. It is helpful in the creation of new object.

(iv) double as =Math.pow(“214”.indexOf(‘4’,3));
8.0

(v) char a[ ] = {‘j’/a’/v’/a’}; int c = 1;
System.out.pritnln(a[++c]);
System.out.pritnln(a[c]++);
(i) v
(ii) a

(vi) Explain the use of return statement in the java.
It is the keyword in java to return from the method with value or without value.

(vii) State the purpose and return data type of the following String functions:
(i) indexOf()
(ii) compareTo()
(i) Find the index of a character return type is integer.
(ii) Compares two strings return type is integer.

(viii) State the output of the code:
int m = 25; int n = 100;
for(int 1 = 1; i<5; i++); m++; -n;
System.out.printIn(“m=”+m);
System.out.printIn(“n=”+n);
m=20, n=9

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 descripticns/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 accept the word from user and print the pattern as shown below:
Sample Input: COMP
Output:
C
CO
COM
COMP
COM
CO
C

import java.util.*;
class lol
{
public static void main()
{
Scanner sc = new Scanner(System.in);
System.out.printIn("Enter a word");
String str = sc.next();
for(int i =0; i<str.length(); i++)
{
for(int j =0; j<=i;j++)
{
charch = str.charAt(i);
System.out.print(ch+" ");
}
System.out.printInO;
}
for(int i = str.length()—2; i<=0; i—)
{
for(int j = 0; j<=i; j—)
{
char ch = str.charAt(j);
System.out.print(ch+"");
}
System.out.printIn();
}
}//end of main
}//end of class Question 5.
Write a program to accept the 15 names in the array and arrange them in alphabetical order by bubble sort technique only. And print the output list.

import java.util.*;
class lol
{
public static void main()
{
String temp;
String a[ ] = new Stringfl 5];
Scanner sc = new Scanner(System.in);
System.out.printIn("Enter a 15 names");
for(int i =0; ka.length; i++)
{
a[i] =sc.nextLine();
}
forfint i = 0; i<a.length; i++)
{
for(int j =0; j<a.length-i-1; j++)
{
if(a[j].compareTo(a[j++])>0)
{
temp = a[j];
a[j]=a[j+1];
a[j+1] = temp;
}
}
}
for(int i =0;
ka.length; i++)
{
System.out.printIn(a[i]);
}
}//end of main
}//end of class

Question 6.
Write a program to accept sentence from user and print number of words which starts with vowel and ends with vowel.
Input: india is greatest country
Output: 1

import java.util.*;
class lol
{
public static void main()
{
int count =0;
Scanner sc = new Scanner(System.in);
System.out.priintIn("Enter a sentence:");
String str = sc.nextLine(), word ="";
for(int i =0; i<str.length(); i++)
{
char ch = str.charAt(i);
if(ch!='')
word = word + ch;
else
{
char ch1 =word.charAt(0);
char ch2 = word.charAt(word.length()-1);
if((ch1=='a' || ch1=='A' || ch1 == 'e'|| ch1 == 'E' || chi =='i'||ch1 ==T|| ch1=='u'||ch1=='Uj|ch1=='o'||ch1=='O')&&(ch2=='a' || ch2=='A' || ch2
== 'e'|| ch2 == 'E' || ch2=='i'||ch2=='l'||ch2=='u'||ch2=='U'||ch2= 'o'|| ch2=='O'))
{
count++;
}
word
}
}
System.out.printIn(count);
}//end of main
}//end of class Question 7.
Write a program to arrange the words in sentence given by user in alphabetical order. Assume input is in lower case letters only.
Input: india is my country
Output: country india is my

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

Question 8.
Write a program to accept integer values in the array and find the second lowest value from the array without sorting the array.
inta[] = {3.10.4,8,12,6,23}
Output: 4

import java.util.*;
class lol
{
public static void main()
{
int count =0;
int sum = 0;
Scanner sc = new Scanner(System.in);
int a[] = new int;
System.out.printIn("Enter 10 values:");
for(int i =0; ka.length; i++)
{
a[i] = sc.nextInt();
}
int low=0;
int secondlow=low;
for(int i =0; i<a.length; i++)
{
if(low >a[i])
{
secondlow=low;
low = a[i];
}
}
System.out.printIn(secondlow);
}//end of main
}//end of class Question 9.
Write a function to display the given pattern: void pattern (int n)
Note: n is the number of rows: import java.util.*;
class lol
{
public void pattern(int n)
{
int n = 5;
int I = 0;
for(int i =1; i<=n; i++)
{
int k = 1;
for(int j = 1; j<=i; j++)
{
System.out.print(k+" ");
k+=2;
}
int l1 = l;
for(int j = 2;j<=i;j++)
{
System.out.print(l1+" ");
l1 ++;
}
l+=2;
System.out.printIn();
}
}//end of function pattern
}//end of class
 Variable Data type Description sc Scanner Object for reading data from input stream. str String Store word from user ij int For looping ch char To reach one character from word. a[ ] String String array for storng 15 names. temp String Storing temporary strings. count int For counting the vowels word String Temporary for storing string low secondlow int Store lowest value and store second lowest value.

## ICSE Class 10 Computer Application Sample Question Paper 6 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) Define encapsulation.
Encapsulation is wrapping up of data and its associated functions
into a single unit. It is achieved by the use of access specifiers like 1 public, private, and protected.

(b) What are keywords? Give an example.
Keywords are tokens in java that have a specific meaning.
E.g. static

(c) Name any three library packages.
java.lang
java.io
java.util

(d) Name the three types of error, syntax, runtime or logical error in the following case below:
(i) Math.sqrt (36 – 45)
(ii) int a;b;c
(i) logical
(ii) Syntax

(e) If int x [ ] = {4,3,7,8,9,10}; what are the values of p and q?
(i) p = x.length
(ii) q = x + x*x
(i) 6
(ii) 37 Question 2.
(a) State the difference between = = operator and equals () method.

 = =operator equals() It compares two primitive data types It compares two strings

(b) What are the type of casting shown by the following examples:
(i) char c (char) 120;
(ii) int x = ‘t’;
(i) Explicit
(ii) Implicit

(c) Differentiate between formal parameter and actual parameter.
Formal parameters are used in the function definition using arguments as the input to the function.
Actual parameters are used in calling the above function by passing values.

(d) Write a function prototype of the following:
A function PosChar which takes a string argument and a character argument and returns an integer value.
int PosChar(String str, char ch);

(e) Name any two types of access specifiers.
private and protected.

Question 3.
(a) Define an impure function.
An impure function is a function where the values passed in the formal arguments of function is reflected back in the main function when values are changed by the called function.

void lol()
{
String str = “lol”;
‘ }
void lol(int a)
{
String str1 = “lol”;
}

(c) What is default constructor and where is it useful?
Default constructor is a constructor without any parameter. It is used to initialize class variables to their default values.

(d) State the difference between selection sort and bubble sort.

 Selection Sort Bubble Sort One element is compared with all the elements of the array and position is exchanged at the end of comparison. Adjacent elements of the array are compared and exchanged.

(e) Int i = 5;
if (++5/2 = =0)
System.out.print(“EVEN”);
else
System.out.print(“ODD”);
error

(f) Convert the following while loop to the corresponding fir loop:
int m = 5, n =10; while (n>=1)
{
System.out.printIn(m*n); n –;
}
50
45
35
30
25
20
15
10
5

(g) Write one difference between primitive data types and composite date types.
Primitive data type: Its fundamental data types of java.
Composite data type: It’s a combination of primitive data type.

(h) Analyze the given program segment and answer the following question:
(i) Write the output of the program segment
5
10

(ii) How many times does the body of the loop get executed?
for (int m = 5; m<=20; m+=5)
{
if(m%3==0)
break;
else
if (m%5==0)
System.out.println(m);
continue;
}
3

a. Give the output of the following expression:
a+=a++ + ++a H a + a–; when a=7
39

b. Write the return type of the following library
(i) isLetterOrDigit(Char)
(ii) replace(char, char)
(i) boolean
(ii) String

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.
Define a class named BookFair with the following description:
Instance variables/Data members String Bname – stores the name of the book double price – stores the price of the book
Member methods
(i) BookFair() – Default constructor to initialize data members
(ii) void input() – To input and store the name and the price of the book.
(iii) void calculate() – To calculate the price after discount. Discount is calculated based of the following criteria

 Price Discount Less than or equal to rs  10000 2% of the price More than rs 1000 and less than or equal to rs3000 10% of the price More than rs3000 15% of the price

(iv) void display() – To display the name and price of the book after discount.
Write a main method to create an object of the class and call the above member methods.

import java.util.*;
class BookFair
{
String Bname;
double price;
BookFair ()
{
Bname = "";
price = 0.0;
}
void input ()
{
Scanner sc = new Scanner(System.in);
System.out.printIn("Enter name and price of the book:");
Bname = sc.nextLine();
price = sc.nextDouble();
}
void display()
{
System.out.printIn(" Name: "+Bname+"\n"+"Price:"+price);
}
void calculate()
{
double discount =0;
if(price <= 1000)
discount = (2.0/100.0)*price;
else if(price >1000 && price <= 3000)
discount = (10.0/100.0)*price;
else if(price >3000)
discount = (15.0/100.0)*price;
else;
price = price - discount;
}
public static void main()
{
BookFair bf = new BookFair();
bf.input();
bf.calculate();
bf.display();
}
} Question 5.
Using the switch statement, write a menu driven program
(i) To print the Floyd’s triangle [Given below] (ii) To display the following pattern For an incorrect option, an appropriate error message should be displayed

import java.util.*;
import java.math.*;
class lol
{
public static void main(String[ ] args)
{
Scanner sc = new Scanner(System.in);
System.out.printIn("Enter 1 for number pattern and 2 for string pattern");
int opt = sc.nextIntO;
switch(opt)
{
case 1: int a = 1;
forfint i =1;i<=5;i++)
{
for(int j = 1;j<=i;j++)
{
System.out.print(a+"");
3++;
j
System.out.printInO;
}
break;
case 2 : String str = "ICSE";
for(int i =0;i <str.length();i++)
{
forfint j =0;j<=i; j++)
{
char ch = str.charAt(j);
System.out.print(ch+" ");
}
System.out.printInO;
}
break;
default: System.out.printIn("ERROR");
}// end of switch
}//end of main
}//end of class

Question 6.
Special words are those words which starts and ends with the same letter
Example:
EXISTENCE
COMIC
WINDOW

Palindrome words are those words which read the same from left to right and vice versa
Example:
MALYALAM
LEVEL
ROTATOR
CIVIC
All palindromes are special words but all words are not palindromes.
Write a program to accept a word check and print whether the word is a palindrome or only a special word

import java.util.*;
class Main
{
public static void main(String [ ]args)
{
Scanner sc = new Scanner(System.in);
System.out.printIn("Enter a word:");
String str = sc.next();
String word ="";
for (int i = str.length()-1;i >=0;i--)
{
char ch = str.charAt(i);
word = word+ch;
}
if(word.equals(str))
System.out.printIn("Palindrome");
else
{
if(str.charAt(0)==str.charAt(str.length()-1))
System.out.printIn("special word");
}
}
} Question 7.
Design a class to overload a function SumSeriesQ as follows:
(i) void SumSeries(int n, double x) – with one integer argument and one double argument to find and display the sum of the series given below:
s + $$\frac{x}{1}-\frac{x}{2}+\frac{x}{3}-\frac{x}{4}+\frac{x}{5}$$ ……….. to n terms
(ii) void SumSeriesO – To find and display the sum of the following series:
s = 1+(1*2)+(1*2*3)+………..+(1*2*3*4* n)

import java.util .*;
class lol
{
void sumseries(int n, double x)
{
double sum =0;
for(int i =1;i<=n;i++)
{
if(i % 2 == 0)
{
sum = sum -(x/i);
}
else
{
sum = sum + (x/i);
}
}
System.out.printIn("sum = "+sum);
}
void sumseries()
{
long sum = 0;
long product = 1;
for(int i = 1;i <=20;i++)
{
product = product * i;
sum+= product;
}
System.out.printIn("sum = "+sum);
}
}

Question 8.
Write a program to accept a number and check and display whether it is a Niven number or not. (Niven number is that number which is divisible by its sum of digits).
Example:
Consider the number 126.
Sum of its digits is 1+2+6 = 9 and 126 is divisible by 9.

import java.util.*;
class lol
{
public static void main(String []args)
{
Scanner sc = new Scanner("System.in");
System.out.printIn("Enter a num:");
int a = sc.nextInt();
int al = a;
int sum =0;
while(a1!=0)
{
int k = a 1 % 10;
sum = sum+ k;
a1/= 10;
}
if(a%sum ==0)
System.out.printIn("Niven number");
else
System.out.printIn("Not Niven number");
}//end of main
}// end of class Question 9.
Write a program to initialize the seven Wonders of the World along with their locations in two different arrays. Search for a name of the country input by the user. If found, display the name of the country along with its Wonder, otherwise display “Sorry Not Found!”
Seven wonders – CHICHEN ITZA, CHRIST THE REDEEMER, TAJMAHAL, GREAT WALL OF CHINA, MACHU PICCHU, PETRA, COLOSSEUM
Locations – MEXICO, BRAZIL, INDIA, CHINA, PERU, JORDAN, ITALY
Example – Country Name: INDIA Output: INDIA -TAJMAHAL

import java.util.*;
class lol
{
public static void main(String args[ ])
{
String wonder[ ]={"CHICHEN ITZA","CHRISTTHE REDEEMER", "TAJMAHAL", "GREATWALL OF CHINA","MACHU PICCHU","PETRA","COLOSSEUM"};
String country} ]={"MEXICO","BRAZIL1,"INDIA","CHINA","PERU","JORDAN","ITALY"};
String str;
int i,len;
Scanner sc=new Scanner(System.in);
System.out.printIn("Enter the name");
str=sc.nextLine();
len=str.length();
boolean flag=false;
for (i=0;i<len;i++)
{
if(str.equalslgnoreCase(country[i]))
{
System.out.printIn(country[i]+""+ wonderfi]);
flag =true;
break;
}
}
if(flag== false)
}//end of main
}//end of class
 Variable Data Type Description discount Double store discount value opt int Option number ij int For looping a int For printing pattern ch char Reading each character of word. str String To read word word String To store reverse word sum double Store the series of sum product long Stores product of integers. a int Read users number a1 int Modifying the digits flag boolean To check true or false

## ICSE Class 10 Computer Application Sample Question Paper 5 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 the use of’this’keyword in parameterized constructor?
This keyword in parameterized constructor is used to refer to the currently calling object.

(b) State the differences between static and dynamic initialization.
Static initialization is used when memory is already allocated and then value is assigned.
Dynamic initialization is used to calculate the value at the run time and then allocate the memory.
E.g. int a = 6,b=9;//static memory allocated.
int c = a*b; //dynamic memory allocation.

(c) What is local variable and global variable? Explain with example.
Local variable is a variable whose scope remains inside a method or a block of statements in a java program.
The Global variable is a variable whose scope lies throughout the class in the java program.

(d) Which is not keyword in Java:
(i) boolean
(ii) void
(iii) public
boolean

(e) int a [ ]; int b [ ] = new int ; what is the difference between two initialization.
int a[ ]: the array is declared without any allocation of memory space to it.
int b[ ] = new int ; The array is declared along with the allocation of memory to it. ie. 400 bytes. Question 2.
(a) State difference between constructor and method of class.

 Constructor Method It has same name as that of class. It has different name than that of class. It has no return type. It is called when object is created. It has a return type and is called by the object.

(b) char ch[ ] = {‘a’, ‘b’, ‘c’, ‘d’};
System.out.println( “hello world”+ch);
What will be the output of the above code?
Hello world a b c d

(c) Define Java byte code.
The set of instructions to be executed by the JVM is called java byte code. JVM is the interpreter for java byte code

(d) State the difference between operator and expression.

 Operator Expression It is used to perform an operation. Set of operators used to perform multiple function. int a =1, b =2; int c = a+b; Int a =1; a+ = (a++)- ++a + –a;

(e) What parse function does? Explain with example.
Parse function converts the value of a primitive data to the value of another primitive data type.
E.g.: String a = “24”;
int a = Integer.parseInt(a);

Question 3.
(a) What is the use of keyword in void in function declaration.
The keyword void is used to tell that function has no return type.

Polymorphism.

(c) Attempt the following:
(i) Name string function which compares two strings and returns boolean value
equals()

(ii) Write Java statement to do the reverse loop from 19 to 0.
int i = 19;
do {
System.out.printIn(i);
i–;
}while(i>0);

(iii) Define Java token.
Java token is the smallest unit of a java program.

(iv) What’s the value of y after execution.
Inty = 5;
y — = ++y + ++y + ++y*3;
5 + 6 + 7*3 = 5 + 6 + 24 = 32.

(v) int a [ ] = {‘a1, ‘b’ ‘c’, ‘A’, ‘B’, ‘C, ‘D’, ‘E’};
System.out.println ((int) a);
System.out.println (a.length);
System.out.println (a);
What will the output of the above code?
65
8
66

(d) Write output
inti = 20
for(; I<=30; i+=4)
System.out.print(i);
System.out.println(i)
20 24 28 32

(e) Name the formal and actual parameter.
Formal parameter: When the identifier used in function definition to accept the values from the calling function is called the formal parameter.
Actual parameter: when the function is called by passing the identifiers which has values are called as actual parameter.

(f) What is the difference between next () and nextLine ()?
next(): it accepts only the word without blank spaces.
nextLine() : It can accept more than one word as well.

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.
Define a class salary described as below:
Data Members: Name, Address, Phone, Subject Specialization, Monthly Salary, Income Tax
Member methods:
(i) To accept the details of a teacher including the monthly salary.
(ii) To display the details of the teacher.
(iii) To compute the annual income tax as 5% of the annual salary above
rs. 1,75,000/-
Write the main method to create object of the class and call the above member method.

import java.util.*;
class salary
{
String sub; double ms, it;
long ph;
salary ()
{
ms =0.0;
it = 0.0;
ph=0;
}
void input ()
{
Scanner sc = new Scanner(System.in);
System.out.printIn("Enter name address subject monthly salary and phone number:");
name = sc.nextLine();
sub = sc.nextLine();
ms = sc.nextDouble();
ph = sc.nextLong();
}
void displayO
{
System.out.printIn(" Name: "+name+'\n"+sub+''\n"+"monthly salary:"+ms+ "\n"+"Phone no:"+ph);
}
void calc()
{
if(ms*12<=175000)
it = 0;
else
it = 5.0/100.0 * (ms*12); ms = ms*12 - it;
}
public static void main()
{
salary oly = new salary();
oly.input();
oly.display();
oly.calc();
}
} Question 5.
Write a program to initialize the given data in an array and find the minimum and maximum values along with the sum of the given elements.
Numbers: 2 5 41 3
Output: Minimum value:1
Maximum value: 5
Sum of the elements:

import java.util.*;
public class Main
{
public static void main(String[ ] args)
{
int arr[ ] = new int;
Scanner sc = new Scanner(System.in);
for(int i =0;i<10;i++)
{
System.out.printIn("enter a number: ");
arr[i] = sc.nextInt();
}
int min = 100000;
int max = 0;
int sum = 0; for(int i =0;i<10;i++)
{
if (arr[i] < min)
min = arr[i];
if(arr[i]>max)
max = arr[i];
sum+= arr[i];
}
System.out.printIn("Minimum value: "+min);
System.out.printIn("Maxmimu value: "+max);
System.out.printIn("Sum of elements: "+sum);
}//end of main
}//end of class

Question 6.
Define a class to overload following function

 double area (double a, double b, double c) A = √s (s-a) (s-b) (s-c) S = (a+b+c)/2 double area (double x, double y, double h) area = 1/2 h* (x+y) double area (double m, double n) area = 1/2 m*n

import java.util .*;
import java.math *;
class lol
{
double area(double a, double b, double c)
{
double s = (a + b + c)/2.0;
double ar = Math.sqrt(s*(s-a)*(s-b)*(s-c));
return ar;
}
double area(double x,double y,double h,int a)
{
double ar1 = 1.0/2.0 *h*(x+y);
return arl;
}
double area(double m, double n)
{
double ar2 = 1.0/2.0*m*n;
return ar2;
}
}

Question 7.
Write a program to enter a sentence from the keyboard and count the number of times a particular word occurs in it. Display the frequency of the search word.
Example:
INPUT:
Enter a sentence: the quick brown fox jumps over the lazy dog.
Enter a word to be searched: the
OUTPUT:
Searched word occurs: 2 times.

import java.util.*;
class lol
{
public static void process(String a, String str)
{
String word ="";
int count =0 ;
for(int i =0; i <str.length();i++)
{
char ch = str.charAt(i);
if(ch!='')
word = word+ch;
else
{
if(a.equals(word))
count++;
}
}//end of for loop
System.out.printIn(count);
}
} Question 8.
Write a program to create two array names A and B of same size 7. Perform the following operation:
(i) Input in an array A and find square of each number and store in array B and display both array simultaneously.
(ii) Display square root of each number from array A and display square root.

import java.util.*;
import java.math.*;
class lot
{
public static void main()
{
Scanner sc = new Scanner(System.in);
int a[] = new int ;
int b[] = new int;
System.out.printIn("enter a number: ");
for(int i =0;i <a.length; i++)
{
a[i] = sc.nextInt();
b[i] = a[i]*a[i];
}
for(int i =0;i <a.length; i++)
{
System.out.printIn(a[i]+""+b[i]);
}
for(int i =0; i<a.length; i++)
{
double k= Math.sqrt(a[i]);
System.out.printIn(k);
}
}//end of main
}//end of class

Question 9.
Write a program to input a number from user and using binary search method find the number is present in the given array or not. Display proper message.
Array is A [ ] = {24,39,330,343, 763, 789, 909,1001,1212, 2000}

import java.util.*;
import java.math.*;
class lol
{
public static void main()
{
int arr[ ] = {24,39,330,343,763,789,909,1001,1212,2000};
int first = 0;
Scanner sc = new Scanner(System.in);
System.out.printIn("enter a number:");
int key = sc.nextInt();
int last = arr.length-1;
int mid = (first + last)/2;
while(first <= last)
{
if (arr[mid] < key)
{
first = mid + 1;
}
else if (arr[mid] == key)
{
System.out.printIn("Element is found at index:" + mid); break;
}
else
{
last = mid - 1;
}
mid = (first + last)/2;
}
if (first > last)
{
}
}//end of main
} //end of class
 Variable Data Type Description ms double Store monthly salary it double Income tax arr[] int Store 10 integers min,max,sum int Minimum value maximum value and sum of all elements. s a b c double Semiperimeter lengths of triangle. ar,ar1,ar2 double Area of shapes word String Store new word count int Store number of similar words. a[]b[] int Array of integers and squares k double Square root of number arr[] int Static array key int Number to be searched. first last and mid int Indexes of array

## ICSE Class 10 Computer Application Sample Question Paper 4 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 encapsulation? How does Java achieve encapsulation?
Encapsulation is the wrapping of the data and its associated functions into a single unit. Java achieve encapsulation by enclosing the data and methods in the class.

(b) True or False:
(i) The default case is compulsory in the switch case statement
(ii) The default initial value of a boolean variable data type is false.
(i) False
(ii) false

(c) Define the term byte code.
High level program is compiled by java compiler to put in language called bytecode. This is understood by JVM in executing it.

(d) What is the result code stored in x, after evaluating the following expression:
intx = 5;
x+ =++*2+3*-x;
30

(e) What is function prototype? Write a function prototype of:
A function poschar which takes a string argument and a character argument and returns an integer value.
Function prototype is the declaration of function with its return type and number of arguments and data type of arguments.
int PosChar(String str, char ch); Question 2.
(a) Show how the sequence {10, 5, 8, 12, 45, 1, 9, 11, 2, 23} changes step by step during the first two passes while arranging in ascending order using the bubble sort technique.
10,5,8,12,45,1,9,11,2,23
5.10.8.12.45.1.9.11.2.23
5.8.10.12.45.1.9.11.2.23

(b) How will you import a scanner package? What is the default delimiter of an instance of the scanner class?
import java.util.*; Default delimiter for scanner class is white space or tab or newline.

(c) Differentiate between Character. isUpperCase( ) and Character, to UpperCase()
Character.IsUpperCaseO checks the uppercase character and returns boolean value.
Character.toUpperCaseO converts lower case character to upper case character and returns upper case character.

(d) Write a Java expression:! = 2π√L/g
doube T = 2*3.14 * Math.sqrt(l/g);

(e) What is fall through? Give example.
Fall through is a way in which all the cases of switch statement will be executed one by one if break is not encountered.
E.g. After case B is executed it executes case C to F.
{
case ‘A’:
System.out.printlnC’Excellent!”);
break;
case ‘B’:
case ‘C’:
System.out.printlnC’Well done”); case ‘D’ :
System.out.println(“You passed”); case ‘F’:
System.out.println(“Better try again”);
break;
default:
}

Question 3.
Write the output of the following print statement:
(a) System.out.print (“IXIXI”,replace(‘X ‘/CJ.indexOfCO.indexOfCC’^));
3

(b) System.out.print(“robotics”.substring(!3).concat(“subject”.substring(3)));
object

(c) System.out.printC’FUN WORLD”.startsWith(“FUN”)== (“COMPUTER IS FUN”.endsWith(“FUN”)));
true

(d) System.out.print(Math.sqrt(Math.abs(Math.ceil(-25.25))));
5.0

(e) System.out.print(Math.max(Math.pow(Math.round(6.25),2),(Math. pow(Math.rint(1.8),3))));
36 Question 4.
Write the output of the following segment of code: (a) 65
66
89
90

(b) 100

(c) 12
15
20
27
36

(d) 1615
1817
2019
2221
2423

(e) Hello
Hello

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 5.
Given below is hypothetical table showing rates of Income Tax for male citizens below the age of 65 years:

 Taxable Income (TI) in Rs. Income Tax in Rs. Does not exceed 1,60,000 NIL Is greater than 1,60,000 and less than or equal to 5,00,000 10% of the amount exceeding 1,60,000 Is greater than 5,00,000 and less than or equal to 8,00,000 20% of the amount exceeding 5,00,000 + 34000 Is greater than 8,00,000 30% of the amount exceeding 8,00,000 + 94000

Write a program to input the age, gender(male or female) and Taxable Income of the person. If the age is more than 65 years or the gender is female, display “wrong category”. If the age is less than or equal to 65 years and the gender is male, compute and display the Income Tax payable as per the table given above. Also if Income Tax calculated in over Rs.10,000/- then extra surcharge payable is 2% of the income tax.

import java.util.*;
class Incometax
{
public static void main()
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter your gender m or f:");
char ch = sc.next().charAt(0);
if(ch==,f,||ch=='F')
{
System.out.printIn("Wrong Category");
}
else if(ch=='m||ch=-M')
{
int age = sc.nextInt(); if(age>65)
{
System.out.printIn("Wrong Category");
}
else
{
double inc = sc.nextDouble();
double tax;
if(inc<=l 60000) { tax=0; } else if((inc> 160000)&&(inc<=500000)) { tax = (inc—160000)*0.1; 1 else if((inc>500000)&&(inc<=800000)) { tax = (inc-500000)*0.2; tax += 34000; } else { tax = (inc-800000)*0.3; tax += 94000; } if(tax > 10000)
tax+= tax* 0.02;
System.out.printIn("\nIncomeTax is INR "+tax);
}
else
{
System.out.printInC'Invalid Gender");
}
}//end of main
}//end of class Question 6.
Define a class Customer described as below:
Data members/instance variables:
String card_holder: Name of the card holder, long cardjiolder: card Number
char card_type: type of card (Silver (S) / Gold (G) / Platinum (P)) double amt: purchase made using the card.

Member methods:
(i) Customer!): Default constructor to initialize all the date members
(ii) void input(): To accept the details of the card holder
(iii) void compute( ): To compute the cash back after availing the discount of a specific card type as per the following:

 Card Type Cash Back Silver (S) 2% of purchase amount Gold (G) 5% of purchase amount Platinum (P) 8% of purchase amount

(iv) void display(): To display the details in the format: Write a main method to create an object of the class and call the above member methods.

import java.util.Scanner;
class Customer
{
String card_holder;
long card_no; charcard_type;
double amt- double cash_back;
public Customer()
{
card_holder="";
card_no =0;
card_type =' ';
amt = 0.0;
}
public void input()
{
Scanner scanner = new Scanner(System.in);
System.out.print("Enter customer name:");
card_holder = scanner.next();
System.out.printfEnter card number:");
card_no = scanner.nextInt();
System.out.print("Entertype of the card [S/G/P: ");
card_type = scanner.next().charAt(0);
System.out.print("Enter amount of purchase made using the card:");
amt = scanner.nextDouble();
}
public void compute()
{
if (card_type == ’S')
{
cash _back = amt * 0.02;
}
else if (card_type == 'G')
{
cash_back = amt * 0.05;
}
else if (card_type == 'P')
{
cash_back = amt * 0.08;
}
else
.{
System.out.printf'Invalid card type ");
}
}
public void display!)
{
System.out.printIn("Card Holder. \tCard Number. \t Card type \t Purchase Amount \t Cash back");
System.out.printIn(card_holder + "\t" + card_no + "\t" + card_type + "\t" + amt);
}
public void main()
{
Customer cl = new Customer();
cl.input();
cl.compute();
cl.display();
}

Question 7.
Accept a sentence and print a new sentence with all the odd placed words in uppercase and even placed words in lower case.
Sample input: It is a beautiful world
Sample output: IT is A beautiful WORLD

import java.util.*;
class lol
{
public static void main()
{
Scanner sc = new Scanner(System.in);
System.out.printIn("Enter a string:");
String str = sc.nextLine();
String strl = str.toLowerCase();
str1+=" ";
String word =" ";
int count = 0;
for(int i =0; i < strl ,length();i++)
{
char ch = strl .charAt(i);
if(ch!='')
{
word+=ch;
}
else
{
count++; if (count %2 !=0)
{
System.out.print(word.toUpperCase()+"");
}
else
System.out.print(word+"");
word ="";
}
}
}
} Question 8.
Using switch statement, write a menu driven program to
(i) Accept a number and find a sum of all the even numbers in the number.
Sample input: 24567
Sample output: Sum = 12 (2+4+6)
(ii) Accept a number and print those digits which are divisible by 3
Sample input: 135689
Sample output: Numbers divisible by 3 are 3,6, 9

import java.util.*;
class lol
{
public static void main()
{
Scanner sc = new Scanner(System.in);
double sum = 0; int b =0;
System.out.printIn("Enter 1 for even number addition and 2 for printing numbers divisible by 3");
int ch = sc.nextIntO; switch(ch)
{
case '1int a = sc.nextInt();
b=a;
while(b % 10 !=0)
{
int temp = b %10;
if (temp %2 == 0)
sum+=temp; b = b/10;
}
System.out.printIn(sum);
break;
case '2': int k = sc.nextIntO;
b =k;
while(b %10 !=0)
{
int temp = b %10;
if (temp %3 == 0)
System.out.printIn(temp);
b = b/10;
}
break;
default: System.out.printIn("Error");
break;
}
}//end of main
}//end of class

Question 9.
Write a program to accept 50 student names and their school in two separate single dimension arrays. Search for the school name input by the user in the list. If found, display “Search Successful” and print the name of the school along with the student name, or else display the message “Search Unsuccessful.”

import java.util.*;
class lol
{
public static void main()
{
String[ ] student_name = new String;
Stringt ] schooLname = new String;
Scanner sc = new Scanner(System.in);
forfint i = 0; i < 50; i++)
{
System.out.printInC'Enter students name :"); student_name[i] = sc.nextLine();
System.out.printInC'Enter schools name;"); school_name[i] = sc.nextLine();
}
System.out.printInC'Enter schools name you want to search:");
String str = sc.nextLine();
int flag =0;
for(int i =0; i < 50;i++)
{ if(school_name[i].compareTo(str)==0)
{ System.out.printInC'Search successful ");
System,out.printIn(school_name[i]+""+student_name[i]);
flag = 1 ;
break;
}
}
if (flag == 0)
System.out.printIn("Search Unsuccessful");
}
} Question 10.
Design a class to overload a function pattern() as follows:
(i) void pattern(int n): with one int argument that prints the pattern as follows:
Input value of n = 5 (ii) void pattern (int n, char ch): with one int argument and one character argument to print the pattern as follows:
Input value of n = 5
Input value of ch =’*’ Output: import java.util.*;
public class Main
{
public void pattern(int n)
{
for(int i = n; i>0; i—)
{
for(intj = i;j<=n;j++)
System.out.print(j+"");
System.out.printIn();
}
}
public void pattern(int n, char ch)
{
for(int i = 1; i<n; i++)
{
for(int j = 1; j<=i*2; j++)
{
jf(j %2 == 0)
System.out.print(ch);
else
System.out.print(T');
}
System.out.printInO;
}
}
public static void main(String[ ] args)
{
System.out.printIn("Enter the value of n");
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
System.out.printIn("Enter the character");
char ch = sc.next().charAt(0);
Main ob = new Main();
ob.pattern(n);
ob.pattern(n,ch);
}//end of main
}//end of class
 Variable Data Type Description ch char For storing character m or f age int Age of person inc double Income of person tax double Store tax cash__back double To store the cashback cl Customer Object of class customer str String To store line or sentence count int Store number of words sum double Store the sum of series a,b,k Int Get the number. student_name,school_name String Array to store student name and school name flag int To know name exists or not ij int For looping n int Number of times to be printed ch char Storing character ob Main Object of class Main

## ICSE Class 10 Computer Application Sample Question Paper 3 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 does the default constructor provided by the compiler do?
Default constructor is helpful in creation of objects of the class.
E.g. ABC obj = new ABC();

(b) Name the operators listed below
(i) >=
(ii) –
(iii) !
(iv) ?:
(i) Greater than
(ii) predecrement
(iii) logical not
(iv) Ternary operator.

(c) Why is an object called an instance of a class?
(i) import
(ii) class and arrays

(d) What are identifiers? Give example of each identifier.
An object is called instance of class because object gets the copy of all variables defined in the class.

(e) Name
(i) A keyword used to call a package in the program.
(ii) Any reference data types
Identifiers are the variables, methods classes etc. which are not independent keywords.
E.g. int a;
a is identifier.

Question 2.
(a) What is the function of catch block in exception handling? Where does it appear it in a program?
The catch block is used to find an exception and handle it. It appears after try block.

(b) Find the output:
String a = “Sidharthissmartguy”,b= “MathsMarks”;
String h = a.substring(2,5);
String k = b.substring(8).toUpperCase();
System.out.println(h);
System.out.println(k.equalslgnoreCase(h));
dha
false

(c) (i) Name the mathematical function which is used to find sine of an angle in radians.
(ii) Name a string function which removes the blank spaces provided in the prefix and suffix of a string.
(i) math.sin()
(ii) trim()

(d) Name the keyword which will be used to resolve the conflict between method parameter and instance variables/fields. Explain with example.
this eg. void assign(inta)
{
this.b = a;
}

(e) int y = 10 ;
y+ = (++y * (y++ +5));
System.out.println(y);
What will be the output of the above code?
186 Question 3.
(a) The arguments of the function given in the function definition are called ________
formal parameter

(b) Why JVM is required in running Java program. Justify your answer.
The JVM converts the Java program into machine code. The computer reads it and displays the output accordingly.

(c) Attempt the following
(i) Explain with example the possible loss of precision.
float h = 3.45;
int k = (int)h;
Here k value assigned is 3.
When higher size data type is assigned to the lower size data type there is loss of data which takes place. It’s called loss of precision.

(ii) Explain the term type casting in java. How is it useful?
Type conversion is method by which one type of data is converted into other type. It’s useful in the expression when calculation is to be done in float type.

(iii) State the difference between keyword and reserved word.
keywords are all reserved words in java example null, true, false are reserved words.
Keywords are like return, continue, break etc.

(iv) What do you mean by convention and rules in java? Explain the difference between compiler and interpreter.
Rules are for naming the identifiers. Example identifier name must begin with alphabet or underscore. No special character to be part of the name. Convention is the use the letter of the alphabet.
Compiler compiles the program at once and displays the error for whole program.
Interpreter compiles the program line by line whenever it finds error it stops. At any time it can show only one error.

(v) State the purpose and return data type of the following string functions.
a. indexOf().
b. compareTo().
a. int – return the index of a character
b. int – compares two strings.

(d) Explain the use of continue statement in looping in java.
The continue statement makes the next iteration of the loop to be executed.

(e) State the output of the code:
int m = 10; int n = 10;
for(int i =1;i<5 ;i++) m++;-n; System.out.println(“m=”+m); System.out.println(“n=”+n); Answer: 11 9 (f) What do you understand by Java application and java applet. Explain with example Answer: An application is the program executed on the computer independently. Applet is small program uses another application program for its execution.

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 i 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.
Digital world announces seasonal discount on the laptops in the given order.

 Cost of the laptop Discount Rs. 20,000 – Rs. 30,000 10% Rs. 30,000 – Rs. 40,000 15% Rs. 40,000 – Rs. 50,000 18% >= Rs. 50,000 20%

An additional discount of 5% on all types of laptops is given. Sales tax is calculated at 12% on the price after the discounts. Define a class to accept the cost of the laptop and print the amount payable by the customer on purchase (use constructor).

import java.util.*;
class dw
{
double Ic, rate, stl, dst; public dw()
{
double Ic = 0.0; double rate = 0.0; double stl = 0.0; double dst = 0.0;
}
public static void main()
{
dw obj new dw();
Scanner sc = new Scanner(System.in);
System.out.printIn("Enter the cost of laptop");
obj.Ic = sc.nextDouble();
double ds = 5;
double fa = 0.0, fa 1 = 0;
if(obj.Ic >=20000 && obj.Ic < 30000)
{
obj.rate = 10;
}
else if(obj.Ic >= 30000 && obj.Ic < 40000)
{
obj.rate = 15;
}
else ifCobj.Ic >= 40000 && obj.Ic < 50000)
{
obj.rate = 18;
}
else if (obj.Ic >= 50000)
{
obj.rate = 20;
}
else
{
System.out.printIn("invalid");
}
fa = obj.Ic-(obj.Ic*(obj.rate + ds)/100);
fa 1 = fa + ((12.0/100.0)*fa);
System.out.printIn("Amount payable:"+fa 1 );
} Question 5.
Write a program in java to accept 10 integers in an array. Now display only those numbers having complete square root
Sample input: 12, 45, 49, 78, 64, 77, 81, 99, 45, 33
Sample output: 49, 64, 81

import java.util.*;
class lol
{
public static void main()
{
Scanner sc = new Scanner(System.in);
inta[] = new int;
System.out.printInC'Enter 10 integers:");
for(int i =0;i <a.length; i++)
{
a[i] = sc.nextIntO;
}
for(int j = 0; jo.length; j++)
{
for(int k=0; k<=a[j]/2; k++)
{
if(k*k == a[j])
System.out.printIn(a[j]);
}
}
}
}

Question 6.
Write a function to suppress negative elements of an array to bottom without altering the original sequence i.e if array contains 5, -4, 3, -2, 6, -11,12,-8,9Then the return array will be 5, 3,6, 12, 9,-4, -2,-11,-8.

import java.util.*;
class lol
{
public static void supress()
{
Scanner sc = new Scanner(System.in);
int a[] = new int;
int temp;
System.out.printIn("Enter 10 integers:");
for(int i =0;i <a.length; i++)
{
a[i] = sc.nextInt();
}
for(int j = 0; j {
for(int k=0; k {
if(a[k]<0 &&a[k+1]>0)

{
temp = a[k];
a[k] = a[k+1];
a[k+1] = temp;
}
System.out.printIn(a[j]);
}
}
}
}

Question 7.
Write a program to input a sentence. Create a function convert(int n).
where n is an integer value in positive or negative.
This function is used to encode or decode the given by shifting each character of a string the number of times as specified by user.
Ex. input – Sid Bowler
Shift value 3
Output -Vig Erzohu

import java.util.*;
class lol
{
public static void convert()
{
Scanner sc = new Scanner(System.in);
System.out.printIn("Enter a sentence:");
String str = sc.nextLine();
String word = " ";
int n = 3; //shift value
for(int i =0;i <str.length(); i++)
{
char ch = str.charAt(i);
if(ch !=1')
word = word + (ch + n); else
word = word + ch;
}
System.out.printIn(word);
}
} Question 8.
Write a program using menu driven mode to find the value of s, where
S = 2 + 3 + 4 + 4 + 6 + 8 + 6 + 9 + 12… 100 terms
S = 2! -4! + 6! – 8! ………….. n

import java.util.*;
class lol
{
public static void main()
{
Scanner sc = new Scanner(System.in);
double sum = 0;
System.out.printIn("Enter 1 for number addition and 2 for factorial summation");
int ch = sc.nextInt();
switch(ch)
{
case '1': int a = 2, b = 3, c = 4; for(int i = 3; i<=99; i+=3)
{
sum = sum + a + b + c; a = a + 2; b = b + 3; c = c + 4;
}
sum+=a;
System.out.printIn(sum);
break;
case '2': int k = 2;
System.out.printIn("Enter number of terms:");
int n = sc.nextIntO;
for(int i = 1;i<=n;i++)
{
int fact = 1;
for(int j = 1; j<=k; j++)
{
fact = fact*j;
if(i%2 == 0)
sum = sum - fact; else
sum = sum + fact;
k = k + 2;
}
System.out.printIn(sum);
break;
default: System.out.printIn("Error"); break;
}
}//end of main
}//end of class Question 9.
Write a program in java to print the Pascalane triangle as follows. import java.util.*;
class lol
{
static int fact(int n)
{
int fact=1;
for(int i = 1; i <=n; i++)
{
fact*=i;
}
return fact;
}
static int ncr(int n,int r)
{
return fact(n) / (fact(n-r) * fact(r));
}
public static void main(String args[ ])
{
System.out.printInQ;
int n, i,j; n = 4;
for(i = 0; i <= n; i++)
{
for(j = 0; j <= n-i; j++)
{
System.out.print(" ");
}
for(j = 0; j <= i;j++)
{
System.out.printC "+ncr(i, j));
}
System.out.printIn();
}
}
 Variable Data Type Description ds double Additional discount fa 1 double Amount payable a[] int Array of 10 integers i,j,k int For looping temp int For swapping the numbers str String store the word ch char store character word String store new changed string sum double store sum of series a be int store consecutive integers. k int store the multiples of 2 fact int Store the factorial.

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

 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.
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)%
++, % >=, &&

(d) What is final variable and static variable?
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.
2 bytes and its range is 0 to 65,536 Question 2.
(a) What is the difference between keyword parse and function valueOf(). Give example of each.

 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.

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

 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?

• 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. Question 3.
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.
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.
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}};
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 of char data type and p of float data type.
char a it occupies 8 bytes,
float p it occupies 16 bytes.

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

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

(d) Write a java statement for finding and displaying the position of last space in string’str’.
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
(iii) valueOf()
(iv) endsWith()
(i) int
(ii) String
(iii) int
(iv) boolean

(f) What do you mean by Abstraction and information hiding in java?
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.

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;
}
}
} 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

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.

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

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;
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
}
}

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

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();
}
}
} Question 9.
Write a program in java to print the following output. 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.