ICSE Class 10 Computer Application Sample Question Paper 11 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.
Answer:
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.
Answer:
int a = (b>c)?b:c;
int d = (a>e)?a:e;

(c) What is polymorphism?
Answer:
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.
Answer:
Math.round()
double k = Math.round(2.9);.

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

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

ICSE Class 10 Computer Application Sample Question Paper 11 with Answers

Question 2.
(a) Compare local, instance and class variables on the basis of the given criteria.
(i) identification in program
Answer:
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.
Answer:
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.
Answer:
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.
Answer:
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
Answer:
Inheritance

(ii) create an interface
Answer:
Abstraction

(iii) create various functions
Answer:
Polymorphism

(iv) use private data members?
Answer:
Encapsulation

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

(d) Differentiate between classes and objects. Why is object referred as instance of class?
Answer:
(i) Object is an identifiable entity with some characteristics and behaviour. Class is a collection of object with similar characteristics.
(ii) Object is called instance of class as object helps in accessing the class members and functions to get the required output.

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

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

ICSE Class 10 Computer Application Sample Question Paper 11 with Answers

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

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

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

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

(ii) Give difference between unary and binary operators.
Answer:
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
Answer:
(i) Array, class
(ii) “\n”;\\’
(iii) //or/*java*/
(iv) Character, Integer

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

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.
Answer:
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().
Answer:

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

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

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

b. Explicit and implicit type conversion.
Answer:
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.
ICSE Class 10 Computer Application Sample Question Paper 11 with Answers 1
Answer:

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

ICSE Class 10 Computer Application Sample Question Paper 11 with Answers

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

