ICSE sample paper class 9
https://java4school.com/loops-for-while-do-while

Section A (40 marks) compulsory questions
Q A. Define following. [5X2=10]
- Abstraction
- Differentiate object and class
- Write any 4 characteristics of OOP.
- What is IDE?
- What are the default values of int and float?
Q B. Write difference between the following. [5X2=10]
- Source code and object code
- // and /*…*/
- Keyword and Identifier
- If and switch
- for and do…while loop
ICSE sample paper class 9
Q C. [10X2=20]
- Write output of the following.
System.out.println (“Bentley”);
System.out.print(“BMW ”);
System.out.println(“Tesla”);
System.out.print(“Mercedes”);
- Name all the types of errors.
- Write output of the following.
for(int i=1;i<=5;i++)
System.out. print(i+” “);
- Convert the following loop into while loop
for(int j=10;j>=1;j–)
System.out. print(j+” “);
(i)Name the package used for scanner class.
(ii)The scanner class function to take a double as input
- Explain the term explicit conversion with an example.
- What will be the values in A1 and A2?
double A1= Math.abs(Math.min(-2.54, -4.67));
double A2=Math.sqrt(Math.floor(100.2));
- Write the following expression in java.
- if x=3, What is the value of x after evaluating the expression
x+= x++ —x+ 3+ –x
- What will be the value in a,b and c if the following expression is executed.
if a=2, b=4
c=a++ – b–+ –a
ICSE sample paper class 9
Section B (60 marks)
Write JAVA Programs. (Write INPUT and OUTPUT of each program) (Attempt any six) [6X10=60]
- Write a program to check whether the given year is a leap year or not.
- Write a program to take the month number from the user and display the name of the month. Display an error message for wrong input(Use switch case only).
- Write a program to accept a number from the user and display if the given number is prime or not. A prime number is a number that has only two factors.
- Write a program to, compute the railway fare depending on the criteria as given
Distance (in kms) | Fare (Rupees per Km) |
Below 10 | Rs. 5 |
From 10 to 30 | Rs. 20 |
From 31 and 50 | Rs. 30 |
Above 50 | Rs. 50 |
- The sum of two distances is calculated as:
Distance 1 = 10 feets 24 inches
Distance 2 = 5 feets 16 inches
Sum of Distances= 18 feets 4 inches
Write a program in Java to input two distances and calculate their sum by applying proper adjustments.
Display the final result with an appropriate message. (Given 1 feet = 12 inches)
- A computer salesman gets commission on the following basis:
Sales | Commission Rate |
Rs. 0 – 20,000 | 3% |
Rs. 20,000 – 50,000 | 12% |
Rs. 50,001 and more | 31% |
Write a program to accept the sales as input, calculate and print his commission amount and rate of commission.
- Write a program to find the sum of the following series.
sum=1+4+9+16+……….100
sum= 2+4+6+8+……..n
- Write a program to print the following series.
- 1 3 5 7 9
- 30 25 20 15 10
- Write a menu driven program using switch case statement that outputs the results of the following evaluation based on the number entered by the user
- Maximum of the two numbers
- Absolute value of the number
- Square root of the number
- Random numbers
- ICSE sample paper class 9
- Write a program to input the basic salary of a person and calculate the salaries and other allowances as given below and print all the values.
special allowance =15%of basic salary
conveyance allowance= 10% of basic salary
pf=5% of basic salary
gross=basic salary+special allowance+conveyance allowance
net salary=gross-pf
- Write a program to print the following paragraph
Online teaching is the process of educating others via the internet.
Various methods can be used such as
- one-on-one video calls
- group video calls
- webinars.
- ICSE sample paper class 9