Automation Tester Questions Set #1 2024
Automation Tester Questions Set #1 2024
y
result.append(current);
m
}
}
return result.toString();
de
}
}
ca
String input = "hello";
System.out.println(removeDuplicates(input)); // Output: helo
gA
}
### Program Remove the second highest element from the HashMap.
tin
import java.util.*;
map.put(2, "Two");
map.put(3, "Three");
Th
if (list.size() > 1) {
System.out.println("Second highest element: " + list.get(1));
} else {
System.out.println("HashMap doesn't have a second highest element.");
}
}
}
### Java program to Generate prime numbers between 1 & given 4 number
y
}
m
}
de
if (num <= 1) return false;
for (int i = 2; i <= Math.sqrt(num); i++) {
if (num % i == 0) return false;
}
} ca
return true;
gA
}
int n = array.length + 1;
int totalSum = n * (n + 1) / 2;
int arraySum = 0;
eT
### Java program to input name, middle name and surname of a person and print
only the initials.
import java.util.Scanner;
y
m
### Program to Print all TreeMap elements?
import java.util.*;
de
public class PrintTreeMapElements {
public static void main(String[] args) {
ca
TreeMap<Integer, String> treeMap = new TreeMap<>();
treeMap.put(1, "One");
treeMap.put(2, "Two");
gA
treeMap.put(3, "Three");
}
}
}
es
### What is a singleton Design Pattern? How do you implement that in your
framework?
eT
Singleton pattern ensures that a class has only one instance and provides a global
point of access to that instance.
Th
private Singleton() {}
y
### What is serialization and deserialization?
m
Serialization is the process of converting an object into a stream of bytes to store it in
memory, a file, or to transmit it over a network. Deserialization is the process of
reconstructing the object from the serialized form.
de
### What is the Difference between status codes 401 and 402?
- 401 Unauthorized: It indicates that the request has not been applied because it lacks valid
ca
authentication credentials for the target resource.
- 402 Payment Required: This status code is reserved for future use and is intended to be
used when the functionality it represents is implemented.
gA
### Difference between selenium 3 and selenium 4?
Selenium 4 introduced several new features and improvements over Selenium 3, including:
- Native support for Chrome DevTools Protocol.
tin
### What is delegate in Java and where do you use Delegate in your Framework?
In Java, there is no direct equivalent to delegates in languages like C#. However, a similar
eT
Example:
### How many maximum thread-pool can you open in the TestNG?
The maximum number of threads in a TestNG thread pool is determined by the parameter
y
`thread-count` in the testng.xml file or programmatically through the TestNG API. It depends
m
on the hardware resources available and the nature of tests being executed.
### What are the Major challenges that come into the picture when you do parallel
de
testing using TestNG and Grid?
Some major challenges of parallel testing using TestNG and Grid include:
- Synchronization issues: Ensuring proper synchronization between tests running
ca
concurrently.
- Resource contention: Managing shared resources such as database connections or files.
- Test data isolation: Preventing interference between tests that manipulate common data.
gA
- Logging and reporting: Consolidating logs and reports from parallel executions for easy
analysis.
- Scalability: Ensuring the testing infrastructure can scale efficiently as the number of parallel
executions increases.
tin
### How do you integrate your automation framework with the Jenkins pipeline?
Integration with Jenkins pipeline involves creating Jenkinsfile and configuring Jenkins to
execute the pipeline. Steps include:
es
1. Define stages: Define stages such as build, test, and deploy in the Jenkinsfile.
2. Configure build steps: Specify commands to build and execute tests in each stage.
3. Add post-build actions: Include actions like archiving artifacts and triggering downstream
eT
jobs.
4. Configure Jenkins job: Create a Jenkins job and link it to the repository containing the
Jenkinsfile.
Th
5. Run pipeline: Execute the pipeline to build, test, and deploy the application.
Example Jenkinsfile:
groovy
pipeline {
agent any
stages {
stage('Build') {
steps {
// Build commands
}
}
stage('Test') {
steps {
// Test execution commands
}
}
stage('Deploy') {
steps {
// Deployment commands
}
}
}
}
y
m
de
### What will happen if we remove the main method from the Java program?
If you remove the `main` method from a Java program, the program won't have an entry
point, and it won't be executable as a standalone application. You'll encounter a compilation
ca
error indicating that the main method is not found. The `main` method serves as the starting
point for execution in Java applications.
gA
### What is the component of your current Project?
The components of my current project include:
- User interface (UI) layer: Responsible for user interaction and presentation.
- Business logic layer: Contains the core business rules and processing logic.
tin
- Logging and monitoring: Tracks application behavior and performance for analysis and
troubleshooting.
eT
Example:
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
testng.xml:
xml
<suite name="Test Suite">
<test name="Parameterized Test">
<parameter name="browser" value="Chrome"/>
<classes>
<class name="ParameterizedTest"/>
</classes>
</test>
y
</suite>
m
### Write the logic of retrying the failed test case with a minimum of 3 numbers of
de
times in Automation Testing. Which Interface do you use for it?
You can implement retry logic using the `IRetryAnalyzer` interface provided by TestNG.
Example: ca
import org.testng.IRetryAnalyzer;
gA
import org.testng.ITestResult;
@Override
public boolean retry(ITestResult result) {
es
}
return false;
}
Th
Usage:
import org.testng.annotations.Test;
1. Encapsulation: Bundling of data and methods that operate on the data into a single unit
(class).
2. Inheritance: Mechanism by which one class can inherit properties and behavior from
y
another class.
m
3. Polymorphism: Ability of objects to take on multiple forms based on their context.
4. Abstraction: Process of hiding the implementation details and showing only the essential
features of an object.
de
5. Class: Blueprint for creating objects, which defines its properties and behaviors.
6. Object: Instance of a class that encapsulates data and methods.
7. Method: Function defined within a class to perform certain actions.
ca
### Difference Between Classes and Objects?
- Class: A class is a blueprint or template for creating objects. It defines the properties and
gA
behaviors common to all objects of that type.
- Object: An object is an instance of a class. It represents a specific entity in memory and
has its own set of properties and behaviors.
tin
Class.forName("ClassName").newInstance();`
3. Using clone() method: `ClassName obj2 = (ClassName) obj1.clone();` (Requires
implementing Cloneable interface)
4. Using deserialization: Read object from file or stream using ObjectInputStream.
5. Using factory method: Define static factory methods within the class to create objects.
6. Using dependency injection frameworks: Let frameworks like Spring manage object
creation and injection.
y
m
de
ca
gA
tin
es
eT
Th