import java.util.*;
class Main
{
static int frequency(int number, int digit)
{
int count = 0;
while (number > 0)
{
if (number % 10 == digit)
count++;
number = number / 10;
}
return count;
}
public static void main(String args[ ])
{
Scanner sc = new Scanner(System.in);
System.out.printInC'Input the number:");
int n = sc.nextInt();
int a = n;
int search = 0;
int countdigit = 0;
int []arr = new int[10];
while(a >0)
{
search = a%10;
countdigit = frequency(n,search);
if(countdigit>0)
{
arr[search]=countdigit;
countdigit=0;
}
a=a/10;
}
for(int i =0; i<arr.length;i++)
{
if(arr[i]>0)
System.out.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.
Answer:

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

ICSE Class 10 Computer Application Sample Question Paper 11 with Answers

Question 7.
Write a class to input a string (combination of letters and digits) and replace the repecated characters with star(*) sign. Then display both old and newly created string.
Answer:

import java.util.*;
class Main
{
public static void main(String[ ] args)
{
Scanner sc=new Scanner(System.in);
System.out.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:
ICSE Class 10 Computer Application Sample Question Paper 11 with Answers 2
Answer:

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

ICSE Class 10 Computer Application Sample Question Paper 11 with Answers

Question 9.
Write a java class to calculate and print the electricity bill to be paid by a customer.
Assume that the customer pays a rent of Rs.350.00

No. of units Charge per unit
Upto 100 units Rs. 1.50
For the next 100 units Rs. 2.00
For next 50 units Rs. 2.50
Beyond 250 units Rs. 4.00

Answer:

import java.util.*;
class Main
{
public static void main(String[ ] args)
{
Scanner sc=new Scanner(System.in);
double fixed_price = 350.0;
double amt = 0.0;
System.out.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 Question Papers with Answers

ICSE Class 10 Computer Application Sample Question Paper 12 with Answers

ICSE Class 10 Computer Application Sample Question Paper 12 with Answers

Max Marks: 80
[2 Hours]

General Instructions

  • Answers to this Paper must be written on the paper provided separately.
  • You will not be allowed to write during the first 15 minutes.
  • This time is to be spent in reading the question paper.
  • The time given at the head of this Paper is the time allowed for writing the answers. O This Paper is divided into two Sections.
  • Attempt all questions from Section A and any four questions from Section B.
  • The intended marks for questions or parts of questions are given in brackets [ ].

SECTION – A [40 Marks]
Attempt All Question

Question 1.
(a) What do you mean by reusability feature.
Answer:
Reusability feature is related to inheritance in java where derived class can use the methods and common data from the base class.

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

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

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

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

ICSE Class 10 Computer Application Sample Question Paper 12 with Answers

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

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

(b) Distinguish between constructor and method.
Answer:

Constructor Method
Automatically called during the creation of the object. Class Object needs to explicitly call the member functions.
It bears the same name as that of class. It doesn’t have same name.

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

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

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

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

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

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

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

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

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

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

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

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

Linear Search Binary Search
It compares each element of the array with rest of the elements in the array. It’s based on divide and conquer rule. Array is sorted in this search. Element is searched only in the selected halves.

(viii) Evaluate the following expression:
int p, k= 8,m=11,r=7; p = (r++%7)+(–m%5)+k*(++k-8);
Answer:
8

SECTION – B (60 Marks)
Attempt any four questions from this Section

The answers in this Section should consist of the Programs in either Blue J environment or any program environment with Java as the base. Each program should be written using Variable descriptions/Mnemonic Codes such that the logic of the program is clearly depicted.

Flow-Charts and Algorithms are not required.

Question 4.
Write a program in java to input a number and check whether it is a pronic number or Heteromecic number or not.
Pronic number: A pronic number, oblong number, rectangular number or heteromecic number is a number which is the product of two consecutive integers i.e n(n+1)
The first few Pronic numbers are:
0, 2, 6, 12, 20, 30, 42, 56, 72.
Answer:

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

ICSE Class 10 Computer Application Sample Question Paper 12 with Answers

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

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

Question 6.
Write a program to accept a sentence and print only the first letter of each word of the sentence in capital letters separated by a full stop.
e.g.
INPUT Sentence: Sid is a cricket
output: S.I.A.C
Answer:

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

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

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

ICSE Class 10 Computer Application Sample Question Paper 12 with Answers

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

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

ICSE Class 10 Computer Application Sample Question Paper 12 with Answers

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

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

ICSE Class 10 Computer Application Question Papers with Answers

ICSE Class 10 Computer Application Sample Question Paper 10 with Answers

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.
Answer:
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.
Answer:
Characteristics (big, small, flat etc)

(c) What is wrapper class.
Answer:
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.
Answer:
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.
Answer:
double d = Math.sin(x*3.14/180);

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

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?
Answer:
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.
Answer:
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?
Answer:
A default constructor is a constructor without any parameters. It is used to assign a default value to the class variables.

(e) Explain the concept of constructor overloading using an example.
Answer:
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);
}
}

ICSE Class 10 Computer Application Sample Question Paper 10 with Answers

Question 3.
(a) How java make use of formal and actual parameter?
Answer:
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.
Answer:
object oriented programming

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

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

(ii) Why is java platform independent?
Answer:
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.
Answer:
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);
Answer:
3

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

(vi) What are functions? Give one advantage of using functions.
Answer:
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?
Answer:
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.
Answer:

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

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

ICSE Class 10 Computer Application Sample Question Paper 10 with Answers

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

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

ICSE Class 10 Computer Application Sample Question Paper 10 with Answers

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

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

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

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

ICSE Class 10 Computer Application Sample Question Paper 10 with Answers

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

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

ICSE Class 10 Computer Application Sample Question Paper 8 with Answers

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.
Answer:
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.
Answer:
Conditional statements are used to check a condition and print the output accordingly. Ternary operator.

(c) What is composite data type. Explain using example.
Answer:
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.
Answer:
Methods and data

(e) Define Polymorphism. Which part of the function differentiates between overloaded functions?
Answer:
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?
Answer:
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?
Answer:
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?.
Answer:
3 + 6 + 9 + 2 = 20.

(d) Why is the string class called as immutable class.
Answer:
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.
Answer:
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.

ICSE Class 10 Computer Application Sample Question Paper 8 with Answers

Question 3.
(a) Why is binary search called as divide and conquer.
Answer:
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.
Answer:
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;
Answer:
9

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

(iii) Define class variable vs instance variable
Answer:

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}}\)
Answer:
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.
Answer:
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
Answer:

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.
Answer:
“true” → String value
true → boolean value

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

