Epam Interview Questions: Part 1
Introduction
Preparing for an EPAM interview? In this blog post, we’ll break down some of the most common EPAM interview questions—covering everything from explaining your automation framework to solving real-world coding challenges. Whether you’re a seasoned automation engineer or just starting your journey, these insights will help you showcase your technical know-how and problem-solving skills. Let’s dive in and get you ready to impress!
Q1) What framework you are using and explain that:
Framework Overview
1. Hybrid Framework:
- Design Pattern: Built on the Page Object Model (POM) design pattern.
- Dependency Management: Utilizes Maven for managing project dependencies.
2. External Libraries
- Selenium WebDriver: Used to interact with web applications.
- TestNG: Facilitates controlled test execution.
- Apache POI: Supports data-driven testing (e.g., reading data from Excel).
- Cucumber: Enables BDD (Behavior Driven Development) automation.
- Extent Report: Generates HTML summary reports for test results.
Framework Components
1. Browser (Interface) – Defines methods for browser-related interactions.
2. Element (Interface) – Defines methods for element-related interactions.
3. Selenium Base
- Implementation: Implements both the Browser and Element interfaces.
- Reusable Methods: Acts as a library containing reusable automation methods.
- Wrapper Class: Contains wrapper methods that simplify Selenium commands.
- Exception Handling: Implements exception handling using try/catch blocks across all methods.
4. ProjectSpecificMethods
- Base Class: Serves as the base for all page classes and test case classes.
- Common Utilities: Contains common methods and variables shared across pages and test cases.
5. Pages
- Contains Java classes for each individual page in the application.
6. TestCases
- Contains Java classes for each test case.
7. Utils
- DataLibrary: Handles reading data from Excel files.
- Reporter: Contains configurations and methods for ExtentReport.
Hierarchy of classes:
Execution flow:
Q2) Write a program declare array with 10 int num and remove the 3rd index element and print the updated array?
Program:
public class RemoveElement {
public static void main(String[] args) {
// Declare and initialize an array with 10 integers
int[] arr = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100};// The index to remove (3rd index = 4th element)
int removeIndex = 3;// Shift elements to the left starting from the removeIndex
for (int i = removeIndex; i < arr.length – 1; i++) {
arr[i] = arr[i + 1];
}// Create a new array with one less element
int[] newArr = new int[arr.length – 1];
for (int i = 0; i < newArr.length; i++) {
newArr[i] = arr[i];
}// Print the updated array
System.out.println(“Updated array:”);
for (int num : newArr) {
System.out.print(num + ” “);
}
}
}
Output:
Updated array:
10 20 30 50 60 70 80 90 100
Explanation:
- Array Declaration:
An array arr is declared with 10 integers. - Element Removal:
We choose the 3rd index (which corresponds to the 4th element) as the removal target.
A loop shifts each element after this index one position to the left. - New Array Creation:
Since the array size is fixed, we create a new array newArr that is one element shorter and copy the shifted values into it. - Printing:
Finally, we print the elements of newArr, which represents the updated array after removing the element at index 3.
Q3: Write a program, declare a string and find the occurrences of each and every string
Program:
public class OccuranceOfEachCharacter {
public static void main(String[] args) {
String str = “welcome to testleaf”;
int count = 0;
for (int j = 0; j < str.length(); j++) {
count = 0;
char c = str.charAt(j);
for (int i = 0; i < str.length(); i++) {
if (c == str.charAt(i)) {
count++;
}
}
System.out.println(c + occurs + count + 11 11 11 times in 11 + str);
}
}
}
Output:
w occurs 1 times in welcome to testleaf
e occurs 4 times in welcome to testleaf
1 occurs 2 times in welcome to testleaf
coccurs 1 times in welcome to testleaf
o occurs 2 times in welcome to testleaf
moccurs 1 times in welcome to testleaf
e occurs 4 times in welcome to testleaf
occurs 2 times in welcome to testleaf
t occurs 3 times in welcome to testleaf
o occurs 2 times in welcome to testleaf
occurs 2 times in welcome to testleaf
t occurs 3 times in welcome to testleaf
e occurs 4 times in welcome to testleaf
s occurs 1 times in welcome to testleaf
t occurs 3 times in welcome to testleaf
1 occurs 2 times in welcome to testleaf
e occurs 4 times in welcome to testleaf
occurs 1 times in welcome to testleaf
f occurs 1 times in welcome to testleaf
Explanation:
1) String Declaration:
The program starts by declaring a string.
This is the text in which the program will count the occurrence of each character.
2) Outer Loop:
The outer loop iterates over each character in the string using index j.
For every character at position j, it resets count to 0 and assigns that character to variable c.
3)Inner Loop:
The inner loop then goes through the entire string (using index i) to count how many times the current character c appears.
Every time the character at position i matches c, the count is incremented.
4) Printing the Result:
After counting, the program prints the character along with its count.
Related Articles: https://blog.testleaf.com/hexaware-java-interview-questions-and-answers-2025-top-faqs-to-crack-your-interview/
Q4) Write a program that generates and displays the Fibonacci sequence.
Program:
public class FibonacciSeries {
public static void main(String[] args) {
int n1=0,n2=1,n3, i, count=10;
//printing 0 and 1
System.out.println(n2);
//loop starts from 2 because 0 and 1 are already printed
for(i=2;i<count;++i)
{
n3=n1+n2;
System.out.println(n3);
n1=n2;
n2=n3;
}
}
}
Output:
1
1
2
3
5
8
13
21
34
1) Initialization:
n1 = 0, n2 = 1 — starting values of the Fibonacci sequence.
count = 10 — total number of iterations.
2) Process:
First, the program prints n2 (which is 1).
Then, in a loop (from i = 2 to i < count), it calculates the next Fibonacci number (n3) as n1 + n2, prints it, and updates n1 and n2 for the next iteration.
Q5) What is the difference between .equals and == in Java?
Explanation:
1. == Operator:
What it does: Compares object references (memory addresses).
For Strings: Returns true only if both references point to the exact same object in memory.
2. equals() Method:
What it does: Compares the contents of two objects.
For Strings: Returns true if the sequences of characters in the strings are identical, regardless of whether they are the same object.
Q6) What will be the output of comparing s1 and s2 using the .equals() method and the == operator?
String s1 = “hello”; String s2 = “hello”;
String s1 = new String(“Hello”);
String s2 = new String(“Hello”);
System.out.println(s1 == s2);
// Outputs false (different objects)
System.out.println(s1.equals(s2));
// Outputs true (same content)
- s1.equals (s2) will return true because the content of both strings is the same (“hello”).
2) s1 == s2 will also return true because both s1 and s2 refer to the same literal in the string pool
Q7) What is an Interface and an Abstract Class in Java? Briefly explain the differences between them
1. Interface
Interfaces are design structures that direct what a class must do. It is placeholder for all abstract methods, and it can also support concrete methods from 1.7 version with default to allow backward compatibility. In our project, we always start with interface so that everyone follows the common standards for developing methods and variables by which we can avoid ambiguity.
- a) Java example: List, Set
- b) Selenium example: SearchContext, WebDriver
2. Abstract Class
Contains both implemented and unimplemented (abstract) methods. Used to partially implement the interface.
- a) Java example: AbstractList
- b) Selenium example: By class
Difference between Interface and Abstract Class in Java:
Feature | Interface | Abstract Class |
---|---|---|
Method Type | Only abstract methods (default/static methods allowed from Java 8) | Can have both abstract and concrete methods |
Fields | public static final (constants) |
Can have instance variables (any access modifier) |
Inheritance | A class can implement multiple interfaces (supports multiple inheritance) | A class can extend only one abstract class |
Constructors | Cannot have constructors | Can have constructors |
Access Modifiers | Methods are public by default |
Methods can have any access modifier |
Usage | Defines a contract for implementation (behavior-focused) | Used for code reuse and providing common behavior (blueprint-focused) |
Q8) What are the core Object-Oriented Programming (OOP) concepts in Java?
1) Encapsulation:
Definition: Bundles data (variables) and methods (functions) together within a class, restricting direct access to some of the object’s components.
Purpose: Enhances security and modularity by hiding internal implementation details using access modifiers (private, protected, public).
2) Inheritance:
Definition: Allows one class (subclass) to inherit fields and methods from another class (superclass).
Purpose: Promotes code reusability and establishes a hierarchical relationship between classes.
3) Polymorphism:
Definition: Enables a single entity (method or object) to take on many forms.
Purpose: Allows methods to perform differently based on the object calling them (method overloading and overriding), leading to more flexible and maintainable code.
4) Abstraction:
Definition: Abstraction is one of the OOPs concepts to hide certain details and show only essential information to the user.
Purpose: Simplifies interaction with objects through abstract classes and interfaces, focusing on what an object does rather than how it does it.
Q9) What is polymorphism and give examples from your automation?
Polymorphism is Object oriented concept where single action can be transformed into multiple forms
Types: Overloading (compile-time) and Overriding (run-time)
1) Overloading:
- Same method name with different arguments
- Purpose: simplify verbose
- Java examples: subString(int) // only start index and subString(int, int) // start and end
- Selenium examples: switchTo().frame
- Framework examples: locateElement(String) -> default by xpath, locateElement(String, String) -> by any locator
2) Overriding:
- Override the super class method behavior at sub class level
- Purpose: when like override the functionality
- Java examples: equals method in String class overrides the Object class
- Selenium examples: quit method in ChromiumDriver overrides the quit method in RWD
- Framework examples: BeforeMethod in registration testcase override the BeforeMethod at hooks level (default: login).
You Might Also Like: https://blog.testleaf.com/2025-top-automation-testing-infosys-interview-questions-with-expert-answers-from-testleaf-for-2-to-5-years-experience/
Q10) Can we override a private method in Java? Why or why not?
No, we cannot override a private method in Java.
Reason:
- Visibility: Private methods are not visible to any subclasses. Since they are not inherited, a subclass cannot override them.
- Method Shadowing: If a subclass defines a method with the same signature as a private method in the superclass, it’s not overriding—it’s simply creating a new method that exists independently in the subclass.
Thus, overriding is only applicable to methods that are inherited (i.e., those with public, protected, or default access within the same package).
Q11) Can we override a static variable in Java?
No, we cannot override a static variable in Java.
Explanation:
- Static Variables Belong to the Class:
Static variables are associated with the class itself, not with instances of the class. They are resolved at compile time based on the reference type. - Overriding vs. Hiding:
Overriding applies to instance methods where a subclass provides a new implementation for an inherited method. With static variables, if you declare a variable with the same name in a subclass, it does not override the parent variable; instead, it hides it. This is known as variable shadowing.
Example:
class Parent {
static int x = 10;
}
class child extends Parent {
// This is not overriding; it’s hiding the static variable from Parent
static int x = 20;
public class Test {
public static void main(String[] args) {
System.out.println(Parent.x); // outputs: 10
System.out.println(Child.x); // Outputs: 20
}
}
In this example, Child.x hides Parent.x, but the original Parent.x remains unchanged. This is why we say that static variables cannot be overridden.
Q12) Can we declare a class as final in Java?
Yes, we can declare a class as final in Java.
Explanation:
- Final Class: When a class is declared as final, it cannot be subclassed (extended). This means no other class can inherit from it.
- Purpose: This is used to prevent modification of the class’s behavior, which can be important for security, design stability, or performance reasons.
- Example: The String class in Java is a well-known final class.
final class MyFinalClass {
// class members and methods
}
// The following code would result in a compilation error
// class Subclass extends MyFinalClass {}
Q13) What is the difference between an Array and an ArrayList in Java?
Array:
- Fixed Size: The size of an array is determined at the time of creation and cannot be changed.
- Type: Can store both primitive data types (e.g., int, char) and objects.
- Performance: Faster access to elements; less overhead.
- Syntax: Built into the language and uses special syntax.
ArrayList:
- Dynamic Size: The size of an ArrayList can grow or shrink dynamically as elements are added or removed.
- Type: Can only store objects (primitive types must be wrapped, e.g., Integer for int).
- Methods: Comes with convenient methods like add(), remove(), and contains().
- Part of Collections: It is part of the Java Collections Framework, offering many utility methods for handling collections.
Q14) What is a HashMap in Java, and how does it work?
A HashMap in Java is a part of the Java Collections Framework that implements the Map interface. It stores data in key-value pairs and provides fast retrieval based on the key.
Key Points:
- Structure: HashMap uses a hash table to store the data, where each key’s hash code determines its bucket location.
- Key-Value Storage: Data is stored as key-value pairs. Keys must be unique, while values can be duplicated.
- Null Values: It allows one null key and multiple null values.
- Performance: Offers constant-time performance for basic operations (like get and put) under typical conditions.
- Order: It does not guarantee any specific order of elements.
- Thread Safety: HashMap is not synchronized. For thread-safe operations, you can use Collections.synchronizedMap() or ConcurrentHashMap.
Program:
import java.util.HashMap;
import java.util.Map;
public class HashMapExample {
public static void main(String[] args) {
// Create a HashMap
Map<String, Integer> map = new HashMap<>();
// Add key-value pairs to the map
map.put(“Apple”, 3);
map.put(“Banana”, 5);
map.put(“Orange”, 2);
map.put(null, 10); // ALLowed: one null key
// Retrieve a value
System.out.println(“Number of Bananas: + map.get(“Banana”));
// Iterate over the map
for (Map. Entry<String, Integer> entry: map.entrySet()) {
System.out.println(entry.getKey()+”->” + entry.getValue());
}
}
Output Example:
Number of Bananas: 5
Apple ->3
Banana ->5
Orange ->2
null -> 10
Don’t Miss Out: https://blog.testleaf.com/capgemini-interview-guide-questions-and-tips-to-ace-interview/
Q15) What are the differences between an ArrayList and a LinkedList in Java?
Feature | ArrayList | LinkedList |
Data Structure | Uses a dynamic array to store elements. | Uses a doubly-linked list where each element is a node with pointers to the next and previous nodes. |
Random Access | Fast random access (O(1)) because elements are indexed. | Slow random access (O(n)) since traversal is required from the beginning or end. |
Insertion/Deletion | Slower for middle insertions or deletions due to shifting of elements (O(n)). | Faster for insertions/deletions at any position (O(1)) if the node reference is known. |
Memory Overhead | Lower memory overhead as it stores only the element data. | Higher memory overhead because each node stores additional pointers (prev and next). |
Real-Time Example | Ideal for storing a list of products in an e-commerce app where you frequently read data but rarely modify it. | Perfect for managing a task scheduler or event queue in a chat application where tasks are frequently added or removed. |
Q16) What is the difference between a Set and a List in Java?
Feature | Set | List |
Duplicates | Does not allow duplicate elements. | Allows duplicate elements. |
Ordering | No guaranteed order (unless using LinkedHashSet or TreeSet). | Maintains insertion order (elements are stored sequentially). |
Index Access | No index-based access (cannot retrieve by position). | Supports index-based access (can retrieve elements by index). |
Use Cases | Useful when uniqueness is required (e.g., storing unique user IDs). | Useful when order matters or duplicates are acceptable (e.g., a playlist). |
Performance | Typically offers faster search operations for unique elements. | Better for scenarios where order-based access is needed. |
Real-Time Example | A system that stores unique email addresses. | An e-commerce application’s shopping cart that may contain multiple instances of the same product. |
Q17) What are the commonly used classes that implement the List and Set interfaces in Java?
List:
- ArrayList: Dynamic array with fast random access.
- LinkedList: Doubly-linked list, efficient for insertions and deletions.
- Vector: Legacy, synchronized version of ArrayList.
- Stack: A subclass of Vector that implements a LIFO stack.
Set:
- HashSet: Unordered collection that stores unique elements using a hash table.
- LinkedHashSet: Maintains insertion order.
- TreeSet: Stores elements in sorted order (implements SortedSet).
Q18) What are the return types of getWindowHandle() and getWindowHandles() in Selenium WebDriver, and what do they represent?
getWindowHandle():
Return Type: String
Represents: The unique identifier (handle) of the current window.
Usage Example:
String currentwindow = driver.getwindowHandle();
getWindowHandles():
Return Type: Set<String>
Represents: A set of unique identifiers (handles) for all open windows or tabs.
Usage Example:
Set<String> allwindows = driver.getWindowHandles();
getWindowHandle() returns a single String for the current window, while getWindowHandles() returns a Set of String values representing all open windows, allowing you to iterate and switch between them.
Continue Reading: https://blog.testleaf.com/selenium-accenture-interview-questions/
Q19) x-path axes/ what is following and following sibling
In XPath, axes help you navigate through an XML document relative to the context node. Two commonly used axes are following and following-sibling.
Following Axis:
Definition:
The following axis selects all nodes in the document that occur after the current node, in document order, regardless of their depth or hierarchical level. It includes not only siblings but also nodes that are deeper in the document structure, if they appear after the closing tag of the current node.
Example:
Consider the following XML:
<root>
<a>First</a>
<b>Second</b>
<C>
<d>Third</d>
</c>
</root>
If your context node is <a>, then the expression following::node() would select <b>, <c>, and <d> because all these nodes appear after <a> in document order.
Following-Sibling Axis:
Definition:
The following-sibling axis selects only those nodes that share the same parent as the current node and appear after it. It does not traverse into the descendants of these siblings.
Example:
Using the same XML as above, if your context node is <a>, the expression following-sibling::* would select <b> and <c>, but not <d> because <d> is a child of <c>, not a sibling of <a>.
What’s Next?
We’ve covered 19 important questions in this blog post, but there’s more to explore! Stay tuned for Part 2, where we’ll dive into 19 more essential questions to further enhance your knowledge.
Author’s Bio:
As CEO of TestLeaf, I’m dedicated to transforming software testing by empowering individuals with real-world skills and advanced technology. With 24+ years in software engineering, I lead our mission to shape local talent into global software professionals. Join us in redefining the future of test engineering and making a lasting impact in the tech world.
Babu Manickam
CEO – Testleaf