Top Java coding interview questions for SDET

Hi all, I’m working as an instructor at Tech Lead Academy. We teach programming for Software Development Engineer in Test(SDET) position. I have gathered the most asked interview coding questions from my own interview experience and from 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.

1. String reverse. Write a method that will take one string as an argument and will 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. String palindrome. A palindrome is a word, phrase, number, or sequence of words that reads the same backward as forward.

5. Number palindrome. A palindrome is a word, phrase, number, or sequence of words that reads the same backward as forward. The straight forward solution would be to convert number to string and use the above approach. Some interviewers will not allow it. So let’s take a look at what we can do here.

6. 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.

7. Find the second min/max number from an array. Write a method that accepts int array as an argument and returns second or n min/max number from the given array.

8. 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 output from this program? Why this output?

9. String Pool and == operator to compare references in Java. Let’s see an example, what’s output from this program? Why this output?

10. Swap values of two variables without direct reassignment and without creating any extra variables.

11. 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.

12. 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.

13. Count letters(Map). Write a method that accepts a string as an argument. The method counts the number of appearances of each char and return map. The key will be a letter and the value will be a number of appearances in the string. See input and output in the example.

14. 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

15. 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.

16. Sum of two. Write a method that accepts int[] array and an int number, 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.

17. 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.

18. Balanced String. This question became very popular lately. The program should find out if an input string is balanced or not.

19. 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 smallest and swapped with current array and we will keep doing it for each element. Please watch this video for 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 correct order. Please watch this video for visual explanation.

Congrats! You made it. It was a long list. Thank you!

--

--

--

Software Developer, Java Instructor https://www.techleadacademy.io/

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Space Robots —  upcoming stuff

SpritSwaps fNFT’s; A TLDR on the what, why, where, when and how !

How I Successfully Changed Careers to Software Engineering with a Coding Bootcamp

The State of IoT Asset Tracking

Three Tricks on Python Functions that You Should Know

Exploring the new String API in Swift 4

Building A Car Rental Booking Software: a comprehensive guide

Fade in your UIs in Flutter

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Beknazar

Beknazar

Software Developer, Java Instructor https://www.techleadacademy.io/

More from Medium

Java Collections: Under the hood — LinkedList E03

Abstract Modifier in Java

String Immutability in Java

Java Interview Common Basic Question