Hi all, I’m working as an instructor at a coding boot camp. We teach programming for the Software Development Engineer in Test(SDET) position. I have gathered the most asked interview coding questions from my own interview experience and our student's interviews. I’m sure if you work through these coding questions, you can nail most of the coding interview questions for SDET. For Big O notation time complexity, please read this article.
If you prefer video sessions, please consider taking my Udemy course Interview Preparation for SDET(Java). It includes all these coding challenges and a lot more to prepare for the interviews.
1. String reverse. Write a method that will take one string as an argument and return the reverse version of this string.
2. Array reverse. Write a method that will take an array as an argument and reverse it.
3. Reverse words. Write a method that will take a string as an argument. The method will reverse the position of words and return it.
4. Prime number. A prime number is a number that can only be divided by itself and 1 without remainder.
5. String palindrome. A palindrome is a word, phrase, number, or sequence of words that reads the same backward as forward.
6. Number palindrome. A palindrome is a word, phrase, number, or sequence of words that reads the same backward as forward. The straightforward solution would be to convert the number to a string and use the above approach. Some interviewers will not allow it. So let’s take a look at what we can do here.
7. Max/min number from an array. Write a method that will accept an array of int as an argument and it returns the max/min number from a given array.
8. Find the second min/max number from an array. Write a method that accepts an int array as an argument and returns a second or n min/max number from the given array.
9. Static keyword in Java. The static keyword is a very popular question in the interviews.
What’s a static keyword in Java?
- Static variables and methods belong to the class, not to a specific object. We need to use static members by class name.
Let’s see an example. What’s the output of this program? Why this output?
10. String Pool and == operator to compare references in Java. Let’s see an example. What’s the output of this program? Why this output?
11. Swap values of two variables without direct reassignment and without creating any extra variables.
12. Two-string anagram. An anagram is when all the letters in one string exist in another but the order of letters does not matter. Write a method that accepts two string arguments and returns true if they are anagram and false if they are not.
13. Remove duplicates from a string. Write a method that accepts one string argument and returns it without duplicates. We will see two versions of this method.
14. Count letters(Map). Write a method that accepts a string as an argument. The method counts the number of appearances of each char and returns a map. The key will be a letter and the value will be the number of appearances in the string. See the input and output in the example.
15. FizzBuzz. Print numbers from 1 to 100
- If a number is divisible by 3 print Fizz
- If a number is divisible by 5 print Buzz
- If a number is divisible by both 3 and 5 print FizzBuzz
16. Even or Odd. Write a method that will accept one int as an argument. The method prints Even if the number is even and Odd if the number is odd.
17. Sum of two. Write a method that accepts an int[] array and an int number, and find 2 elements in the array that sum is equal to the given int. Assume that an input array will have only one pair of numbers that sum equal to our given number. It will always have this pair. See input and output examples. I use the Brute Force algorithm.
18. The Fibonacci. It is a series of numbers where the next number is the sum of the previous two numbers. The first two numbers of the Fibonacci is 0 followed by 1. Write a method that will accept one int number n. The method will print n number of Fibonacci numbers.
19. Balanced String. This question has become very popular lately. The program should find out if an input string is balanced or not.
20. Sort array without built-in sort methods. In this example, we will use selection sort and bubble sort algorithms to sort our array.
In selection sort, we select the smallest and swap it with the current array and we will keep doing it for each element. Please watch this video for a visual explanation.
In bubble sort, we bubble out the biggest values to the right side by looping over our array and switching two pairs of elements if they are not in the correct order. Please watch this video for a visual explanation.
Congrats! You made it. It was a long list. Thank you!
This article is part of a series of articles to prepare for the interview for SDET or Test Automation roles. Next, you can read these articles:
Top Theoretical Java Interview Questions for SDET
Top Java Coding Interview Questions for SDET
Top QA Interview Questions for SDET
Top Selenium Interview Questions for SDET
Top Cucumber Interview Questions for SDET
Top JUnit/TestNG Interview Questions for SDET
Top Maven Interview Questions for SDET
Top Framework Interview Questions for SDET
SDLC & Agile Interview Questions for SDET
Top API Interview Questions for SDET
Top Git Interview Questions for SDET
Thank you for your attention. Please consider taking my online courses: