Java Coding Interview Questions for Freshers
Section 1: Easy Java Questions
1. Print "Hello, World!"
2. Swap two numbers without using a third variable
3. Check if a number is even or odd
4. Find the largest of three numbers
5. Print numbers from 1 to 100
6. Check if a number is prime
7. Check if a number is palindrome (e.g., 121)
8. Check if a string is palindrome (e.g., "madam")
9. Find factorial of a number
10. Print Fibonacci series up to N terms
11. Count the number of digits in a number
12. Reverse a number
13. Reverse a string
14. Sum of digits of a number
15. Check if a year is a leap year
16. Calculate simple interest
17. Find the ASCII value of a character
18. Convert temperature from Celsius to Fahrenheit
19. Check if a character is a vowel or consonant
20. Print multiplication table of a given number
Section 2: Medium-Level Java Questions
1. Find the second largest element in an array
2. Remove duplicate elements from an array
3. Sort an array without using built-in methods
4. Check if two strings are anagrams
5. Count occurrences of each character in a string
6. Implement a basic calculator using switch-case
7. Find all prime numbers between 1 and 100
8. Check if an array is sorted
9. Find the missing number in a sequence (e.g., 1 to 100, but one number is missing)
10. Implement a basic bank account class using OOP (with deposit, withdraw methods)
Section 3: Easy String Questions
1. Print a string
2. Find the length of a string
3. Convert string to uppercase and lowercase
4. Reverse a string
5. Check if a string is a palindrome
6. Count vowels and consonants in a string
7. Count the number of words in a sentence
8. Compare two strings (== and .equals())
9. Check if a string contains a given substring
10. Replace a character in a string
11. Check if two strings are equal ignoring case
12. Remove all white spaces from a string
13. Concatenate two strings
14. Print each character of a string
15. Find the first and last character of a string
16. Check if string starts with or ends with a substring
17. Convert a string to a character array
18. Find the frequency of a character in a string
19. Check if a string is empty or null
20. Get substring from a string (using substring())
Section 4: Medium-Level String Questions
1. Check if two strings are anagrams of each other
2. Remove duplicate characters from a string
3. Find the first non-repeating character in a string
4. Print all permutations of a string
5. Count the occurrence of each word in a sentence
6. Find the longest word in a sentence
7. Sort characters of a string alphabetically
8. Check if a string contains only digits
9. Convert a string to an integer (without using Integer.parseInt())
10. Capitalize the first letter of each word in a sentence