(viii) Which unit of the class gets called when object is created? Give an example
Answer:
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
Answer:

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

ICSE Class 10 Computer Application Sample Question Paper 8 with Answers

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}\)
Answer:

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

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

ICSE Class 10 Computer Application Sample Question Paper 8 with Answers

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

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

import java.util.*;
class lol
{
public static void main()
{
String temp; double temp1;
Scanner sc = new Scanner(System.in);
String at ] = new String[20];
double b[ ] = new double[20];
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

ICSE Class 10 Computer Application Sample Question Paper 8 with Answers

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

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

ICSE Class 10 Computer Application Sample Question Paper 9 with Answers

ICSE Class 10 Computer Application Sample Question Paper 9 with Answers

Max Marks: 80
[2 Hours]

General Instructions

  • Answers to this Paper must be written on the paper provided separately.
  • You will not be allowed to write during the first 15 minutes.
  • This time is to be spent in reading the question paper.
  • The time given at the head of this Paper is the time allowed for writing the answers. O This Paper is divided into two Sections.
  • Attempt all questions from Section A and any four questions from Section B.
  • The intended marks for questions or parts of questions are given in brackets [ ].

SECTION – A [40 Marks]
Attempt All Question

Question 1.
(a) What is return of following function.
(i) equals()
Answer:
boolean

(ii) rint().
Answer:
double

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

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

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

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

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

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

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

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

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

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

ICSE Class 10 Computer Application Sample Question Paper 9 with Answers

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

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

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

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

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

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

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

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

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

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

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

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

SECTION B (60 Marks)
Attempt any four questions from this Section

The answers in this Section should consist of the Programs in either Blue J environment or any program environment with Java as the base. Each program should be written using Variable descriptions/Mnemonic Codes such that the logic of the program is clearly depicted.

Flow-Charts and Algorithms are not required.

Question 4.
Write a program to print the sum of prime digits from given number.
E.g. 134667
Output: 1+3+7=11
Answer:

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

ICSE Class 10 Computer Application Sample Question Paper 9 with Answers

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

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

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

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

ICSE Class 10 Computer Application Sample Question Paper 9 with Answers

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

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

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

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

ICSE Class 10 Computer Application Sample Question Paper 9 with Answers

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

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

ICSE Class 10 Computer Application Question Papers with Answers

ICSE Class 10 Computer Application Sample Question Paper 7 with Answers

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.
Answer:
final

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

a. Differentiate between equals() and equalslgnoreCase()
Answer:

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.
Answer:
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);
Answer:
-1

d. Differentiate between linear search and binary search.
Answer:

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[5] of character data type.
Answer:
10 bytes 24 bytes

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

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?
Answer:
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.
Answer:
nextInt()

(ii) Is used to input a string data from standard input stream.
Answer:
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
Answer:
System.out.printIn(“COMP IS FUN”.indexOf(”));

(ii) To find and display the position of the last space in string str.
Answer:
System.out.printIn(“COMP IS FUN”.lastindexOf(”));

ICSE Class 10 Computer Application Sample Question Paper 7 with Answers

Question 3.
(a) The arguments of the function given in the function definition are called
Answer:
formal parameters

(b) Why JVM is required for running java program. Justify your answer.
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.
Answer:
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.
Answer:
int a[ ] = new int [10];
int a[ ];
int a[] = {1,2,3};

(iii) What is the purpose of new operator. Why is it useful?
Answer:
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));
Answer:
8.0

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

