Java Basics Practice Set - 30 Questions with
Examples
1. Print "Hello Java" without using semicolon
Example: Print Hello Java using [Link] or other tricks without ';'
2. Check if a number is even or odd
Example: Input = 5 → Output = Odd
3. Find the greatest of three numbers
Example: Input = 3, 7, 5 → Output = 7
4. Simple calculator using switch-case
Example: Input = 2, 3, + → Output = 5
5. Check vowel or consonant
Example: Input = 'a' → Output = Vowel
6. Print multiplication table
Example: Input = 3 → Output = 3, 6, 9, ..., 30
7. Swap two numbers using third variable
Example: Input = 5, 10 → Output after swap = 10, 5
8. Swap two numbers without third variable
Example: Input = 4, 9 → Output after swap = 9, 4
9. Check if a number is prime
Example: Input = 11 → Output = Prime
10. Reverse a number
Example: Input = 123 → Output = 321
11. Find GCD of two numbers
Example: Input = 8, 12 → Output = 4
12. Find LCM of two numbers
Example: Input = 4, 5 → Output = 20
13. Find sum of digits
Example: Input = 123 → Output = 6
14. Print ASCII value of a character
Example: Input = 'A' → Output = 65
15. Convert Celsius to Fahrenheit
Example: Input = 0 → Output = 32
16. Convert decimal to binary
Example: Input = 5 → Output = 101
17. Convert binary to decimal
Example: Input = 101 → Output = 5
18. Find factors of a number
Example: Input = 6 → Output = 1, 2, 3, 6
19. Count digits in number
Example: Input = 12345 → Output = 5
20. Check if number is strong number
Example: Input = 145 → Output = Strong number
21. Check automorphic number
Example: Input = 25 → Output = Automorphic number
22. Check neon number
Example: Input = 9 → Output = Neon number
23. Check perfect number
Example: Input = 6 → Output = Perfect number
24. Check harshad number
Example: Input = 18 → Output = Harshad number
25. Check friendly pair number
Example: Input = 6, 28 → Output = Friendly pair
26. Sum of first N natural numbers
Example: Input = 5 → Output = 15
27. Find square root without sqrt()
Example: Input = 16 → Output = 4
28. Leap year check
Example: Input = 2020 → Output = Leap year
29. Print numbers 1 to 100 without loops
Example: Output = 1 2 3 ... 100
30. Find largest of two numbers without if/else
Example: Input = 5, 9 → Output = 9