Revision Booklet Class 9 Computers
Revision Booklet Class 9 Computers
7. How many times are the following loop bodies repeated? What is the final output in
each case?
int j = 3;
do {
System.out.println(j);
j--;
} while(j > 0);
8. What are tokens in Java? Name the different types of tokens available.
9. Describe the difference between primitive and reference data types in Java.
10. What is the += operator? Give an example of its usage.
11. State the difference between = and = =.
12. If x = 10, y = 5, calculate the value of:
y *= x + y;
13. What is type casting? How is explicit type casting different from implicit casting?
Programing
1. Write a program in Java that accepts a number of seconds and converts it into
corresponding hours, minutes, and seconds.
Sample output:
Enter Total Seconds: 7500
2 Hour(s) 5 Minute(s) 0 Second(s)
5. Write a program in Java to calculate the cost for sending a parcel based on its weight,
using the following charges:
o 0-5 kg: ₹50
o 5-10 kg: ₹100
o 10+ kg: ₹150
o
6. Write a menu-driven program to accept a number from the user and check if it is a
palindrome or a perfect square.
7. Write a program that prompts the user for the total number of cookies, the number of
cookies per box, and the number of boxes per container. The program then calculates
and displays the number of boxes and containers required to ship the cookies.
8. Write a program to accept a two-digit number. Add the sum of its digits to the product
of its digits. If the result is equal to the input number, display "Special number",
otherwise display "Not a special number".
9. Using the switch statement, write a menu-driven program to: a. Check whether a
number is a perfect number (a number whose sum of divisors equals the number
itself).
b. Find the largest digit of an integer. Sample input: 6524. Sample output: "Largest
digit is 6".
10. Write a program to display all numbers between 50 and 150 which don't contain the
digit '3' in them.
11. Write a program to display all prime palindrome numbers between 10 and 1000.
o Example: 101, 131, 151, 181
12. Write a program in Java to input a number with three digits or more. Arrange the
digits of the entered number in descending order and display the result.
o Sample Input: 4972
o Sample Output: 9, 7, 4, 2
13. Write a program to input a number and display only those factors of the number that
are prime.
14. Write a program using a do-while loop to compute the sum of the first 30 positive odd
integers.
15. Write a program to read the number n via the Scanner class and print the Fibonacci
series up to n terms.
16. Write a program to input a number and check whether it is a square number or not
17. Write a program to input a number and check and display whether it is a Narcissistic
number or not.
o A Narcissistic number is a number that is equal to the sum of its digits raised
to the power of the number of digits.
18. Write a menu-driven program to: a. Check if a number is a Buzz number or calculate
the GCD of two numbers. b. The GCD (Greatest Common Divisor) is calculated by
the Euclidean algorithm.
23. Write a program to enter two numbers and check whether they are co-prime or not.
o Two numbers are co-prime if their GCD is 1.
24. Write a program to input a number. Display the product of the successors of all even
digits of the number entered by the user.
o Example: Input: 2745. Output: 15 (The even digits are 2 and 4, the product of
their successors is 3*5=15).