Professional Documents
Culture Documents
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.
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;
@Test
public void testAddition() {
// Arrange: Create an instance of the Calculator
Calculator calculator = new Calculator();
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.
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:
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).
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.
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);
}
}
import java.util.*;
class Main
int arr[] = {10, 20, 20, 30, 40, 40, 40, 50, 50};
4
int n = arr.length;
hash_Set.add(arr[i]);
System.out.print(hash_Set);
Arrays.sort(charArray1);
Arrays.sort(charArray2);
// Example usage
if (areAnagrams(string1, string2)) {
} else {
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