0% found this document useful (0 votes)
41 views3 pages

Revision Booklet Class 9 Computers

Questions on Java for Class 9

Uploaded by

Rajatava Roy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views3 pages

Revision Booklet Class 9 Computers

Questions on Java for Class 9

Uploaded by

Rajatava Roy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Class IX

Revision Booklet 2024-25

1. Distinguish between Math.abs() and Math.sqrt() methods.


2. Distinguish between the following: a. hasNext() and hasNextLine()
b. nextInt() and nextDouble()
3. Explain the following terms, giving an example of each: a. Compile-time error
b. Runtime exception
c. Logical bug
4. How are these statements different from each other:
a. break
b. continue
5. What are the differences between a for loop and a while loop?
6. How many times are the following loop bodies repeated? What is the final output in
each case?
int i = 1;
while(i < 10) {
System.out.println(i);
i += 2;
}

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)

2. Write a program in Java to input a temperature in Celsius, convert it into Fahrenheit,


and display the result in the Terminal window.
Sample output:
Enter temperature in Celsius: 30
30.0 degree Celsius = 86.0 degree Fahrenheit

3. Write a program to generate random integers between 50 and 100.


4. Write a program in Java to compute the area and perimeter of a rectangle with given
length and width.

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.

19. Write a program to generate the following output (using loops):


*
**
***
****
*****
20. Write a program in Java to display the following pattern (inverted triangle):
*****
****
***
**
*
21. Write a program to input two numbers and check whether they are twin prime
numbers or not.
o Twin prime numbers are two prime numbers that have a difference of 2.
Example: (11, 13), (17, 19).

22. Write a program to generate a right-angled triangle or inverted triangle depending on


the user's choice.
Example 1:
Enter your choice 1
Enter the number of terms 4
1
22
333
4444
Example 2:
Enter your choice 2
Enter the number of terms 5
55555
4444
333
22
1

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).

You might also like