(vi) Explain the use of return statement in the java.
Answer:
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()
Answer:
(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);
Answer:
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
Answer:

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

ICSE Class 10 Computer Application Sample Question Paper 7 with Answers

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

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

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

ICSE Class 10 Computer Application Sample Question Paper 7 with Answers

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

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

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[10];
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

ICSE Class 10 Computer Application Sample Question Paper 7 with Answers

Question 9.
Write a function to display the given pattern: void pattern (int n)
Note: n is the number of rows:
ICSE Class 10 Computer Application Sample Question Paper 7 with Answers 1
Answer:

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

ICSE Class 10 Computer Application Sample Question Paper 6 with Answers

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.
Answer:
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.
Answer:
Keywords are tokens in java that have a specific meaning.
E.g. static

(c) Name any three library packages.
Answer:
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
Answer:
(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[2] + x[5]*x[1]
Answer:
(i) 6
(ii) 37

ICSE Class 10 Computer Application Sample Question Paper 6 with Answers

Question 2.
(a) State the difference between = = operator and equals () method.
Answer:

= =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’;
Answer:
(i) Explicit
(ii) Implicit

(c) Differentiate between formal parameter and actual parameter.
Answer:
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.
Answer:
int PosChar(String str, char ch);

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

Question 3.
(a) Define an impure function.
Answer:
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.

(b) Explain the function overloading with example.
Answer:
void lol()
{
String str = “lol”;
‘ }
void lol(int a)
{
String str1 = “lol”;
}

(c) What is default constructor and where is it useful?
Answer:
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.
Answer:

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”);
Answer:
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 –;
}
Answer:
50
45
35
30
25
20
15
10
5

(g) Write one difference between primitive data types and composite date types.
Answer:
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
Answer:
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;
}
Answer:
3

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

b. Write the return type of the following library
(i) isLetterOrDigit(Char)
(ii) replace(char, char)
Answer:
(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.
Answer:

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

ICSE Class 10 Computer Application Sample Question Paper 6 with Answers

Question 5.
Using the switch statement, write a menu driven program
(i) To print the Floyd’s triangle [Given below]
ICSE Class 10 Computer Application Sample Question Paper 6 with Answers 1
(ii) To display the following pattern
ICSE Class 10 Computer Application Sample Question Paper 6 with Answers 2
For an incorrect option, an appropriate error message should be displayed
Answer:

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
MADAM
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
Answer:

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

ICSE Class 10 Computer Application Sample Question Paper 6 with Answers

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)
Answer:

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

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

ICSE Class 10 Computer Application Sample Question Paper 6 with Answers

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
Country Name: USA Output: Sorry Not Found!
Answer:

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)
System.out.printIn("Sorry Not Found");
}//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 Question Papers with Answers

ICSE Class 10 Computer Application Sample Question Paper 5 with Answers

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?
Answer:
This keyword in parameterized constructor is used to refer to the currently calling object.

(b) State the differences between static and dynamic initialization.
Answer:
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.
Answer:
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
Answer:
boolean

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

ICSE Class 10 Computer Application Sample Question Paper 5 with Answers

Question 2.
(a) State difference between constructor and method of class.
Answer:

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?
Answer:
Hello world a b c d

(c) Define Java byte code.
Answer:
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.
Answer:

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.
Answer:
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.
Answer:
The keyword void is used to tell that function has no return type.

(b) Which OOP principle is used in function overloading?
Answer:
Polymorphism.

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

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

(iii) Define Java token.
Answer:
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;
Answer:
5 + 6 + 7*3 = 5 + 6 + 24 = 32.

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

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

(e) Name the formal and actual parameter.
Answer:
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 ()?
Answer:
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.
Answer:

import java.util.*;
class salary
{
String name, address;
String sub; double ms, it;
long ph;
salary ()
{
name = address = sub="";
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();
address = 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();
}
}

ICSE Class 10 Computer Application Sample Question Paper 5 with Answers

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

