Top 50 Java Interview Programs
1. Basic Java Programs
1. Hello World Program
2. Print ASCII value of a character
3. Swap two numbers (with and without using third variable)
4. Check whether number is even or odd
5. Check whether a year is leap year or not
6. Find largest among three numbers
7. Check whether a character is vowel or consonant
8. Check whether a number is positive, negative, or zero
9. Find factorial of a number (using loop and recursion)
10. Generate Fibonacci series (loop and recursion)
2. Number Programs
11. Check whether a number is prime or not
12. Generate prime numbers between 1 to N
13. Check whether a number is palindrome or not
14. Check whether a number is Armstrong or not
15. Find sum of digits of a number
16. Reverse a number
17. Count number of digits in an integer
18. Check whether a number is perfect or not
19. Calculate power of a number
20. Find GCD and LCM of two numbers
3. Pattern Programs
21. Print pyramid pattern
22. Print right-angle triangle
23. Print inverted triangle
24. Print Floyd's triangle
Top 50 Java Interview Programs
25. Print Pascal's triangle
26. Diamond pattern
27. Number pyramid
28. Star pattern - left and right aligned
29. Hollow square/star pattern
30. Butterfly pattern
4. String Programs
31. Reverse a string (loop and recursion)
32. Check whether string is palindrome or not
33. Count vowels and consonants in a string
34. Remove all white spaces from a string
35. Find frequency of each character in string
36. Replace a character in a string
37. Find duplicate characters in a string
38. Convert string to uppercase/lowercase
39. Compare two strings (using == and .equals())
40. Sort characters of string alphabetically
5. Array Programs
41. Find largest and smallest element in an array
42. Sort array elements (ascending and descending)
43. Reverse an array
44. Find duplicate elements in an array
45. Find sum of all elements in array
46. Merge two arrays
47. Remove duplicate elements from array
48. Find frequency of each element in array
49. Find second largest element in array
50. Search an element in array (Linear & Binary Search)