ICSE Class 10 Computer Applications Sample Question Paper 1 with Answers

ICSE Class 10 Computer Applications Sample Question Paper 1 with Answers

Section – A [40 Marks]
Attempt all questions

Question 1
(a) Name any four tokens of Java. [2]
(b) Give the difference between actual parameter and formal parameter. [2]
(c) What is an identifier? [2]
(d) Write an expression in Java for sin x + √a2+ b3. [2]
(e) What is the result produced by 2 – 10*3 + 100/11 ? Show the steps. [2]
Answer:
(a) Integer, boolean, double and character.

(b) 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.
}

ICSE Class 10 Computer Applications Sample Question Paper 1 with Answers

(c) Identifiers are names of the variables, strings, classes and packages. Its values can change throughout the program.

(d) sin(x) + Math.sqrt(a*a + b*b*b);

(e) Step 1:2- 10*3 + 9
Step 2:3 – 30 + 9
Step 3: 3 – 21
Step 4: – 19

Question 2
(a) What is the difference between local variable and instance variable? [2]
(b) intx = 20, y = 10, z;
What is the value of z
in z = ++x * (y –     – y ?
Show the steps. [2]
(c) What is the purpose of default in a switch? [2]
(d) Give the difference between linear search and binary search. [2]
(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:
(a)

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.

ICSE Class 10 Computer Applications Sample Question Paper 1 with Answers

(b) int x =20, y = 10, z;
z = ++x * (y – – y )- y?
Step 1:21 * 10 – 9
Step 2: 210 – 9
Step 3: 201

(c) Default in the switch statement means when no matching case is encountered by the controller it executes the default case.

(d)

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

ICSE Class 10 Computer Applications 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]

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

ICSE Class 10 Computer Applications Sample Question Paper 1 with Answers

(iii) int a = 0;
if(a>0 && a<20)
d++;
else a-;
System.out.println(a); [2]

(iv) int a- 5, b = 2,c;
if (a>b || a ! = b)
c = ++a+-b;
System.out.print(c+ ” “+a+” “+b); [2]

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

ICSE Class 10 Computer Applications Sample Question Paper 1 with Answers

(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
1. Automatically called during the creation of the object.
2. It bears the same name as that of class.
1. Class object needs to explicitly call the member functions.
2. 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
1. It has the keyword static before the function name.
2. It can be called by static member functions only.
1. It doesn’t have static keyword before the function name.
2. It can be called by any function.

Section – B  (60 Marks)
Attempt any four questions

Attempt any four questions from this Section
The answers in this Section should consist of the Programs in either Blue J environment or any program environment with Java as the base. Each program should be written using Variable descriptions/Mnemonic Codes such that the logic of the program is clearly depicted. Flow-Charts and Algorithms are not required.

ICSE Class 10 Computer Applications Sample Question Paper 1 with Answers

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 input( ) 
{
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 display( ) 
{
System.out.priintln("Taxino "+"Name "+" kilometers travelled "+"Bill amount ");
System.out.priintln(taxino+ ""+name+""+" "+fare);
}
public void main( )
{
taximeter obj == new taximeter( ) ;
obj.input( );
obj.calculate( );
obj.display( );
} //end of main 
} //end of class

ICSE Class 10 Computer Applications 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………….. up to n 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.
Answer:

import java.util.*; class abc
 {
public void main( )
{
Scanner sc = new Scanner(System.in); 
double sum = 0.0;
System.out.println
("lnput 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("lnput N value for for the series"); 
int n = sc.next.lnt( ); 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.println("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.println('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 Applications 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.printlnC'Enter 10 numbers:");
for(int i = 0; i < 10; i++)
a[i] = sc.nextlnt ( );
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.println("Largest of number in array is "+largest); 
System.out.printlnC'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++)
{
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.printlnC'sum of all prime numbers is:"+sum); 
}//end of main 
}//end of class

ICSE Class 10 Computer Applications Sample Question Paper 1 with Answers

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 main( ) 
{
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.next ( ); 
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]; 
a[j] = 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 Applications Question Papers with Answers

ICSE Class 9 Computer Applications Sample Question Paper 4 with Answers

ICSE Class 9 Computer Applications Sample Question Paper 4 with Answers

Section-A
(Attempt all questions)

Question 1.
(a) What is an object?
(b) Define encapsulation with an example.
(c) What do you mean by software ethics?
(d) What is hacking?
(e) What is software piracy?
Answer:
(a) An object is an instance of a class . Objects have the attributes and behaviors of their class. If country is a class then India, China and Nepal are objects of that class.

(b) Encapsulation is the wrapping up of data under a single unit. The class encapsulates all the variables and data which can be accessed by the member functions of that class .

(c) Software ethics refers to the moral principles and behavior of individuals working on computer software. It deals with many social and ethical problems.

(d) Hacking refers to unauthorized intrusion into a computer or a network. The person engaged in hacking activities is known as a hacker. This hacker may alter system or security features to accomplishes a goal that differs from the original purpose of the system.

(e) Software piracy refers to the unauthorised supplication of software. Under copyright law , software piracy occurs when copyright protected software is copied, modified, distributed or sold. It causes loss to the makers and programmers lose interest in making new creative software.

ICSE Class 9 Computer Applications Sample Question Paper 4 with Answers

Question 2.
(a) What is fall through?
Answer:
Fall through is situation that occurs in the switch case construct when the different cases are not terminated by the break statement. As a result of which all the cases occurring after the selected case gets executed until the first break statement is reached.
For example :

switch(k)
{
case 1 : System.out.print("Blue") ;
case 2 : System.out.println(''Green") ;
case 3 : System.out.println("Orange")
break;
case 4 : System.out.println("White") ;
}

Output if k == 1
Blue
Green
Orange

(b) What are the various loop statements used in Java?
Answer:
There are three loop statements used in Java are For – Loop , While Loop and Do-While
Loop for (initialization; condition; increment/decrement)

{
// loop body
}
while (condition)
{
/ / loop body
}
do
{
/ / loop body
}
while ( condition);

ICSE Class 9 Computer Applications Sample Question Paper 4 with Answers

(c) Write the uses of break statement.
Answer:
Write the uses of break statement.
The break statement are used :
(i) In loops to terminate the operation if a certain condition is reached, hence after the statement is executed, the control exits the loop.
(ii) In switch-case construct to terminate the case when all the operations in a particular case is carried out and to avoid fall through situation.

(d) What is netiquette? State two of them.
Answer:
Netiquette is a combination of the words network and etiquette. It is defined as a set of rules of acceptable online behaviour. Every user of the Internet should be careful and responsible while working on the Internet. A person should
1. Not harm anyone over the Internet in the society
2. Maintaining transparency in information policies

(e) Write two protective measures to safeguard your computer.
Answer:
Installing a good Anti-Virus software Backup of essential data

ICSE Class 9 Computer Applications Sample Question Paper 4 with Answers

Question 3.
(a) What are keywords? Give example.
Answer:
Keywords are words that have specific meaning. They cannot be used as identifier.
For example : int, if

(b) Name two rules of naming an identifier.
Answer:
The first character must be an alphabet.
Identifiers are case sensitive.

(c) What are literals? Give example.
Answer:
These are constants that have a fixed value of any of the data types.They can be number, text etc
For example, 3.9, 45

(d) What is type casting?
Answer:
(d) It is the process by which Java converts one data type to another data type. The type casting can carried out automatically (implicit) or forced ( explicit).

(e) What is special about the main( ) method?
Answer:
It is the controlling method of a program. Every program begins from main( ) method.

(f) Given the initial value of a = 20, k = 15 in the following expression
k = k + a++ + ++a/2;
Write the final value in k and a.
Answer:
k = 15 + 20 + 22/2 = 46
a= 22

ICSE Class 9 Computer Applications Sample Question Paper 4 with Answers

(g) Rewrite the following using if ..else construct switch ( ko )
case 25 : System.out.print (“Yellow”);
break;
default: System.out.print (“Purple”);
Answer:

if ( ko == 25)
System.out.print ("Yellow");
else
System.out.print ("Purple");

(h) Rewrite the following using while loop
for ( m = 75; m >= 50 ; m = m - 10)
System.out.print( k + " " );
Answer:
int m = 75;
{
while ( m >= 50 )
{
System.out.print( k + " " );
m=m - 10;
}

(i) What will be the output of the following code :
int pa = 600;
while ( pa <1000)
{
System.out.print( pa ++);
pa = pa + 100;
}
Answer:
600 ..701 ..802 ..903 ..

(j) What will be the output of the following code :
int N = 77, f = 0, status = 1;
for(f = 2; f <= N; f++)
{
( N % f == 0)
{
status = 0;
break;
}
}
System.out.print( ” Status = ” + status + ” at value of f = ” + f);
Answer:
(j) Status = 0 at value of f = 7

ICSE Class 9 Computer Applications Sample Question Paper 4 with Answers

Section – B
(Attempt Any Four)

Question 4.
In a school picnic group, there were 22 students and 3 teachers. Each person had to pay an amount of Rs 450 for food, Rs 225 for transport and Rs 175 for entertainment. The organizers profit was 10% of the entire expenditure. Calculate and print the entire expenditure and the profit of the organizer.
Answer:

import java.util.*;
public class Q 4
{
void main( )
{
int group = 25, food = 450, tms = 250, entr = 175;
int totalFood = group * food;
int totalTns = group * tms;
int totalEntr = group * food;
int Total = totalFood + totalTns + totalEntr ;
double profit = Total * 10.0/100;
System.out.println("Total expenditure = Rs " + Total);
System.out.println("Profit = Rs " + profit);
}
}

Variable Description Table

Variable Name Data type Use
group int indicating total number of people in the group
food int amount per person on food
trns int amount per person on transport
entr int amount per person on entertainment
totalFood int total amount on food
totalTns int total amount on transport
totalEtr int total amount on entertainment
Total int total amount
profit double total profit

Output
Total expenditure = Rs 28750
Profit = ₹ 2875.0

ICSE Class 9 Computer Applications Sample Question Paper 4 with Answers

Question 5.
In a library, books were given to members for 10 days. Upon late return, they were charged at a rate given below –
Days Late   (D)                      Late  Fine(F)
D <= 5                                   10
D > 5 and    D <= 10             15
D > 10                                   30
Input the number of days a member is late in returning a book. Print the late fine.
Answer:

import java.util.*;
public class Q 5
void main( )
{
Scanner sc new Scanner (System.in);
int D = 0, F = 0;
System.out.print("Enter number of days late :");
D = sc.nextlnt(); if ( D <= 5 )
{
F = 10;
}
else if( D <= 10)
{
F = 15;
}
else
F = 30;
}
System.out.println(" Number of days late " + D );
System.out.print(" Fine to pay = Rs" + F );
}
}

ICSE Class 9 Computer Applications Sample Question Paper 4 with Answers

Variable Description Table

Variable Name Data type Use
D int Input variable, number of days late
F int amount to pay as late fine

Output
Enter number of days late : 12
Number of days late 12
Fine to pay = ₹ 30

Question 6.
In a art workshop, different courses had different course code and course charge per day, as given below

Course Code Course Name Course Charge (per day)
101 Stone Painting 160
102 Origami 125
201 Bag Painting 250

Input the course code( c) and number of days(d) a student wants to enroll. Calculate and print the amount to be paid by a student. [Apply switch case construct]
Answer:

import java.util.*; public class Q6
{
void main( )
{
Scanner sc = new Scanner (System.in);
int C = 0, D = 0 , T = 0;
System.out.print("Enter the Course Code : ");
C = sc.nextlnt();
System.out.print("Enter the number of days of course :
D = sc.nextlnt();
switch ( C)
{
case 101: T = D * 160;
break;
case 102 : T = D * 125;
break;
case 201: T = D * 250;
break;
default : T = 0;
System.out.print("Sorry, no such course");
}
System.out.print(" Amount to pay = Rs " + T );
}
}

ICSE Class 9 Computer Applications Sample Question Paper 4 with Answers

Variable Description Table

Variable Name Data type Use
C int Input variable, number of days late
D int amount to pay as late fine
T int amount to pay as late fine

Output
Enter the Course  Code : 102
Enter the number of days of course : 15
Amount to pay = ₹ 1875.

Question 7.
Print the given series for n number of terms. [Input n]
1 + (1/2) + 3 + (1/4) + 5 +(1/6) + …
Answer:

import java.util.*;
public class Q 7
{
void main()
{
Scanner sc = new Scanner (System.in); int n ; double val = 0, s = 0; System.out.print("Enter the number of terms : "); - n = sc.nextlnt();
for (int t = 1; t <= n; t++)
{
if (t %2 ! = 0)
{
val = t;
else
val = 1.0 / t;
}
s = s + val;
}
System.out.print(" Sum of the series = " + s );
}
}

ICSE Class 9 Computer Applications Sample Question Paper 4 with Answers

Variable Description Table

Variable Name Data type Use
n int Input variable, number of terms
val double term value
s double sum of terms
t int loop counter

Output
Enter the number of terms : 5
Sum of the series = 9.75

Question 8.
A number is called a Cyclo number if its first and last digit is same. Input a number and verify whether it is a Cyclo Number or not. For example 52145
Answer:

import java.util.*; 
public class Q 8
{
void main( )
{
Scanner sc new Scanner (System.in);
int n = 0, d = 0, p = 1;
System.out.print("Enter a number : ");
n = sc.nextlnt( );
d = n%10; int cn = n; while ( cn>=10)
{
cn = cn/10;
}
if ( d == cn)
{
System.out.print(n + " is a Cyclo Number " );
}
else
{
System.out.print(n + " is NOT a Cyclo Number " );
}
}
}

ICSE Class 9 Computer Applications Sample Question Paper 4 with Answers

Variable Description Table

Variable Name Data type Use
n int Input variable, number of terms
d double term value
P double sum of terms
cn int loop counter

Output
Enter a number : 5206
5206 is NOT a Cyclo Number

Question 9.
Write a program to print the following pattern using nested for loop 8
Answer:

import java.util.*;
public class Q 9
{
void main( )
{
for(int r = 8; r >=4; r- -)
{
for(int c = r; c <=8; C++ )
{
System.out.print(" " + c);
}
System.out.println( );
}
}
}

ICSE Class 9 Computer Applications Sample Question Paper 4 with Answers

Variable Description Table

Variable Name Data type Use
r int to store the row number
c int to store the column number

ICSE Class 9 Computer Applications Question Papers with Answers

ICSE Class 9 Computer Applications Sample Question Paper 3 with Answers

ICSE Class 9 Computer Applications Sample Question Paper 3 with Answers

Section – A
(Attempt all questions)

Question 1.
(a) Write two features of Java.
(b) Define polymorphism with an example.
(c) How are worms harmful ?
(d) What is the difference between = and = = ?
(e) Name the arithmetic operators used in Java. Which operator does a different task in mathematics ? Explain in brief with example.
Answer:
(a) Platform Independent: Java programs can be run on any platform that has Java Virtual Machine, such as Windows, Unix etc)
Robust: It performs extensive error checking and does not let the memory get hanged.

(b) It is the ability of methods to have same name but to behave differently under different situations. For example, a student can also be an artist and a musician.

(c) A worm is responsible for memory or disk crashes. Worms work by replicating itself on the disk and taking up memory space until eventually the disk crashes.
Example : I Love You, Morris, Sobig, Mydoom worm etc.

ICSE Class 9 Computer Applications Sample Question Paper 3 with Answers

(d) = is the assignment symbol. It cannot have a literal on its left.
= = is the operator for comparison of equality. It can have variables/literals on both sides.

(e) + – * / %
% mod operator is-1 applied in calculation of percentage in mathematics.

Question 2.
(a) Write a difference between entry controlled and exit controlled loop.
(b) What are the logical operators?
(c) What is a spam?
(d) What is phishing?
(e) Rewrite the following condition using ternary operators :
if ( a < 24 )
p = 12;
else
P = 48;
Answer:
(a) Two differences between entry controlled and exit controlled loop,
entry controlled : condition is verified before execution of loop body may not get executed even once for and while loops are entry controlled
exit controlled : condition is verified after execution of loop body gets executed at least once do while loop is entry controlled !

(b) ( NOT) && ( AND) || (OR)

ICSE Class 9 Computer Applications Sample Question Paper 3 with Answers

(c) Spams are unwanted e-mails sent from unknown people. These are bulk e-mails that are sent to people generally for advertising, phishing etc. In some cases, spam may consume a lot of memory space.

(d) Phishing is the act of extracting important information from innocent users, by posing as someone reliable. Some websites carry out phishing by disguising themselves as any socially important website and then asking people to provide confidential information. This confidential information are later used for harmful purposes,

(e) p = ( a < 24) ? 12 : 48;

Question 3.
(a) What will be the output:
int K = 66, f = 2, g = 6 , rank = 1;
if ( K % f != 0 )( K %g != 0)
{
rank = 0;
}
System.out.print( ” Rank = ” + rank);
Answer:
Rank = 1

(b) Rewrite using do. .while loop :
int Q = 7, K = 10; while ( Q > 2)
K + = 2;
Q – -;
}
System.out.print(” Result = ” + K ) ;
Answer:

int Q = 7, K = 10;
do
{
K=K+2;
Q - -;
}
while (Q > 2);
System.out.print("Result = " +K);

ICSE Class 9 Computer Applications Sample Question Paper 3 with Answers

(c) What will be the output of the given code , given that Pg = 16, Pr = 22
if (( Pg >= 10 &&Pr <= 20 )) (( Pg >= 20 &&Pr <= 10 ))
{
System.out.print (“Madagaskar”);
else
{
System.out.print (“Maldives”);
}
Answer:
Maldives

(d) What is the difference between Math.floor( ) and Math.ceil() ?
Answer:
Math.floor ( ) : The largest floating-point value that is smaller than the entered number.
Example Math.floor(2.26) = 2.0
Math.ceil ( ): The smallest floating-point value that is greater than the entered number.
Example Math.ceil( 6.38) = 7.0

(e) Debug the following code and rewrite it correctly :
doublepr = ( b =! q ); 100 ? 250 :
Answer:
double pr = ( b != q ) ? 100 : 250;

(f) What is fall through ? Explain with an example.
Answer:
Fall through is a situation that occurs in the switch case construct when the different cases are not terminated by the break statement. As a result of which all the cases occurring after the selected case gets executed until the first break statement is reached.
For example :
switch (k)
{
case 1 : System.out.print(“Blue”) ;
case 2 : System.out.println(“Green”) ;
case 3 : System.out.println(“Orange”) ;
break;
case 4 : System.out.println(“White”) ;
}
Output if k == 1
Blue
Green
Orange

ICSE Class 9 Computer Applications Sample Question Paper 3 with Answers

(g) Write the output of the following code :
int W = 737, s = 0;
int cW = W;
while ( cW != 0 )
{
s = s + cW % 10;
System.out.println( ” S = ” + s );
cW = cW/10;
}
Answer:
S = 7
S= 10
S= 17

(h) Write the output of the following code :
int T = 9;
for (int n = T; n > 6; n – – )
{
int V = T * n + n ;
System.out.println( “Value = ” + V );
}
Answer:
Value =90
Value = 80
Value =70

Section – B
(Attempt Any Four)

Question 4.
Input a number in T. Calculate the print the result of the following formulae :
G = 4028 + T/4 + T2 + 8*T
Answer:
Input a number in T. Calculate the print the result of the following formulae
G = 4028 + T/4 + T2 + 8*T

import java.util.*;
public class Q5
{
void main( )
{
Scanner sc = new Scanner (System.in);
double T= 0.0, G = 0.0;
System.out.print("Enter a number : ");
T = sc.nextDouble( );
G= 4028 +, (T/ 4)+(T*T)+(8*T);
System.out.print(" Value of T = " + T + " & Result G = " + G );
}

ICSE Class 9 Computer Applications Sample Question Paper 3 with Answers

Variable Description Table

Variable Name Data type Use
T double Input variable
G double result

Question 5.
Calculate and print the value of W, by taking necessary inputs, given the following :
W = ((M – 10) + (N – 5)) / P      when P = 10
= ((M – 20) + (N – 10)) / (4*P)  when P = 20
= ((M – 5) + (N – 15)) / (2*P)    otherwise
Answer:

W = ((M - 10) + (N - 5)) / P when P - 10
= ((M - 20) + (N - 10)) / (4*P) when P = 20
= ((M - 5) + (N - 15)) / (2*P) otherwise import java.util.*; public class
Scanner sc = new Scanner (System.in); double M= 0.0, N = 0.0, W=0.0; int P=0;
System.out.println("Enter Numbers M , N : "); M = sc.nextDouble( );
N = sc.nextDouble( );
System.out.println("Enter Number P: ");
P = sc.nextlnt(); if (P - 10)
W = ((M - 10) + (N - 5)) / P; else if ( P==20 )
W = ((M - 20) + (N - 10)) / (4*P) ;
else
W= ((M - 5) + (N - 15)) / (2*P) ;
System.out.print(" Value of W = " + W );
}
}

ICSE Class 9 Computer Applications Sample Question Paper 3 with Answers

Variable Description Table

Variable Name Data type Use
M, N double Input variables
W double result

Question 6.
Create a mini calculator. Enter two numbers (say a, b). Enter a choice (say ch). Perform add, subtract, multiply and divide upon the value of choice being 1, 2, 3, 4.. Use switch..case operator.
Answer:

import java.util.* ;
public class Q7
{
void main( )
{
Scanner sc = new Scanner (System.in) ;
int a = 0, b= 0, ch=0, r=0;
System.out.println("Enter 2 numbers : ");
a = sc.nextlnt( );
b= sc.nextlnt( );
System.out.println("Enter the choice : ");
ch = sc.nextlnt( );
switch (ch)
{
case 1 : r = a + b;
break;
case 2 : r= a - b;
break;
case 3 : r= a * b;
break;
case 4 : r = a / b;
break;
default : System.out.print("Wrong Choice");
}
System.out.println("Result: " + r ) ;
}
}

Variable Description Table

Variable Name Data type Use
a, b integer Input variables
c integer Input of choice
r integer to store result

Question 7.
Print the result of the given series using a for loop.
1 + (1/2) + (1/3) + (1/4) + … upto n terms
Answer:

import java.util.* ;
public class Q8
{
void main( )
{
Scanner sc - new Scanner (System.in) ;
int n = 0; double s = 1.0;
System.out.println("Enter number of terms : ") ;
n = sc.nextlnt( );
System.out.print("1 + ") ;
for (int i=2; i <= n-1; i++)
{
System.out. print(" (l/"+i+ ") +");
s = s + (1.0 / i);
}
s = s + (1.0/n);
System.out.print(" (1/" + n +") = " + s );
}

ICSE Class 9 Computer Applications Sample Question Paper 3 with Answers

Variable Description Table

Variable Name Data type Use
n integer Input, total terms
s double to store sum
i integer loop counter

Question 8.
Input a number of type integer. Print its factors,
Answer:

import java.util.* ;
public class Q9
{
void main( )
{
Scanner sc = new Scanner (System.in);
{
int n = 0;
System.out.println("Enter a number : ");
n = sc.nextlnt( );
System.out.print("Its   factors  are:  1  ");
for(int f = 2 ; f <= (n/2); f ++)
{
if (n%f == 0)
System.out.print(" " + f ) ;
}
System.out.print('' " + n);
}
}

Variable Description Table

Variable Name Data type Use
n integer Input number
f integer loop counter

Question 9.
Print the following pattern using nested for loop :
ICSE Class 9 Computer Applications Sample Question Paper 3 with Answers 1
Answer:

import java.util.* ;
public class Q10
{
void main( )
{
for (int r =1; r <= 5; r++)
{
for (int c =3; c <= 8 - r ; C++)
System.out.print( c+ " " );
System.out.println( ) ;
}
}
}

ICSE Class 9 Computer Applications Sample Question Paper 3 with Answers

Variable Description Table

Variable Name Data type Use
r int to store the row number
c int to store the column number

ICSE Class 9 Computer Applications Question Papers with Answers

ICSE Class 9 Computer Applications Sample Question Paper 2 with Answers

ICSE Class 9 Computer Applications Sample Question Paper 2 with Answers

Section – A
(Attempt all questions)

Question 1.
(a) Write two differences between Object Oriented Programming and Procedure Oriented Programming.
(b) Define abstraction with an example.
(c) What is copyright and what is trademark ?
(d) What are Java Applets ?
(e) What are spams ?
Answer:
Follows bottom-up approach
More secure as having data hiding feature
(a) OOP : Follows bottom-up approach
More secure as having data hiding feature
POP : Follows top-down approach
Less secure as there is no way of data hiding

(b) Any representation of data in which the implementation details are hidden is known as data abstraction.
For example, a person may know how to drive a car but may not know how to repair it.

ICSE Class 9 Computer Applications Sample Question Paper 2 with Answers

(c) Copyright – It gives the right to the creator that no one can copy the same. However, someone can do the whole thing from the beginning keeping the basic idea same. Copyrighted items have a symbol of ©.
Trademark – It is a distinct name that is used for some kind of goods or services. Symbol of trademark is-©.

(d) A Java Applet is a small and efficient Java program, which is used for internet programming.

(e) These are bulk e-mails that are sent to people generally for advertising, phishing etc. In some cases, spam may consume a lot of memory space.

ICSE Class 9 Computer Applications Sample Question Paper 2 with Answers

Question 2.
(a) Write two differences between if else and switch-case constructs.
(b) Write two features of a constructor.
(c) What are increment and decrement operators ?
(d) What are comments? Give example.
(e) What is ternary operator?
Answer:
(a) if else : All relational operators can be used.
All data-types are allowed.
Multiple conditions can be connected by using logical operators.

switch-case : Only comparison of equality operator can be used.
Only integer type (byte, short, int, long) and char type data can be used.
Multiple conditions cannot be connected by using logical operators.

(b) Has the same name as the class and no return type.
Invoked directly when object is created.

(c) These operators are used to increment / decrement the value of a variable by 1.
a = 5; a++ ; / / value of a becomes 6

(d) Comments are statements that are not executed by the compiler/interpreter. They are used to provide information about parts of the code.
Single line comment / /
Multiple line comment /* ………. * /

(e) It is a single line conditional operator.
Syntax : result = Cond ? true : false;
Example : r = (a>b)?a : b;

ICSE Class 9 Computer Applications Sample Question Paper 2 with Answers

Question 3.
Answer with respect to given code :
(a) The given code has some errors. Rewrite the code correctly and underline the changes made
Switch (m)
{
case 8 : System.out.piint [88];
break;
default: System.out.print [100];
}
Answer:
(a)

switch (m)
{
case 8 : System.out.print(88);
break;
default : System.out.print(100);
}

(b) Identify the error, if any, in the following code snippet:
for ( c ==25, c < 20 , c – -)
Answer:
for ( c =25; c > 20; c – – )

(c) Identify the error, if any, in the following code snippet:
for (q = = 1; q <= 100 ; q = = q + 10 )
Answer:
for (q = 1; q <= 100; q = q + 10 )

ICSE Class 9 Computer Applications Sample Question Paper 2 with Answers

(d) What are the components of a for loop ?
Answer:
initialization
condition test
update variable

(e) What is the role of break statement in a loop ? Show a code example.
Answer:
When a break statement is encountered inside a loop, it is immediately terminated and the control comes out of the loop block and resumes at the next statement following the loop.
for(k=1;k<=6;k++)
{
System.out.print( k + ” “);
if ( k > 3)
{
break;
}
}
It will print 1  2  3

ICSE Class 9 Computer Applications Sample Question Paper 2 with Answers

(f) Write the output of the following code :
int y = 6; do
{
System.out.print( y++ + ” .. ” )
y++;
}
while ( y <= 12);
Answer:
6 ..8 ..10 ..12 ..

ICSE Class 9 Computer Applications Sample Question Paper 2 with Answers

(g) Write the output of the following code :
for ( k = 100; k > 55; k= k – 5)
{
if ( k%2 = = 0)
{
continue ;
}
System.out.print(k + ” “);
}
Answer:
95, 85, 75, 65.

Section – B
(Attempt Any four)

Question 4.
Input a number in K. Calculate the print the result of the following formulae :
W = (7*K + K2 ) / 2
Answer:

import java.util.*; public class Q5
{
void main( )
Scanner sc = new Scanner (System.in);
double K = 0.0, W = 0.0;
System.out.print("Enter a number : ");
K = sc.nextDouble( );
W = (7 * K + K*K )/ 2;
System.out.print(" Value of K = " + K + " & Result W = " + W );
}
}

Variable Description Table

Variable Name Data type Use
K double Input variable
W double Result

Output :
Enter a number : 11.5
Value of K = 11.5 & Result W = 106.375

ICSE Class 9 Computer Applications Sample Question Paper 2 with Answers

Question 5.
Input two numbers and find the max and min. Show the use of the ternary operator.
Answer:

import java.util.*;
public class Q6
{
void main( )
{
Scanner sc = new Scanner (System.in);
int nl = 0, n2 = 0, max - 0, min = 0;
System.out.print("Enter 1st number :");
n1 = sc.nextlnt( ) ;
System.out.print("Enter 2nd number
n2 = sc.nextlnt( );
max (n1 > n2) ? n1 : n2;
min = (n1 < n2) ? n1 : n2;
System.out.println(" Max of " + nl + " and " + n2 + " = " + max );
System.out.print(" Min of " + nl + " and " + n2 + " = " + min );
}
}

Variable Description Table

Variable Name Data type Use
n1, n2 int Input variables
max int Result of maximum
min int Result of minimum

Output :
Enter 1st number : 54
Enter 2nd number : 68
Max of 54 and 68 = 68
Min of 54 and 68 = 54

ICSE Class 9 Computer Applications Sample Question Paper 2 with Answers

Question 6.
Input a number and print the corresponding day of the week. Assume that a. week begins with Sunday with day number being 1. Valid day numbers are from 1 to 7. Use switch..case operator.
Answer:

import java.util.*;
public class Q7
void main ( ) throws IOException
{
Scanner sc = new Scanner (System.in);
int wn = 0;
System.out.print(”Enter day number:”);
wn = sc.nextlnt( ) ;
switch (wn)
{
case 1: System.out.print(”\n When wn = “+ wn + “ the weekday is SUNDAY.”);
break;
case 2: System.out.print(”\n When wn = “ + wn + “ the weekday is MONDAY.”);
break;
case 3: System.out.print(”\n When wn = “ + wn + “ the weekday is TUESDAY.”);
break;
case 4: System.out.print(”\n When wn =‘‚ + wn + “the weekday is WEDNESDAY.”);
break;
case 5: System.out.print(”\n When wn =“ + wn +“ the weekday is THURSDAY.”);
break;
case 6: System.out.print(”\n When wn =‘‚ + wn +“ the weekday is FRIDAY.”);
break;
case 7: System.out.print(”\n When wn = “ + wn + “ the weekday is SATURDAY.”);
break;
default: System.out.print(”\n wn = is an INVALID day number. “);
}
}
}

Variable Description Table

Variable Name Data type Use
wn int Input variable, day of week, its day number is to be printed

Output :
Enter the week number : 7
When wn = 7 the weekday is SATURDAY.
Enter the week number : 0
wn = 0 is an INVALID day number.

ICSE Class 9 Computer Applications Sample Question Paper 2 with Answers

Question 7.
Print the given series using a for loop.
10          2               30            4                  50                6       … upto n terms
Answer:

import java.util.*;
public class Q8
{
void main( )
{
Scanner sc = new Scanner (System.in);
int n = 0;
System.out.print("Enter number of terms : ");
n = sc.nextlnt( );
for (int t = 1; t<=n; t++)
{
if (t %2 != 0)
{
System.out.print(" " + (t * 10) );
}
else
{
System.out.print(" " + t);
}
}
}
}
Variable Description Table
Variable Name Data type Use
n int Input variable, number of terms
t int loop counter indicating each term in the loop

Output :
Enter number of terms : 10
10 2 30 4 50 6 70 8 90 10

ICSE Class 9 Computer Applications Sample Question Paper 2 with Answers

Question 8.
Input a number of type integer. Calculate and print the product of its digits. Use while loop.
Answer:

import java.util.*;
public class Q9
{
void main( )
{
Scanner sc = new Scanner (System.in);
int n = 0, d = 0, p = 1;
System.out.print("Enter a number : ");
n = sc.nextlnt( );
int cn = n;
while ( cn > 0)
{
d = cn%10;
P = P * d;
cn = cn/10;
System.out.print(" Product of digits of " + n + " = " + p);

Variable Description Table

Variable Name Data type Use
n int Input variable
cn int copy of n, from which digits to be taken
d int to store the digits of cn
P int to store the product of digits

Output :
Enter a number : 546
Product of digits of 546 = 120

ICSE Class 9 Computer Applications Sample Question Paper 2 with Answers

Question 9.
Print the following pattern using nested for loop.
ICSE Class 9 Computer Applications Sample Question Paper 2 with Answers 1
Answer:

import java.util.*;
public class Q9
{
void main( )
{
for (int r = 5; r <-9; r++ )
{
for (int c = r; c >=5; c - - )
{
System.out.print(" " + c);
}
System.out.println( );
}
}
}

Variable Description Table

Variable Name Data type Use
r int to store the row number
c int to store the column number

ICSE Class 9 Computer Applications Question Papers with Answers

ICSE Class 9 Computer Applications Sample Question Paper 1 with Answers

ICSE Class 9 Computer Applications 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 questions)

Question 1.               [5 x 2 = 10]
Answer the following in brief.
(a) Write two integer primitive data types. [2]
(b) Write two java keywords. [2]
(c) What is a token in Java ? [2]
(d) State any two harms caused by software piracy. [2]
(e) What do you mean by Intellectual property rights ? [2]
Answer:
Answer the following brief:
(a) int, double
(b) if, class
(c) Token is the smallest identifiable part of a program. For example : Keywords, Literals.
(d) Software piracy is unethical. Some of the harms caused are :
• Financial loss to the creative programmers, who make them.
• Causes hike in the general cost of the Software.
(e) Intellectual property refers to any intangible property that consists of original ideas and human knowledge.

ICSE Class 9 Computer Applications Sample Question Paper 1 with Answers

Question 2.
Answer with respect to given code. [5 x 2 = 10]
(a) What will be the value of b, c when nl = 10, n2 = 0, given that: [2]
int b = (nl < n2) ? nl : n2 ;
double c = (n2 != 0) ? (nl/n2) : (nl * 2);
Answer:
Answer with respect to given code:
(a) b = 0
c = 20

(b) Given the initial value of r = 5 in the following expression : [2]
v = r++ + 2*r + 2*r++
Write the final value in v and r.
Answer:
v = 5 + 2*6 + 2*6 =29
r = 7

(c) Given the initial value of a = 10, k = 2 in the following expression : [2]
k+ =  a++ + ++a/2;
Write the final value in k and a.
Answer:
k = 2 + (10 + 12/2) = 18
a = 12

ICSE Class 9 Computer Applications Sample Question Paper 1 with Answers

(d) Rewrite the following code after debugging (underline the changes made) : [2]
switch (wn) ;
{
case 1 : System.out.print(” Geography”);
break;
case 2 : System.out.print(“Chemistry”) break;
Default : System.6ut.print(“Mathematics”);
}
Answer:

switch (wn)
{
case 1 : System.out.print(" Geography");
break;
case 2 : System. out.print( "Chemistry")
break;
default: System.out.print("Mathematics");
}

ICSE Class 9 Computer Applications Sample Question Paper 1 with Answers

(e) Rewrite the following code after debugging (underline the changes made) [2]
for (int f = 10 , f > 5 , f++ )
{
System.out.print( f +”………”);
}
Answer:

Rewrite the following code after debugging (underline the changes made)
for (int f = 10; f > 5; f - - )
{
System.out.print (f + " ... ");
}

Question 3.
(a) Differentiate between Entry controlled and Exit controlled loop. [2]
Answer:
(a) Entry controlled and Exit controlled loop.
Entry Controlled Loop : The loop first verifies the test condition. If it is true only than it runs the loop body. For example : for loop and while loop.
Exit Controlled Loop: The loop first runs the loop body and then verifies the test condition. In this case the loop body gets executed at least once. For example : do while loop.

ICSE Class 9 Computer Applications Sample Question Paper 1 with Answers

(b) Differentiate between data type int and data type double. [2]
Answer:
(b) Data type int: This primitive datatype is used to store integers. Its default value is 0. Data type double : This primitive datatype is used to store large fractional number. Its default value is 0.0

(c) Differentiate between constructor and other methods of a class. [2]
Answer:
Constructor : They share the same name as that of the class.
They have no return type, not even void.
They are invoked upon creation of an object of the class.

Method : They have different name than that of the class.
They must have a return type.
They are invoked explicitly.

(d) Write the following code by using while loop : [4]
for (k = 501; k <= 521; k = k+2 )
{
System.out.print (” % ” + k );
}
Answer:
The code by using while loop
int k = 501;
while ( k <= 521)
{
System.out.print (” % ” + k );
k = k + 2;
}

ICSE Class 9 Computer Applications Sample Question Paper 1 with Answers

(e) Write the following code by using if .. else statement: [2]
P = ( g == 9.8) ? 0 : 1;
Answer:

The code by using if .. else statement
if ( g == 9.8)
{
p = 0;
}
else
{
p= 1;
}
p = (g== 9.8) ? 0 : 1;

ICSE Class 9 Computer Applications Sample Question Paper 1 with Answers

(f) Write the output of the following code : [4]
System.out.print(“The series is as follows – \n” ); for( int k = 710; k > 660; k – = 10)
{
System.out.println ( “XX ” + (k – 10) );
}
Answer:
The series is as follows :
XX – 700
XX – 690
XX – 680
XX – 670

(g) Write the output of the following code : [4]
double d = 100, c;
c = d;
while ( c > 20 )
{
System.out.println (“Value : : ” + c );
c – = 20;
}
Answer:
Value : : 100.0
Value : : 80.0
Value : : 60.0
Value : : 40.0

ICSE Class 9 Computer Applications Sample Question Paper 1 with Answers

Section-B
(Attempt Any Four)

Question 4.
It is puja season-and shopping season too ! You work as an employee at Small Bazaar. The owner has asked you to create an application that would quickly calculate a discount on the purchase, and also a gift. He hands you the following table for you to implement in your code:

ICSE Class 9 Computer Applications Sample Question Paper 1 with Answers 1
ICSE Class 9 Computer Applications Sample Question Paper 1 with Answers 2

Write a program that inputs the amount of purchase. Print the Amount Payable and the gift that the customer should get. [15]
Answer:

import java.util.*;
public class Q4
{
void main( )
Scanner sc = new Scanner (System.in);
double, ap=0.0, d=0.0;
int p=0;
System.out.print("Enter amount purchased: ");
p = sc.nextlnt( ); //input
if (p < 1100) / / 1st condition check
{
d= (5*p)/100.0; // calculation
System.out.print ("The gift is a wallet");
}
else if (p < 5100)
{
d= (10*p)/100.0;
System.out.print("The gift is a wrist watch");
}
else if (p < 10100)
{
d= (15*p)/100.0;
System.out.print("The gift is a wall clock");
{
d= (20*p)/100.0;
System.out.print("The gift is a travel kit");
}
ap = p - d; / /final calculation
System.out.print("The amount payable is + ap); //result printing
}
}

Variable Description Table

Variable Name Data type Use
C int Input variable, number of days late
D int amount to pay as late fine
T int amount to pay as late fine

Output
Enter the Course Code : 102
Enter the number of days of course : 15
Amount to pay = ₹ 1875

ICSE Class 9 Computer Applications Sample Question Paper 1 with Answers

Question 5.
Teacher -“What is a Nest number ?” [15]
Kabir- “A number is said to be a ‘Nest Number’ if the number contains at least one digit which is zero.”
Eg Input : 2008
Output : It is a Nest Number

Eg Input : 238
Output : Not a Nest Number
Teacher-‘great job, Kabir ! Can you write a code to check for the same ?’
Assume that you are Kabir. Write a program to input a number and check if it is a Nest number or not! [15]
Answer:

import java.util.*; public class Q5
{
void main( )
{
Scanner sc = new Scanner (System.in);
int n = 0, d = 0, f = 0;
System.out.print("Enter a number :");
n = sc.nextlnt( );
int cn = n; while ( cn > 0)
{
d = cn%10;
if (d==0)
f=1;
cn = cn/10;
}
if(f== 0)
System.out.print(" It is not a nest number");
else
System.out.print(" It is a nest number");
}
}

Variable Description Table

Variable Name Data type Use
n int Input variable, number
cn int copy number
d int to store digits
f int flag to indicate Nest number or not

Output
Enter a number : 6345
It is not a nest number.

ICSE Class 9 Computer Applications Sample Question Paper 1 with Answers

Question 6.
Write a program to print the given series : [15]
3 6 12 24 48 96 …. up to n terms
Answer:

import java.util.*;
public class Q6
{
void main( )
{
Scanner sc = new Scanner (System.in);
int n = 0, c = 6;
System.out.print("Enter the number of terms : ");
n = sc.nextlnt( );
while(n > 0)
{
System.out.print(c + " ");
n - = l;
c = c * 2;
}
}
}

Variable Description Table

Variable Name Data type Use
n int Input variable, number of terms
c int term values

Output
Enter the number of terms : 7 6 12 24 48 96 192 384

ICSE Class 9 Computer Applications Sample Question Paper 1 with Answers

Question 7.
Write a program to input n and print the following pattern [ here n = 4] [15]
ICSE Class 9 Computer Applications Sample Question Paper 1 with Answers 3
Answer:

import java.util.*;
public class Q7
{
void main( )
{
Scanner sc = new Scanner (System.in);
int n=0, r=0, c=0;
System.out.print ("Enter the number of terms:");
n = sc.nextlnt( );
for ( r = n ; r > 0; r - )
{
for (c = r; c > 0; c - -)
System.out.print("@");
System.out.println ( );
}
}
}

Variable Description Table

Variable Name Data type Use
n int Input variable, number of rows
r int outer loop counter
c int inner loop counter

ICSE Class 9 Computer Applications Sample Question Paper 1 with Answers

Question 8.
Imagine that you are a time keeper at the FI Grand Prix. You keep a record of the time taken by a car to complete a lap in seconds. For easier data keeping, the boss asks you to record the time in minutes and seconds. [15]
Write a code that takes time in seconds as input. Show the time in minutes and seconds.
Eg. Input – Time taken : 254 seconds
Output – The time taken is 4 minutes and 14 seconds
Answer:

import java.util.*;
public class Q8
{
void main( )
{
Scanner sc new Scanner (System.in);
int n = 0, m = 0, s = 0;
System.out.print("Time Taken in seconds : ");
n = sc.nextlnt( );
m = n/60;
s = n%60;
System.out.println("The time taken is" + m + "minutes and" + s + "seconds");
}
}

Variable Description Table

Variable Name Data type Use
n int Input variable, time taken in only seconds
m int time taken in minutes
s int time taken in seconds after minutes

Time Taken in seconds: 5000
The time taken is 83 minutes and 20 seconds

ICSE Class 9 Computer Applications Sample Question Paper 1 with Answers

Question 9.
Input a number and verify whether it is a Lead Number or not. A number is called a Lead number if the sum of the even digits is equal to the sum of the odd digits. For example, 1452. [15]
Answer:

import java.util.*;
public class Q9
{
void main( )
{
Scanner sc = new Scanner (System.in);
int n = 0, sed=0, sod=0, d;
System.out.println("The number is :");
n = sc.nextlnt( );;
int cn=n;
while(cn > 0)
{
d=cn%10;
if ( d % 2== 0)
sed+=d;
else
sod+=d;
cn=cn/10;
}
if( sod==sed)
System.out.println("IT IS A LEAD NUMBER");
else
System.out.println("IT IS NOT A LEAD NUMBER");
}
}

Variable Description Table

Variable Name Data type Use
n int Input number
cn int copy input
d int digit
sed int sum of even digits
sod int sum of odd digits

ICSE Class 9 Computer Applications Sample Question Paper 1 with Answers

The number is :
32452
IT IS A LEAD NUMBER.

ICSE Class 9 Computer Applications Question Papers with Answers

ICSE Class 9 Computer Applications Sample Question Papers with Answers 2021-2022

ICSE Class 9 Computer Applications Sample Question Paper with Answers 2021-2022

ICSE Sample Papers for Class 9 with Answers