import java.util.*;
public class Main
{
public static void main(String[ ] args)
{
int arr[ ] = new int[10];
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

Answer:

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

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

ICSE Class 10 Computer Application Sample Question Paper 5 with Answers

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

import java.util.*;
import java.math.*;
class lot
{
public static void main()
{
Scanner sc = new Scanner(System.in);
int a[] = new int [7];
int b[] = new int[7];
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}
Answer:

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)
{
System.out.printIn("Element is not found!");
}
}//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 Question Papers with Answers

ICSE Class 10 Computer Application Sample Question Paper 4 with Answers

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?
Answer:
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.
Answer:
(i) False
(ii) false

(c) Define the term byte code.
Answer:
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;
Answer:
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.
Answer:
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);

ICSE Class 10 Computer Application Sample Question Paper 4 with Answers

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.
Answer:
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?
Answer:
import java.util.*; Default delimiter for scanner class is white space or tab or newline.

(c) Differentiate between Character. isUpperCase( ) and Character, to UpperCase()
Answer:
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
Answer:
doube T = 2*3.14 * Math.sqrt(l/g);

(e) What is fall through? Give example.
Answer:
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.
switch(grade)
{
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:
System.out.println(“lnvalid grade”);
}

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

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

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

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

(e) System.out.print(Math.max(Math.pow(Math.round(6.25),2),(Math. pow(Math.rint(1.8),3))));
Answer:
36

ICSE Class 10 Computer Application Sample Question Paper 4 with Answers

Question 4.
Write the output of the following segment of code:
ICSE Class 10 Computer Application Sample Question Paper 4 with Answers 1
Answer:
(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.
Answer:

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')
{
System.out.print("Enter your age:");
int age = sc.nextInt(); if(age>65)
{
System.out.printIn("Wrong Category");
}
else
{
System.out.print("Enteryour income:");
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

ICSE Class 10 Computer Application Sample Question Paper 4 with Answers

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:
ICSE Class 10 Computer Application Sample Question Paper 4 with Answers 2
Write a main method to create an object of the class and call the above member methods.
Answer:

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

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

ICSE Class 10 Computer Application Sample Question Paper 4 with Answers

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

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

import java.util.*;
class lol
{
public static void main()
{
String[ ] student_name = new String[50];
Stringt ] schooLname = new String[50];
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");
}
}

ICSE Class 10 Computer Application Sample Question Paper 4 with Answers

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
ICSE Class 10 Computer Application Sample Question Paper 4 with Answers 3
(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:
ICSE Class 10 Computer Application Sample Question Paper 4 with Answers 4
Answer:

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

ICSE Class 10 Computer Application Sample Question Paper 3 with Answers

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?
Answer:
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) ?:
Answer:
(i) Greater than
(ii) predecrement
(iii) logical not
(iv) Ternary operator.

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

(d) What are identifiers? Give example of each identifier.
Answer:
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
Answer:
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?
Answer:
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));
Answer:
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.
Answer:
(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.
Answer:
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?
Answer:
186

ICSE Class 10 Computer Application Sample Question Paper 3 with Answers

Question 3.
(a) The arguments of the function given in the function definition are called ________
Answer:
formal parameter

(b) Why JVM is required in running Java program. Justify your answer.
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.
Answer:
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?
Answer:
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.
Answer:
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.
Answer:
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().
Answer:
a. int – return the index of a character
b. int – compares two strings.

(d) Explain the use of continue statement in looping in java.
Answer:
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).
Answer:

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

ICSE Class 10 Computer Application Sample Question Paper 3 with Answers

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

