41. String str1 = "Kolkata".replace('k', 'a');
In the above statement, the effect on string Kolkata is
String str1 = "Kolkata".replace('k', 'a');
In the above statement, the effect on string Kolkata is
42. The class string belongs to ................. package.
43. What will be the output?
public class Test{
public static void main (String[] args){
String test = "a1b2c3";
String[] tokens = test.split("\\d");
for(String s: tokens)
System.out.print(s);
}
}
public class Test{
public static void main (String[] args){
String test = "a1b2c3";
String[] tokens = test.split("\\d");
for(String s: tokens)
System.out.print(s);
}
}
44. How many objects will be created?
String a = new String("Examveda");
String b = new String("Examveda");
String c = "Examveda";
String d = "Examveda";
String a = new String("Examveda");
String b = new String("Examveda");
String c = "Examveda";
String d = "Examveda";
45. How many Constructor String class have?
46. What will be output?
String S1 = "S1 ="+ "123"+"456";
String S2 = "S2 ="+(123+456);
String S1 = "S1 ="+ "123"+"456";
String S2 = "S2 ="+(123+456);
47. What will be the output of the following program code?
public class Test{
public static void main(String args[]){
String s = "what";
StringBuffer sb = new StringBuffer("what");
System.out.print(sb.equals(s)+","+s.equals(sb));
}
}
public class Test{
public static void main(String args[]){
String s = "what";
StringBuffer sb = new StringBuffer("what");
System.out.print(sb.equals(s)+","+s.equals(sb));
}
}
48. What will be the output?
public class Test{
public static void main(String args[]){
Object myObj = new String[]{"one", "two", "three"};
{
for(String s : (String[])myObj)
System.out.print(s + ".");
}
}
}
public class Test{
public static void main(String args[]){
Object myObj = new String[]{"one", "two", "three"};
{
for(String s : (String[])myObj)
System.out.print(s + ".");
}
}
}
49. Determine output:
public class Test{
public static void main(String args[]){
String str = null;
if(str.length() == 0){
System.out.print("1");
}
else if(str == null){
System.out.print("2");
}
else{
System.out.print("3");
}
}
}
public class Test{
public static void main(String args[]){
String str = null;
if(str.length() == 0){
System.out.print("1");
}
else if(str == null){
System.out.print("2");
}
else{
System.out.print("3");
}
}
}
50. Which of these methods is used to compare a specific region inside a string with another specific region in another string?
Read More Section(Strings)
Each Section contains maximum 100 MCQs question on Strings. To get more questions visit other sections.