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.
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);
(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
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
(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
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
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 ); } }
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 ); } }
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 ); } }
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 " ); } } }
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( ); } } }
Variable Description Table
Variable Name | Data type | Use |
r | int | to store the row number |
c | int | to store the column number |