import java.util.*;
class lol
{
public static void main()
{
Scanner sc = new Scanner(System.in);
inta[] = new int[10];
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.
Answer:

import java.util.*;
class lol
{
public static void supress()
{
Scanner sc = new Scanner(System.in);
int a[] = new int[10];
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
Answer:

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

ICSE Class 10 Computer Application Sample Question Paper 3 with Answers

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

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

ICSE Class 10 Computer Application Sample Question Paper 3 with Answers

Question 9.
Write a program in java to print the Pascalane triangle as follows.
ICSE Class 10 Computer Application Sample Question Paper 3 with Answers 1
Answer:

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

ICSE Class 10 Computer Application Sample Question Paper 2 with Answers

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

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

(d) What is final variable and static variable?
Answer:
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.
Answer:
2 bytes and its range is 0 to 65,536

ICSE Class 10 Computer Application Sample Question Paper 2 with Answers

Question 2.
(a) What is the difference between keyword parse and function valueOf(). Give example of each.
Answer:

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

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

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?
Answer:
Advantages:

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

ICSE Class 10 Computer Application Sample Question Paper 2 with Answers

Question 3.
(a) What do you mean by function overloading? Explain with example.
Answer:
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.
Answer:
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.
Answer:
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}};
Answer:
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[4] of char data type and p[4] of float data type.
Answer:
char a[4] it occupies 8 bytes,
float p[4] it occupies 16 bytes.

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

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

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

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

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

ICSE Class 10 Computer Application Sample Question Paper 2 with Answers

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

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

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

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[10];
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
System.out.printIn(n+" not found");
}
}

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

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

ICSE Class 10 Computer Application Sample Question Paper 2 with Answers

Question 9.
Write a program in java to print the following output.
ICSE Class 10 Computer Applications Sample Question Paper 2 with Answers 1
Answer:

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.

ICSE Class 10 Computer Application Question Papers with Answers

ICSE Class 10 Computer Application Sample Question Paper 1 with Answers

ICSE Class 10 Computer Application Sample Question Paper 1 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) Name any four tokens of Java. [2]
Answer:
Integer, boolean, double and character.

(b) Give the difference between actual parameter and formal parameter. [2]
Answer:
Formal parameters are used in the function definition and Actual parameters are used when function is being called. E.g.

void sum(int a, int b) // a and b are formal parameters
{
System.out.println(a+b);
}
Public static void main()
{
Sum(2,4); // 2,4 are actual parameters.
}

(c) What is an identifier? [2]
Answer:
Identifiers are names of the variables, strings, classes and packages. Its values can change throughout the program.

(d) Write an expression in Java for sin x + √a2 + √b3. [2]
Answer:
Math.sin(x) + Math.sqrt(a*a + b*b*b);

(e) What is the result produced by 2 – 10*3 + 100/11 ? Show the steps. [2]
Answer:
Step 1:2- 10*3 + 9
Step 2:3 – 30+9
Step 3: 3-21
Step 4: -19

ICSE Class 10 Computer Application Sample Question Paper 1 with Answers

Question 2.
(a) What is the difference between local variable and instance variable? [2]
Answer:

Local Variable Instance Variable
Its scope remains inside a function or the block. Its scope remains throughout the methods of the class.
Multiple copies of this variable are used throughout the program. Every object has separate copies of this variable.

(b) int x = 20, y = 10, z;
What is the value of z in
z = ++x * (y – -) – y ?
Show the steps. [2]
Answer:
int x =20, y = 10, z;
z = ++x * (y – -) – y ?
Step 1:21 * 10-9
Step 2: 210 – 9
Step 3: 201

(c) What is the purpose of default in a switch? [2]
Answer:
Default in the switch statement means when no matching case is encountered by the controller it executes the default case.

(d) Give the difference between linear search and binary search. [2]
Answer:

Linear Search Binary Search
It compares each element of the array with rest of the elements in the array. It’s based on divide and conquer rule. Array is sorted in this search. Element is searched only in the selected halves.

(e) What will be the output of the following code?
float x = 7.87;
System.out.println(Math.ceil(x));
System.out.println(Math.floor(x)); [2]
Answer:
8.0
7.0

ICSE Class 10 Computer Application Sample Question Paper 1 with Answers

Question 3.
(a) State the difference between if-else if ladder and switch…case. [2]
Answer:

