Huawei Technologies - SDET interview questions and answers

 

Huawei Technologies - SDET interview questions and answers

--- Program to reverse each character in the string---

public class reverse

{


public static void main(String args[])

{

String temp = "This is just for interview";


String newString;

String test;

--------------------------Split String intoArray

String val[]= temp.split(" ");


for(int i =0; i<val.length();i++)

{


reverseString(val(i));


test= newString.concate(val(i).concate(" "));


}

System.out.println(test);


}

--------------------------Create a function to reverse a string 

public static void reverseString(String val)

{

char temp[]= val.toCharArray();

for(int i =temp.lenght-1; i<0;i--)

{

System.out.print(temp(i));

}


}


}






-- find the max value from the array

class maxArray

{

public static void main(String args[])

{

int test[] = {34, 8, 10, 3, 2, 80, 30, 33, 1};

int arr[i] =0;

for(int j =0; j<test.length; j++)

{


if(arr[i]<test[j])

{

arr[i]== test[j];

}

}

System.out.println(arr[i]);

}

}




class maxArray

{

public static void main(String args[])

{


String name = "india"


char val[]= name.tocharArray();


HashMap<Character, integer> obj = new HashMap<Character, integer>();


for(int i =0; i<val.lenght; i++)

{


if(obj.get(i).contains(val(i)))   // iskey or haskey

{

obj.put(val(i)),get(val(i)+1)

}

else

{

obj.put(val(i),1);

}

}

System.out.println(obj);

}

}





empname, add, salary, contactno




Class findsalary()

{




public static void main(String args[])

{


WebDriver driver = new ChromeDriver("Path");

driver.get("Application URL");

driver.findElement(By.xpath("username xpath")).sendkeys("username");

driver.findElement(By.xpath("password xpath")).sendkeys("password");

driver.findElement(By.xpath("loginButton xpath")).click();


List<WebElement> sal= driver.findElements("xpathforNamesalary");


List<WebElement> names = driver.findElements("xpathforNamecolumn"); // we can use webTable concept here and take the


for(int i =0; i<names.size();i++) // xpath for entercolumn instaead of any sepecif row 

{

if(names.get(i).getText().equals("Manish")

{

System.out.println(sal.get(i).getText());

}    

}

}






































Post a Comment