Automation Interview Logical Question & Answer || Automation Testing Interview Question & Answer || Automation Testing Interview Question
1. write program for reverse string?
string str = "Bhaumik"
String res = " ";
int count = str.length();
for(int i = count-1; i>=0;i--)
{
res = res + charAt(i);
}
syso(res)
2. Get unique string from String?
String str = "Bhaumik"
Map<Charater,Integer> m = new HashMap<Charater,Integer>();
Char st[] = str.tocharArray();
for(chr c : st){
if(m.containskey(c))
{
m.put(c, m.get(c)+1);
}
else{
m.put(c,1);
}
syso(m);
3. Find Max number from arraylist?
int a[] = new int[] {100,200,2,4,5,1,0,101,222};
int max = a[0];
for(int i =0; i<a.length; i++)
{
if(a[i]>max)
{
max=a[i];
}
}
System.out.println(max);
4. Remove special Charater from string?
String s1 = "@#$%This is new String #$%^";
String s = s1.replaceALL("[^A-Z0-9a-z ]","");
syso(s)
Comments
Post a Comment