Real Time Test Automation Interview Questions

1. What is the final keyword in Java?. Can we apply it to class and methods?

  • Final keyword is a non access modifier used for classes, attributes and methods
  • Whenever a variable is declared final, it’s value cannot be changed which means it is a constant
  • When a class is declared final, it cannot be inherited
  • When a method is declared final, it cannot be overridden by a derived class

2. What is static keyword in Java?. Why it is used?

  • Static keyword is a non-access modifier which can be used with blocks, variables, methods and nested classes
  • Static member is shared across all instances of the class
  • Static methods belong to a class instead of the object, they can be called without creating the object of the class
  • Static keyword is mainly used for memory management
  • Static variables gets memory only once in the class area when it is loaded

3. What is an interface and when do we use it?

  • Interface is an abstract type that is used to specify a behavior that classes must implement
  • Interfaces are used to achieve complete abstraction
  • Interfaces contains abstract methods which have no implementation
  • Interfaces can be used to achieve multiple inheritance in Java
  • Variables in interface are final, static and public
  • Interfaces cannot be instantiated
  • Interfaces can be implemented using “implements”

4. What is an abstract class and why do we use it?

  • Abstract class can have both abstract and non abstract methods
  • Abstract class cannot be instantiated
  • Abstract class can have constructors and static methods
  • Abstract class can be extended using “extends”
  • Abstract class is used when we want to share code among several closely related classes
  • Abstract class doesn’t support multiple inheritance

5. Write a Java program to filter out duplicate values in a list

public class FilterDuplicateValuesInList {

    public static void main(String[] args) {

        List<String> values = new ArrayList<>();

        Set<String> removeDuplicates = new HashSet<>();

        for(String s: removeDuplicates){


6. What is an Automation Framework?

  • Framework is a set of rules or best practices which must be followed to deliver consistent results
  • Automation Framework is a collection of tools and practices that are designed to make the testing process more efficient
  • Guidelines could include coding standards, test data handling methods, object repositories, handling different application configurations, storing test results, accessing external resources
  • Automation Frameworks helps increase speed and efficiency, reduce maintenance costs, improve test accuracy, lower risks, maximize test coverage and increase reusability of code

7. Explain the different features of your Automation Framework

  • Our Automation Framework is built on Selenium WebDriver API with Cucumber and Java
  • We have used BDD Framework to write our feature files using the Gherkin language which increases collaboration across the team
  • We have used Page Object Model to maintain our different test objects across different page classes which increases code reusability and makes it easier to maintain
  • We have used Maven to build and maintain all our project dependencies and plugins
  • We have used reusable functions for common operations and application specific functionalities
  • We have used external data sources like excel, database to store our test data
  • We have used different reporting plugins and custom libraries to generate extensive reports in  various formats like HTML, XML, JSON, Excel
  • We have used standard naming conventions to write our class, functions or variable names. We have also provided detailed comments and documentation for each class and function

8. How do you handle different test environments within your Automation Framework?. Write sample code

  • We store all the environment related configurations in properties files
  • Used Properties class and its methods to retrieve different values
public class ReadPropertiesFile {

    public static void main(String[] args) {

        File file = new File("src/resources/");
        try {
            FileInputStream fis = new FileInputStream(file);
            Properties props = new Properties();
            String devUrl = props.getProperty("dev.url");
            String stagingUrl = props.getProperty("staging.url");
            System.out.println("Application DEV URL is: " + devUrl);
            System.out.println("Application Staging URL is: " + stagingUrl);
        } catch (FileNotFoundException e) {
        } catch (IOException e) {

9. What are the different design patterns in Java?. Give an example of a design pattern used in your Automation Framework

Some of the design patterns are:

  • Factory Pattern
  • Singleton Pattern
  • Prototype Pattern
  • Builder Pattern

We have used the Singleton design pattern to initialize the browser driver. This is to make sure only one driver instance exists at all times. Singleton class contains a private constructor and a static method that has return type object of the singleton class.

public class SingletonClass {

    private static SingletonClass instance = null;

    private SingletonClass(){

    public static SingletonClass getInstance(){
            instance=new SingletonClass();
        return instance;

10. How have you implemented Abstraction in your Automation Framework?

  • We have implemented Abstraction using the Page Object Model and reusable methods
  • We have defined all our page objects and their methods inside different page classes
  • In this way the actual tests are completely abstracted from their implementation as they only contain calls to different methods



Bijan Patel

Founder & Creator of QAScript | 12+ years of IT Experience | Full Stack Automation Engineer | Blogger | Trainer

You may also like...

Leave a Reply

Your email address will not be published.