Pages

Tuesday, 18 August 2020

Top 11 interview question on Java for SDET/Automation Testing/Experienced?











 
 
 
 
 
 
 
 
 
This is the first set of Java questions for SDET and Automation testing, will post more posts in following weeks so stay tuned and do subscribe for future posts.
 
                                        Automation Testing(java)-Set-05

41. What is Eager and Lazy Initialization of Singleton Class ?


42. What modifiers are accepted for Main class in Java?

Ans: public, abstract & final are permitted
 
43. Write code to reverse a string without using function?

Ans:
public class reverse {
    public static void main (String args[]) {
       
            String str = "automationreinvented";
            int n = str.length();
            String rev="";
            for (int i=n-1;i>=0;i--)
             rev = rev + str.charAt(i);
            System.out.println(rev);

          }
    }

44. How to do string manipulation in java?


45. Write a Java function which will return the maximum number in array?

Ans:
static int max()
    {
    int i;
    int max = findmaximum[0];
    for (i=1;i<findmaximum.length;i++)
   
        if (findmaximum[i] > max)
            max = findmaximum[i];
       
        return max;
    }

46. How to sort an Array using function?

Ans:
public class sortIntegerArray {
   
        public static void main(String[] args) {
            int[] arr={2,9,3,5,4,7,1,8,6};
            int temp;
            Arrays.sort(arr);
            for(int i=0;i<arr.length;i++)
            {
                System.out.println(arr[i]);
            }

        }
    }

47. How to Add/Join/Combine two arraylist?



48. How to convert List to array and array to list?

Ans: To convert List to Array:   list.toArray();
To convert Array to List:   Arrays.asList(Array);

49. How to get length of Array and List?

Length of array: array.length();
Size of list: list.size();

50. Difference between comparable and comparator in Java?

 
51. How to call a method in Java with and without object?
 

Want to learn more? ...Check below link for more java interview question:
 

*******************************************************************
For any doubts or career guidance, reach out to me 

****************************************

TOP 15 BDD - CUCUMBER Interview Q&A


************************************************

✍️AUTHORLinkedIn Profile

************************************************

Learn (API-Microservice)Testing+ Selenium UI Automation-SDET with Self Paced Videos prepared by FAANG employees and LIVE Doubt Session 

SDET TRANING VIDEOS AVAILABLE with Live Doubt Session(course-1 below,API TRaining Videos With Class Notes and Coding Set) and (API+UI, both course-1 & 2 below) Check Training Page for Course Content or reach out @whatsapp +91-9619094122. 
This includes classnotes, 300+ interview questions, 3 projects, Java Coding question set for product companies along with career guidance from FAANG employees for Automation and SDET.

For more details whatsapp : https://lnkd.in/dnBWDM33

*************************************************

SeleniumWebdriver Automation Testing Interview Questions:

https://automationreinvented.blogspot.com/search/label/SeleniumWebdriver

API Testing Interview Question Set:

https://automationreinvented.blogspot.com/2022/03/top-80-api-testing-interview-questions.html

DevOps Interview Q&A:

https://automationreinvented.blogspot.com/2021/11/top-11-devops-interview-questions-and.html 

Kubernetes Interview Question Set

https://automationreinvented.blogspot.com/search/label/Kubernetes

Docker Interview Question Set

https://automationreinvented.blogspot.com/Docker

Linux Interview question Set

https://automationreinvented.blogspot.com/search/label/Linux

Automation Testing/SDET Framework Design

https://automationreinvented.blogspot.com/search/label/FrameworkDesign

Java Related Interview Question Set

https://automationreinvented.blogspot.com/search/label/Java

GIT Interview Question Set:

https://automationreinvented.blogspot.com/2021/09/top-40-git-interview-questions-and.html

Coding Interview Question Set:

https://automationreinvented.blogspot.com/search/label/Coding%20Questions

Mobile Testing Interview Question Set:

https://automationreinvented.blogspot.com/search/label/Mobile%20Testing

Python Interview Question Set for QAE - SDET - SDE:

https://automationreinvented.blogspot.com/search/label/Python


 


 


Wednesday, 12 August 2020

How to rerun only failed test cases using testng in automation testing framework? TestNG listeners for Automation Framework



 

 

 

 

 

 

1. Create a class which implements IRetryAnalyzer and provide the retry count @maxRetryCount

public class FailRetry implements IRetryAnalyzer {
 
  private int retryCount = 0;
  private static final int maxRetryCount = 2;
 
  @Override
  public boolean retry(ITestResult result) {
    if (retryCount < maxRetryCount) {
      retryCount++;
      return true;
    }
    return false;
  }
  }
 
2. Create a class which implements IAnnotationTransformer and pass the class name that we have created in step-1  @setRetryAnalyzer

public class RetryListener implements IAnnotationTransformer {

    @Override
    public void transform(ITestAnnotation testannotation, Class testClass,
            Constructor testConstructor, Method testMethod)    {
        IRetryAnalyzer retry = testannotation.getRetryAnalyzer();

        if (retry == null)    {
            testannotation.setRetryAnalyzer(FailRetry.class);//pass the class name created in Step-1
        }

    }
}

3. Add listener in testng.xml file after the suite tag as below and define the class name created in Step-2 with the package path

<suite name="Automation Test Suite for IX Onespace">
<listeners>
        <listener class-name="com.task.automation.util.RetryListener"/>
  </listeners>

