DevLabs Alliance Top 20 Java Programming Interview Questions For SDET
DevLabs Alliance Top 20 Java Programming Interview Questions For SDET
By DevLabs Alliance
package com.dla;
public class SecondFrequentCharacter {
static final int NO_OF_CHARS = 256;
public static void main(String[] args)
{
//String to find second frequent character
String str = "DevLabsAlliance";
char res = getSecondMostFreq(str);
if (res != '\0')
System.out.println("Second most frequent char is " + res);
else
System.out.println("No second most frequent character");
}
Programming Interview Questions for SDET
package com.dla;
public class ReverseAString {
public static void main(String[] args) {
String s = "DevLabsAlliance";
String revS = "";
package com.dla;
import java.util.regex.Pattern;
public class ReverseWordsInString {
public static void main(String[] args) {
String str = "Learn Lead And Succeed in DevLabsAlliance";
Pattern p = Pattern.compile("\\s");
String[] temp = p.split(str);
String rev = "";
for (int i = 0; i < temp.length; i++) {
if (i == temp.length - 1)
rev = temp[i] + rev;
else
rev = " " + temp[i] + rev;
}
Programming Interview Questions for SDET
Output: The reversed string is: DevLabsAlliance in Succeed And Lead Learn
Programming Interview Questions for SDET
package com.dla;
public class FrequencyOfCharacter {
public static void main(String[] args) {
String str = "DevLabs Alliance is awesome.";
char ch = 'e';
int frequency = 0;
for(int i = 0; i < str.length(); i++) {
if(ch == str.charAt(i)) {
++frequency;
}
}
System.out.println("Frequency of " + ch + " = " + frequency);
}
}
Output: Frequency of e = 4
Programming Interview Questions for SDET
package com.dla;
public class ReplaceSubStringWithAnotherString {
public static void main(String[] args) {
String str = "Learn, Lead and Succeed in DevLabsAlliance";
String toBeReplaced = "in";
String toReplacedWith = "with";
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);
}
}
Programming Interview Questions for SDET
System.out.println(strb);
}
}
Ouput: Learn, Lead and Succeed with DevLabsAlliance
Programming Interview Questions for SDET
7. Write a Java program to find the largest value from the given array.
package com.dla;
public class LargestNumberInArray {
public static void main(String[] args) {
int[] arr={28,3,15,9,17,4,23,2};
int val=arr[0];
for(int i=0; i<arr.length; i++){
if(arr[i] > val){
val=arr[i];
}
}
System.out.println("Largest value in the Given Array is "+ val);
}
}
Output: Largest value in the Given Array is 28
Programming Interview Questions for SDET
package com.dla;
import java.util.HashMap;
public class WordCount {
public static void main(String[] args) {
String str = "Training Training course and certification course in Devlabs
Alliance";
String[] split = str.split(" ");
HashMap<String, Integer> map = new HashMap<String, Integer>();
for (int i = 0; i < split.length - 1; i++) {
if (map.containsKey(split[i])) {
int count = map.get(split[i]);
map.put(split[i], count + 1);
}
Programming Interview Questions for SDET
else {
map.put(split[i], 1);
}
}
System.out.println(map);
}
}
SDET is a highly skilled resource having both development and testing skills whereas
manual testers have limited programming skills and can only prepare and execute the test
cases.
SDETs can develop test automation tools and can use it but testers are not expected to
develop the automations tools, they can only use the various automation tools.
Visit us at: www.devlabsalliance.com
Email: [email protected]
Contact: +91 9717514555