selenium java programs interview questions

Beginner Level Selenium Interview Questions
  • What are the Selenium suite components? …
  • What are the limitations of Selenium testing? …
  • What are the testing types supported by Selenium? …
  • What is the difference between Selenium 2.0 and Selenium 3.0? …
  • What is the same-origin policy and how is it handled? …
  • What is Selenese?

In the recent past, I visited a couple of companies for the interviews for automation engineer posts and there I was asked to write small programs which I have learnt in graduation days…

1. Print below pattern: This is one of the best programs to learn loop (you can try any among all provided java loops but here I am going to use for loop)

2. Print below pattern: This program is again going to use the same logic but in place of digits, * would be used

3. Program to read from file line by line: bufferedReader class provides readLine method to be used to read the file line by line.

public static void readFile() throws FileNotFoundException { FileReader fr = new FileReader(“C:’Users’…’Desktop’unused.txt”); BufferedReader br = new BufferedReader(fr); StringBuffer str = new StringBuffer(); try { while (br.readLine()!= null){ str.append(br.readLine()); } } catch (IOException e) { e.printStackTrace(); } System.out.println(str); }

public static void reverse() { String str = “I use selenium webdriver. selenium is a tool for web applications.”; int i = str.length(); StringBuffer strb = new StringBuffer(); for( int j=i-1; j>=0; j–){ strb = strb.append(str.charAt(j)); } System.out.println(strb); }

If you want to learn more about string related interview question then read 5 Commonly Asked Java String Question in Selenium Interview

public static void replace() { String str = “I use selenium webdriver. selenium is a tool for web applications automation.”; String toBeReplaced = “selenium”; String toReplacedWith = “Firefox”; String[] astr = str.split(toBeReplaced); StringBuffer strb = new StringBuffer(); for ( int i = 0; i <= astr.length – 1; i++ ) { strb = strb.append( astr[i] ); if (i != astr.length – 1) { strb = strb.append(toReplacedWith); } } System.out.println(strb);

There could have been more ways to create the above programs. I would like to invite you all to find out those.

Along with this, I would suggest you, take this quiz to check your selenium interview preparation

#1 : Java Programming Interview Questions For Automation Testers With Answers

First, we convert the given ‘inputstring’ to char array and call it as ‘inputStringArray’. We define one more char array called ‘resultArray’ with the same size as ‘inputStringArray’. In the first for loop, for every space in the ‘inputStringArray’, we insert space in the ‘resultArray’ at the corresponding positions. In the second for loop, we copy non-space characters of ‘inputStringArray’ starting from first to last into the ‘resultArray’ at ‘j’ position where ‘j’ will have value from length of resultArray to 0. Before copying, we check whether the ‘resultArray’ already contains a space at index ‘j’ or not. If it contains, we copy the character in the next position. See the below for more clarity.

In this section, we are giving few java interview programs faced by some of my friends. If you come across any questions, post it to me. I can provide solutions. You can email me at [email protected]

Factorial of any number is the product of an integer and all the integers below it for example factorial of 4 is 4! = 4 * 3 * 2 * 1 = 24. In below code, I will show you how to design Java program to find factorial, using for loop you can perform this task.

Top 10 Java Coding Questions for Test Automation Developers.

We wish that these Java coding questions would provide you the desired edge in a job interview. If you would have any query regarding these questions, then use the comment box given at the end of this post to reach to us.

Question-1: Write code to filter duplicate elements from an array and print as a list?

If you recently gave any Selenium Webdriver interview and faced similar or different Java coding questions. Then, please do write to us and help us increase our interview question bank. It’ll be a great help not only us but for the other readers of this blog. We’ll surely add your submissions to our list of Java coding questions. And, you’ll get a direct mention on our blog.

Explain Java Main Method public static void main (String[] args)

When you start learning Java, the first method you encounter is public static void main(String [] args). The starting point of any Java Program is the main() method. It is one of the important methods of Java. Technically, the main method is the starting point where the Java program starts its execution. JVM always look for this method signature to start running an application. Check this to know detailed explanation.

FAQ

What are the Java programs asked in interview?

Top 8 Java Programs Asked In Interview for Freshers With Solution
  • The Fibonacci series. …
  • Checking for prime number. …
  • String palindrome. …
  • Bubble sort. …
  • Armstrong number. …
  • Merge Sort. …
  • Factorial. …
  • Reversing strings.

How is Java used in selenium?

Java is one of the languages used for writing Selenium automation script. Selenium supports other languages as well like python, ruby, C#, javascript, etc. Selenium with Java is widely used and preferred language by automation testers compared to other languages. I don’t say there is no need to learn complete Java.

Which one of the following can be tested automatically using selenium?

What are the basic Java programs?
  • Calculator Program in Java.
  • Factorial Program using Recursion.
  • Fibonacci Series Program.
  • Palindrome Program in Java.
  • Permutation and Combination Program.
  • Pattern Programs in Java.
  • String Reverse Program in Java.
  • Mirror Inverse Program in Java.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *