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.
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
(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"); }
(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.
(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;
}
(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;
(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
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:
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
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.
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
Question 7.
Write a program to input n and print the following pattern [ here n = 4] [15]
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 |
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
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 |
The number is :
32452
IT IS A LEAD NUMBER.