Interview Questions & Answers Selenium Webdriver Tutorials

Write a Java program | 5 commonly asked java-program in Selenium interview

As soon as you write Selenium Java in your resume, interviewer is bound to give you a sheet of paper & ask write a Java program. Though Selenium doesn’t require extensive Java knowledge but still there is a set of basic Java programs that you should be able to write on-the-spot. This article covers five of the most popular Write a Java program questions frequently asked in the technical interview. The questions are easy, but don’t forget to mark these java-program in your to do list before attending any technical interview for Selenium automation testing.

Write a Java program Commonly asked java-program in Selenium interview

Recursion in programming

Recursion is a programming technique that allows the programmer to express operations in terms of themselves, i.e. a function that calls itself is known as a recursive function. A useful way to think of recursive functions is to imagine them as a process being performed where one of the instructions is to “repeat the process”.

Write a Java program to calculate Factorial of a number

In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example,

5! = 5 * 4 * 3 * 2 * 1 = 120

The value of 0! is 1, according to the convention for an empty product.

Use of Recursion:

Write a Java program to print the Fibonacci series

In mathematics, the Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and characterized by the fact that every number after the first two is the sum of the two preceding ones:

1, 1, 2, 3, 5, 8, 13, 21, 34, 55…

By definition, the first two numbers in the Fibonacci sequence are either 1 and 1, or 0 and 1, depending on the chosen starting point of the sequence, and each subsequent number is the sum of the previous two.

Use of Recursion:

Write a Java program to calculate power ‘n’ of a number

This is simple,

2 power 5 = 2 * 2 * 2 * 2 * 2 = 32

Use of Recursion:

Write a Java program to Reverse a String

Although there are many ways to get the solution but we are sharing 2 different ways to reverse a string. First we will understand the question,

Input: Deepanshu Agarwal | Output: lawragA uhsnapeeD

Input: Software Testing Studio | Output: oidutS gnitseT erawtfoS

This java program reverses a string entered by the user. We use,

  • charAt method to extract characters from the string and append them in reverse order to reverse the entered string
  • StringBuffer class method

Write a Java program to calculate ‘Digit Sum’

You’re given an integer N. Write a Java program to calculate the sum of all the digits of N. In mathematics, the digit sum of a given integer is the sum of all its digits (e.g. the digit sum of 84001 is calculated as 8+4+0+0+1 = 13).

Hope these five programs will help you kick-start the Java-program journey. All the Best 🙂

Leave a Reply

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