Need more Framework Design related code: Check out below post==>https://automationreinvented.blogspot.com/search/label/FrameworkDesign

 TestNG related interview questions for SDET:
https://automationreinvented.blogspot.com/search/label/TestNG

 JAVA related posts:
https://automationreinvented.blogspot.com/search/label/Java

QA Job Opening: Click here


************************************************* 

API Testing Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Rest-API

 
Kubernetes Interview Question Set
https://automationreinvented.blogspot.com/search/label/Kubernetes

 
Docker Interview Question Set
https://automationreinvented.blogspot.com/2020/02/top-18-docker-commands-for-aytomation.html

 
Linux Interview question Set
https://automationreinvented.blogspot.com/search/label/Linux

 
Automation Testing/SDET Framework Design 
https://automationreinvented.blogspot.com/search/label/FrameworkDesign


Java Related Interview Question Set

https://automationreinvented.blogspot.com/search/label/Java


GIT Interview Question Set:
https://automationreinvented.blogspot.com/search/label/GIT


Coding Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Coding%20Questions

Friday, 7 August 2020

TOP 21 git interview question and answers for 2020 SET-02? SDET/Automation QA/Devops




Check GIT commands for Interview preparation SET-1:
GIT Interview Question 1 to 11

12. How to know about the history?

git log

To know more about git log : https://git-scm.com/docs/git-log

13. How to know all the details of changes to a commit?

git show <commitID>
To know more about git show : https://git-scm.com/docs/git-show
 
********************************************************

Framework Design Tips & Interview Question ==> Click Here

************************************************** 

14. How to know the last commit details and see a log where each commit is one line?

To know the last commit details : git log -1
see log each commit in one line: git log --pretty=oneline

15. What git add and git commit command does

Git add--> add the changes to index area
Git commit--> add changes to local repo

16. How to compare two branch in GIT?

git diff branch1...branch2


17. How to view current state and any merge conflits?

git status

The git status command displays the state of the working directory and the staging area.

18. How to undo last commit and rewrite history?

git reset --hard HEAD~1
 
 

19. Difference between soft, mixed, and hard resets?

--soft: Uncommit changes but leave those changes staged
--mixed (the default): Uncommit and unstage changes, but changes are left in the working directory
--hard: Uncommit, unstage, and delete changes

20.  How to reset a file back to how it was before changes?

git restore <filename>     # new syntax (as of Git 2.23)
git checkout -- <filename> # old syntax

21. How to unstage changes or restore files?

Maybe you accidentally staged some files which we don't want to commit.
git restore test.js
git restore .

#TodaysTip
Starting with git 2.23 we have new sub-commands :

1. git switch to switch between branches
2. git restore to undo all modifications made
Check GIT commands for Interview preparation SET-1:
GIT Commands SET-1

How to add repository in bitbucket for automation project and tracked by git? 
 
 Interview Question Set AutomationTesting/SDET/QAOPS
QA Job Opening: Click here

************************************************* 

API Testing Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Rest-API

 
Kubernetes Interview Question Set
https://automationreinvented.blogspot.com/search/label/Kubernetes

 
Docker Interview Question Set
https://automationreinvented.blogspot.com/2020/02/top-18-docker-commands-for-aytomation.html

 
Linux Interview question Set
https://automationreinvented.blogspot.com/search/label/Linux

 
Automation Testing/SDET Framework Design 
https://automationreinvented.blogspot.com/search/label/FrameworkDesign


Java Related Interview Question Set

https://automationreinvented.blogspot.com/search/label/Java


GIT Interview Question Set:
https://automationreinvented.blogspot.com/search/label/GIT


Coding Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Coding%20Questions


Sunday, 2 August 2020

How to call a method in Java? SDET Interview questions 2020












SDET Interview questions: How to access methods of a class in Java?

There are two ways to access method in class.

1. By creating object of class
2. Using static : If we use static then we can access the method without creating object of the class

Example of By creating object of class:

public class configReader {
     
  public int methodtwo(int a, int b)
// int is return type and public is access modifier. int a and int b are input parameters

{
      int sum = a+ b;
      return sum;
     
  }
 
  public static void main(String[] args) {
   
      configReader md = new configReader();  //Object Creation
      int result = md.methodtwo(2,3);               // access method by using object
      System.out.println(result);
  }
 
}

Example of accessing method with Static:

public class configReader {
 
  public static  int methodone(int a, int b) {
//static has been used so that with class name we can access the method
      int sum = a+ b;
      return sum;
  }
 
  public static void main(String[] args) {
      int resultone = methodone(3,4);            //accessing method directly without object
     System.out.println(resultone );
  }
}

If we want to access the same method in another class then use classname:
configReader.methodone(3,4)

For more Java related interview questions check below link:
*
**
**
*

*************************************************

API Testing Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Rest-API

 
Kubernetes Interview Question Set
https://automationreinvented.blogspot.com/search/label/Kubernetes

 
Docker Interview Question Set
https://automationreinvented.blogspot.com/2020/02/top-18-docker-commands-for-aytomation.html

 
Linux Interview question Set
https://automationreinvented.blogspot.com/search/label/Linux

 
Automation Testing/SDET Framework Design
https://automationreinvented.blogspot.com/search/label/FrameworkDesign


Java Related Interview Question Set

https://automationreinvented.blogspot.com/search/label/Java


GIT Interview Question Set:
https://automationreinvented.blogspot.com/search/label/GIT


Coding Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Coding%20Questions