0% found this document useful (0 votes)
3 views1 page

Java Practice Questions If Else Loops Switch

The document contains a list of Java practice questions focused on control structures such as if-else, loops, and switch statements. It includes tasks like checking even or odd numbers, finding the largest number, determining leap years, and performing basic arithmetic operations. Additionally, it covers loops for printing sequences, calculating sums, and checking for prime numbers.
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)
3 views1 page

Java Practice Questions If Else Loops Switch

The document contains a list of Java practice questions focused on control structures such as if-else, loops, and switch statements. It includes tasks like checking even or odd numbers, finding the largest number, determining leap years, and performing basic arithmetic operations. Additionally, it covers loops for printing sequences, calculating sums, and checking for prime numbers.
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

Java Practice Questions (If–Else, Loops, Switch,

Break, Continue)

1. Write a Java program to check whether a number is even or odd using if-else.

2. Write a Java program to find the largest between two numbers using if-else.

3. Write a Java program to find the largest among three numbers.

4. Write a Java program to check whether a number is positive, negative, or zero.

5. Write a Java program to check whether a year is a leap year or not.

6. Write a Java program to display grade based on marks (90+ A, 70–89 B, 50–69 C, below 50
Fail).

7. Write a Java program using switch case to perform addition, subtraction, multiplication, and
division.

8. Write a Java program using switch case to print day name based on a number (1–7).

9. Write a Java program to display month name based on month number (1–12).

10. Write a Java program using switch case to check whether a character is a vowel or consonant.

11. Write a Java program using a for loop to print numbers from 1 to 10.

12. Write a Java program to find the sum of first N natural numbers.

13. Write a Java program to print the multiplication table of a given number.

14. Write a Java program to calculate the factorial of a number using a loop.

15. Write a Java program to reverse a number.

16. Write a Java program that prints numbers from 1 to 10 but stops when it reaches 5 using break.

17. Write a Java program that prints numbers from 1 to 10 but skips number 5 using continue.

18. Write a Java program to print even numbers from 1 to 20.

19. Write a Java program to calculate the sum of even numbers from 1 to 50.

20. Write a Java program to check whether a number is prime or not using loops.

You might also like