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

Leave a Comment