If-else Ladder Switch Case
Works on more than one variable It works on only one variable or constant
It can hold many conditions It can hold only one condition.

(b) Explain the concept of constructor overloading with an example. [2]
Answer:
Function name same as that of class name without return type is called Constructor. Constructor overloading is when same name constructor is used with different arguments list is called constructor overloading.

Example:

Class lol
{
lol ()
{
//write something ...
}
lol(int a)
{
//write something
}
lol(int a, int b)
{
//write something
}

(c) What will be the output of the following program segments?
(i) String s = “application”; int p = s.indexOf(‘a’);
System.out.println(p);
System.out.println(p+s); [2]
Answer:
0application

(ii) String st = “PROGRAM”; System.out.println(st.indexOf(st.charAt(4))); [2]
Answer:
1

(iii) int a = 0; if(a>0 && a<20) d++; else a-; ‘ System.out.println(a); [2] Answer: -1 (iv) int a- 5, b = 2,c; if (a>b || a ! = b) c = ++a+-b;
System.out.print(c+ ” “+a+” “+b); [2]
Answer:
7 6 1

(v) int i = 1; while(i++<=1)
{
i++;
System.out.print(i + “”);
}
System.out.print(i); [2]
Answer:
34

(d) Differentiate between isUpperCase(char) and toUpperCase(char). [2]
Answer:

isUpperCase() toUpperCase()
It checks whether the character is uppercase or not. It changes the character into uppercase
Return value is boolean. Return value is String

(e) What is the difference between a constructor function and a member function of a class? [2]
Answer:

Constructor Function Member Function
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.

(f) What is the difference between a static member function and a member function which is not static? [2]
Answer:

Static Member Function Non Static Member Function
It has the keyword static before the function name. It doesn’t have static keyword before the function name.
It can be called by static member functions only. It can be called by any function.

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 taximeter having the following description:
Data members/instance variables
int taxino – to store taxi number
String name – to store passenger’s name
int km – to store number of kilometres travelled
Member functions:
taximeter() – constructor to initialize taxino to 0, name to” “and b to 0.
input() – to store taxino,name,km
calculate() – to calculate bill for a customer according to given conditions kilometers

travelled(km) Rate/km
<1 km Rs.25
1 < km < 6 Rs. 10
6 < km <12 Rs. 15
12 < km <18 Rs. 20
>18 km Rs.25

display() – To display the details in the following format Taxino Name Kilometres travelled Bill amount ……. Create an object in the main method and call all the above methods in it. [15]
Answer:

import java.util.*;
class taximeter
{
int taxino;
String name;
int km;
double fare;
public taximeter()
{
taxino = 0;
name ="";
km = 0;
fare = 0.0;
}
public void inputQ
{
Scanner sc = new Scanner(System.in);
System.out.primtlnC'Enter taxi number");
taxino = sc.nextlnt();
System.out.primtln("Enter passenger's name");
name = sc.nextLine();
System.out.priintln("Enter number of kms travelled");
km = sc.nextlnt();
}
public void calculate()
{
int Rate =0;
if (km <= 1)
fare = 25.0 * km;
else if(l < km && km <= 6)
fare = 10.0 * km;
else if(6 < km && km <= 12)
fare = 15.0 * km;
else if(12 < km && km <= 18)
fare = 20.0 * km;
else
fare = 25.0 * km;
}
public void displayO
{
System.out.priintln("Taxino "+"Name "+" kilometers travelled "+"Bill amount ");
System.out.priintln(taxino+ ""+name+" "+" "+fare);
}
public void main()
{
taximeter obj == new taximeterO;
obj.input();
obj.calculate();
obj.display();
}//end of main
}//end of class

ICSE Class 10 Computer Application Sample Question Paper 1 with Answers

Question 5.
Write a menu-driven program to find the sum of the following series depending on the user choosing 1 or 2 1. S = 1/4 + 1/8 + 1/12………… upton terms 2. S = 1/1! – 2/2! + 3/3!……….. upto n terms where ! stands for factorial of the number and the factorial value of a number is the product of all integers from 1 to that number, e.g. 5! = 1* 2* 3* 4* 5. (use switch-case). [15]
Answer:

import java.util.*;
class abc {
public void main()
{
Scanner sc = new Scanner(System.in);
double sum = 0.0;
System.out.println("Input 1 for sum first series and input 2 for sum of second series");
int a = sc.next.lnt();
switch(a)
{
case 1:
{
System.out.println("Input N value for for the series");
int n = sc.next.Int();
for(int i = 1; i<= n;i++)
{
sum+ = 1,0/(4.0*i);
}
System.out.println{"sum of 1st series is "+sum);
}
break;
case 2:
{
System.out.println("lnput N value for for the series");
int n = sc.next.Int();
for(int i = 1; i<=n; i++)
{
int fact = 1;
for(int j = 1; j< = i;j++)
fact*= j;
if(i%2 ==1)
sum+= (double)i/fact;
else
sum-= (double)i/fact;
}
System.out.printIn("sum of 2nd series is "+sum);
}
break;
default: System.out.println("not valid choice");
break;
} //end of switch
}//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.

Example: INPUT SENTENCE :”This is a cat”
OUTPUT :T.I.A.C. [15]
Answer:

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

ICSE Class 10 Computer Application Sample Question Paper 1 with Answers

Question 7.
Write a program to create an array to store 10 integers and print the largest integer and the smallest integer in that array. [15]
Answer:

import java.util.*;
class abc
{
public static void main()
{
Scanner sc = new Scanner(System.in);
int a[] = new int[10];
System.out.printIn(Enter 10 numbers:");
for(int i = 0; i < 10; i++)
a[i] = sc.nextlntO;
int largest = 0;
int smallest = 0;
for (int i = 0; i < 10; i++)
{
if(largest < a[i]) largest = a[i]; if(smallest > a[i]) smallest = a[i];
}
System.out.printIn("Largest of number in array is "+largest);
System.out.printIn(Smallest of number in array is "+smallest);
}//end of main
}//end of class

Question 8.
Write a program to calculate the sum of all the prime numbers between the range of 1 and 100. [15]
Answer:

import java.util.*;
class prime
{
public static void main()
{
int sum = 0;
for(int i = 2; i <=100; i++)
!
l
int mid = i/2;
int count = 0;
for (int j = 1; j <=mid; j++)
{
if (i%j ==0) count++;
}
if(1 == count) sum+= i;
}
System.out.printIn(sum of all prime numbers is:"+sum);
}//end of main
}//end of class

Question 9.
Write a program to store 10 names in an array. Arrange these in alphabetical order by sorting. Print the sorted list. Take single word names, all in capital letters, E.g. SAMSON, AJAY, LUCY, etc. [15]
Answer:

import java.util.*;
class prime
{
public static void mainQ
{
String temp;
Scanner sc = new Scanner(System.in);
String a[ ] = new String [10];
System.out.println("Enter 10 names all in capital letters");
for (int i = 0; i < a.length; i++) a[i] = sc.nextO;
for(int i = 0; i < a.length; i++)
for(int j = i+1;j < a.length; j++) { if(a[i].compareTo(a[j])>0)
{
temp = a[i];
a[i] = a[j];
atj] = temp;
}
}
for(int i = 0; i < a.length; i++)
System.out.println(a[i]);
}//end of main
}//end of class
Variable Data Type Description
str String Input a string
word String To extract character from string
ch char To store character
a[ ] int To store integer array
temp int Temporary variable for swapping
count int To count the number of factors.
sum int To add the sum of prime numbers
n int Number to be checked whether its prime or not
largest int To store the largest value
smallest int To store the smallest value
a[] String To read all the names in capital letters.
fj int For looping
temp String For storing temporarily

ICSE Class 10 Computer Application Question Papers with Answers