Bhavin Thumar
2 min readMay 13, 2024

Top Java Coding Interview Questions for Automation Tester

As QA Automation Testers, we all understand the importance of the languages and frameworks. During interviews, I’ve noticed that many candidates mention having an understanding of Java and Selenium, but when I ask them, they don’t execute any single coding questions. That is why I wrote this blog: to help you understand and be aware of the coding questions. I’m not sure if you’ll be able to pass any coding interviews, but you should be able to learn something after reading this blog. I have gathered the most asked interview coding questions from my own interview experience and other top online sites.

1. Find duplicate char from string. Write a program to find duplicate characters in a given String.

Input: hackerearth
Output: h a e r

2. Remove duplicate char from string: Write a program to remove duplicate characters in a given String.

Input: hackerearth
Output: hackert

3. Revere string: Write a program to reverse a given string.

Input: This is a string
Output: gnirts a si sihT

4. String count of non-space chracter: Write a program to calculate the count of non-space characters in a string.

Input: This is a string
Output: 13

5. Swap two string using Substring: Write a program to swap the two strings using substring.

Input: Hello world
Output: World Hello

6. Swap two string using temp variable: Write a program to swap the two strings using temp variable.

Input: Hello world
Output: World Hello

7. Swap two string using String Builder: Write a program to swap the two strings using StringBuilder class.

Input: Hello world
Output: World Hello

8. Swap two number: Write a program to swap the two numbers using the substring method.

Input: 10 20
Output: 20 10

9. Chek prime number: Write a program to check whether the given number is prime or not

Input: 7
Output: prime

10. Check leap year: Write a program to check whether the year is leap or not.

Input: 2020
Output: Leap

Congrats! You made it. Thank you!