Table of Contents
Java Selenium Interview Programming Questions
Prepare for your Java Selenium Interview Programming Questions with our comprehensive collection of programming questions designed to assess your expertise in web automation. Whether you’re a seasoned Selenium professional or a budding automation engineer, our curated set of interview questions will help you showcase your Java programming skills and demonstrate your proficiency in Selenium WebDriver.
1.Write a program for reverse String?
public class ReverseString {
public static void main(String[] args) {
String original = "Hello, world!";
String reversed = "";
for (int i = original.length() - 1; i >= 0; i--) {
reversed += original.charAt(i);
}
System.out.println("Original string: " + original);
System.out.println("Reversed string: " + reversed);
}
}
2. Write a program for Find Area of Tringle
package arithmeticOperations;
import java.lang.*;
import java.util.Scanner;
public class AreaOfTringle {
public static void main(String[] args) {
float base, height,area;
System.out.println("Enter base and height ");
Scanner sc = new Scanner(System.in);
base = sc.nextFloat();
height =sc.nextFloat();
area = 1f/2f* base * height ;
System.out.println("Area of tringle " + area);
}
}
3. Write a program for Quadratic Equations
package arithmeticOperations;
import java.util.Scanner;
public class QuadraricEquations {
public static void main(String[] args) {
int a,b,c;
double r1, r2;
Scanner sc = new Scanner(System.in);
System.out.println("Enter the value of a, b, c ");
a=sc.nextInt();
b=sc.nextInt();
c=sc.nextInt();
r1=(-b+Math.sqrt(b*b-4*a*c))/(2*a);
r2=(-b-Math.sqrt(b*b-4*a*c))/(2*a);
System.out.println("Root of " + r1 +" "+ r2);
}
}
4. Write a program for Cuboid
package arithmeticOperations;
import java.util.Scanner;
public class AreaAndVolumeOFCuboid {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int length, breath, height;
System.out.println("Enter the value of Length, Breath, Height ");
length = sc.nextInt();
breath =sc.nextInt();
height =sc.nextInt();
int TotalArea, Volume;
TotalArea=2*(length*breath+length*height+breath*height);
Volume = length * breath * height ;
System.out.println("Total area :" + TotalArea + " " + "Total Volume :"+ Volume);
}
}
5. Remove Special characters from String
package allPractisePrograms;
public class RemoveSpecialCharaFromString {
public static void main(String[] args) {
String sample="ABCD!@#ABCD";
System.out.println(sample.replaceAll("[^a-zA-Z0-9]", ""));
String ExtraSpace = "dsaa s sa a a a s da ds s";
System.out.println(ExtraSpace.replaceAll("\\s*", " "));
String countWords="asdas asfasf asfsafsfa";
String [] words=countWords.split("\\s");
System.out.println(words.length);
}
}
6. Validate Email name and Domain name
package allPractisePrograms;
public class ValidateEmail {
public static void main(String[] args) {
String mail= "user@gmail.com";
int i= mail.indexOf("@");
String user=mail.substring(0,i);
String domain=mail.substring(i,mail.length());
System.out.println(user + " + " + domain);
System.out.println(domain.startsWith("@gmail"));
System.out.println(domain.endsWith("com"));
}
}
7. Validate Binary Number
package allPractisePrograms;
public class ValidateBinaryNumber {
public static void main(String[] args) {
int a =101011;
String b=String.valueOf(a);
System.out.println(b.matches("[01]*"));
String Hexadecimal ="234AB";
System.out.println(Hexadecimal.matches("[0-9A-F]*"));
}
}
8. Find Even/ Odd Number from given Value
package allPractisePrograms;
import java.util.*;
public class FindNumberEvenOrOdd {
public static void main(String[] args) {
int n;
Scanner sc = new Scanner(System.in);
n= sc.nextInt();
if (n%2==0) {
System.out.println("This number id Even" + n);
}
else {
System.out.println("This number is Odd " + n);
}
}
}