ICSE Class 10 Computer Applications Sample Question Paper 8 with Answers

ICSE Class 10 Computer Applications Sample Question Paper 8 with Answers

Section – A
Attempt all questions

Question 1
(a) What is an array. Write the ground syntax for declaring the array.
(b) What is conditional /selection statement in java? Name the operator used for condition checking in java.
(c) What is composite data type. Explain using example.
(d) Which elements of java program represents characteristics and functions of an object.
(e) Define Polymorphism. Which part of the function differentiates between overloaded functions?
Answer:
(a) Array is set of data of the same type.
Eg. inta[ ] = {1,2,3,4,5};
(b) Conditional statements are used to check a condition and print the output accordingly. Ternary operator.
(c) A set of primitive data type is a composite datatype. Eg. Array, Class etc.
(d) Methods and data
(e) The ability to represent a thing in more than one form. The parameters of the function differentiates between the overloaded functions.

ICSE Class 10 Computer Applications Sample Question Paper 8 with Answers

Question 2
(a) What do you mean by function signature in java?
(b) Public static void main( ) why is main method declared as static?
(c) int i=3; i+=(i++*2)+ – – i*i++ + ++i/2; System.out.println(i); what is the output of the above code?
(d) Why is the string class called as immutable class.
(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:
(a) Function signature is the part which defines the return type, parameters and visibility of a method.
(b) Main method is declared static because only one copy of the main method is used in the program.
(c) 3 + 6 + 9 + 2 = 20.
(d) String is immutable because once it is stored, it cannot be altered during the execution of the program.
(e) It is used to find the run time errors and catch those errors gracefully, e is object of IO exception class it is used as input to the catch function.

ICSE Class 10 Computer Applications 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;
(ii) Differentiate between length and lengthO function.
(iii) Define class variable vs instance variable
(iv) Write java expression for the following;
\(\frac{\cos x+\sin x}{3.14^{*} \sqrt{x}}\)
(v) What is the source code in java and what is its extension.
(vi) Write one difference between
(i) char type and String type
(ii) “true” and true.
(vii) State the escape sequence for vertical tab and new line feed.
(viii) Which unit of the class gets called when object is created? Give an example
Answer:
(i) 9
(ii) length is used to find the length of array.
Length( ) is used to find length of string.

ICSE Class 10 Computer Applications Sample Question Paper 8 with Answers

(iii)

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) double x = (Math.cos(x*3.14/180) + Math.sin(x*3.14/180))/ (3.14*Math.sqrt(x));

(v) Source code in java is the set of commands in java to be executed by the JVM. Extension is .java.

(vi) (i)

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

(ii) “true” – String value
true – boolean value
(vii) “\t”and”\n‘
(viii) Constructor
E.g.

Class lol
{
Int a;
lol( )
{
a=10;
}
Public static void main( )
{
lol obj = new lol( );
}
}

ICSE Class 10 Computer Applications Sample Question Paper 8 with Answers

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.println("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.println( );
}
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.println( );
}
}//end of main 
}//end of class

ICSE Class 10 Computer Applications 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.println(''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.println( );
}
break;
case 'x': System.out.println("Enter the value of x and n"); 
double x = sc.nextDouble( ); 
int n = sc.nextlnt( ); 
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.println("sum:" +sum); break;
default: System.out.println("Error"); break;
}
}
}

ICSE Class 10 Computer Applications Sample Question Paper 8 with Answers

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.println("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 chi =word.charAt(0);
char ch2 = word.charAt(word.length()-1);
if((ch1=='a' || ch1=='A' || chi == 'e'|| ch1 == 'E* || chi =='i,||ch1==T|| 
ch1 -='u'||ch1 =='U'||ch1 =='o'||chl =='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.println(count);
}//end of main 
}//end of class

ICSE Class 10 Computer Applications 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.println("Enter a sentence:");
String str_ = sc.nextLine( ), 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.toCharArray( ); 
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.priintln(count);
}//end of main }//end of class

ICSE Class 10 Computer Applications Sample Question Paper 8 with Answers

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 tempi;
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.println("Enter name & marks:"); 
a[i] = sc.nextLineO; 
b[i] = sc.nextDoubleO;
}
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.println("Name" + "\t" + "Marks"); 
for(int i =0; i<a.length; i++) 
System.out.println(a[i]+"\t"+b[i]);
} //end of function main 
}//end of class

ICSE Class 10 Computer Applications 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:
C3
A 1
T 20
Answer:

import java.util.*; 
class lol 
{
public static void main( )
{
Scanner sc = new Scanner(System.in); 
System.out.println("Enter a word:");
String str = sc.next ( );
String strl = str.toUpperCase( );
forfint i =0; i<str.length( ); i++)
{
char ch = str.charAt(i); inta = ch-64;
System.out.println(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 Applications Question Papers with Answers

Leave a Comment