You are on page 1of 6

For Software Development Engineer in Test (SDET) positions with 3-5 years of

experience in Java, interview questions often cover a combination of coding,


testing concepts, and problem-solving skills.

1. Test Automation and Coding Skills:


- Implement a function to reverse a string.
- Write a program to find the factorial of a number.
- Create a program to check if a given string is a palindrome.
- Implement a function to remove duplicates from an array or list.
- Write a program to find the Fibonacci number.
- Create a function to check if two strings are anagrams.

2. Data Structures and Algorithms:


- Implement a binary search algorithm.
- Solve a problem using breadth-first search (BFS) or depth-first search (DFS).
- Implement a stack or a queue using arrays or linked lists.
- Write a function to detect a cycle in a linked list.

3. Java-specific Questions:
- Explain the difference between `==` and `.equals()` in Java.
- Describe the concept of garbage collection in Java.
- Discuss the difference between abstract classes and interfaces.
- Implement a custom exception in Java.
- Explain the use of the `static` keyword in Java.

4. Test Automation Frameworks:


- Discuss the advantages and disadvantages of different test automation frameworks (e.g., JUnit,
TestNG).
JUnit:
Advantages:
Simplicity and ease of use.
Rich ecosystem.
Annotations for organizing tests.
Disadvantages:
Limited parallel execution support.
Less flexible parameterization.

1
TestNG:
Advantages:
Flexible test configuration.
Parameterization support.
Test dependency management.
Data-driven testing.
Disadvantages:
Steeper learning curve.
Potential integration challenges.
Smaller community size compared to JUnit.

import org.testng.Assert;
import org.testng.annotations.Test;

public class CalculatorTest {

@Test
public void testAddition() {
// Arrange: Create an instance of the Calculator
Calculator calculator = new Calculator();

// Act: Perform the addition operation


int result = calculator.add(3, 5);

// Assert: Verify that the result is as expected


Assert.assertEquals(result, 8);
}
}

2
- Explain the concept of Page Object Model (POM) and how it is used in test automation.
The Page Object Model (POM) is a design pattern in test automation where web pages are
represented as classes, each containing elements and methods to interact with the page. This
enhances code maintainability, readability, and reusability by providing a clear separation between
test code and page-specific details.

- Discuss strategies for handling dynamic elements in automated tests.


Wait Strategies:

Use implicit and explicit waits to allow dynamic elements to load before interacting with them.
Dynamic Locators:

Employ flexible locators (XPath, CSS) based on attributes or surrounding elements to adapt to
changes.
Stale Element Reference Handling:

Catch and handle StaleElementReferenceException by refreshing the reference to the element if it


becomes stale.

- Describe how you handle synchronization issues in test automation.

To handle synchronization issues in test automation:

Wait Strategies:
Use implicit or explicit waits to ensure that the automation script waits for elements to
be present, visible, or interactive before interacting with them.

3
5. Behavior-Driven Development (BDD):
- Explain the principles of BDD and its benefits.
- Write a simple scenario using Gherkin syntax.
- Discuss the integration of BDD with a testing framework (e.g., Cucumber with Java).

6. Concurrency and Multithreading:


- Implement a simple program using multithreading in Java.
- Discuss the challenges and solutions related to parallel test execution.

7. Web Technologies:
- Write a Selenium WebDriver script to perform a basic interaction with a web page.
- Explain the concept of XPath and how it is used in test automation.
- Discuss strategies for handling dynamic elements on a web page.

8. API Testing:
- Write a Java program to make a simple API request using a library like RestAssured.

-Implement a function to remove duplicates from an array or list.


In Java, import java.util.* is a wildcard import statement that allows you to import all classes and interfaces
from the java.util package. The java.util package is a collection of utility classes, data structures, and
other useful functionalities, including collections like List, Set, Map, and more.

import java.util.*;
class Main
{
public static void main (String[] args)
{
int arr[] = {10, 20, 20, 30, 40, 40, 40, 50, 50};
int n = arr.length;
Set<Integer> hash_Set = new HashSet<Integer>();
for (int i=0; i<n; i++)
hash_Set.add(arr[i]);

System.out.print(hash_Set);
}
}

Create a function to check if two strings are anagrams.

import java.util.*;

class Main

public static void main (String[] args)

int arr[] = {10, 20, 20, 30, 40, 40, 40, 50, 50};
4
int n = arr.length;

Set hash_Set = new HashSet();

for (int i=0; i<n; i++)

hash_Set.add(arr[i]);

System.out.print(hash_Set);

// Convert strings to char arrays and sort them

char[] charArray1 = str1.toCharArray();

char[] charArray2 = str2.toCharArray();

Arrays.sort(charArray1);

Arrays.sort(charArray2);

// Compare sorted char arrays

return Arrays.equals(charArray1, charArray2);

public static void main(String[] args) {

// Example usage

String string1 = "Listen";

String string2 = "Silent";

if (areAnagrams(string1, string2)) {

System.out.println(string1 + " and " + string2 + " are anagrams.");

} else {

System.out.println(string1 + " and " + string2 + " are not anagrams.");

Explanation:

 The areAnagrams function takes two strings as input and returns a boolean indicating whether they are anagrams.
 It removes spaces and converts both strings to lowercase to ensure case-insensitive comparison.
 It checks if the lengths of the strings are equal; if not, they cannot be anagrams.
 It converts the strings to character arrays, sorts them, and then compares the sorted arrays using Arrays.equals.
 The main method provides an example of how to use the areAnagrams function, comparing the strings "Listen" and "Silent".

5
------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------

SDET

1. Explain OOPS concept.


• 2. Explain OOPS concept in your Selenium project.
• 3. Which type of variables can we have in interface? Can we have non-static variables?
• 4. Can we have methods with body inside Interface?
• 5. Which version java are you using?
• 6. How to create read only classes?
• 7. Duplicate - return type of method - Method Overloading - Is it right?
• 8. How can you achieve Multiple Inheritance in Java?
• 9. What is Diamond problem?
• 10. Can we change value of static variables?
• 11. Usage of super and this keyword?
• 12. Program: String str="32400121200";
Output should be: 00003241212 (all zeroes should be in starting)
• 13. What is Exception handling? How to handle it?
• 14. What is Exception propagation?
• 15. Can we have try block without catch block?
• 16. Will finally block be always executed? Can I abort the program before running this finally?
17. Sysout statement after finally block? Will it get execute?
• ---------------
18. OAUth 1 vs OAuth2 - Difference
19. https / http - security? - Difference?
20. Design pattern in APItesting framework
21. Any idea about BDD Cucumber?
22. Log4J levels - default
23. Appenders - Types?
• ------------
24. git merge
25. git conflict
26. git fetch
27. Ever check what is inside this -> .git folder?
28. XPath Axes :

You might also like