51. What will be the output of the following Java code?
class output
{
public static void main(String args[])
{
StringBuffer s1 = new StringBuffer("Hello");
s1.insert(1,"Java");
System.out.println(s1);
}
}
class output
{
public static void main(String args[])
{
StringBuffer s1 = new StringBuffer("Hello");
s1.insert(1,"Java");
System.out.println(s1);
}
}
52. What will be the output of the following Java code?
class output
{
public static void main(String args[])
{
String c = "Hello i love java";
boolean var;
var = c.startsWith("hello");
System.out.println(var);
}
}
class output
{
public static void main(String args[])
{
String c = "Hello i love java";
boolean var;
var = c.startsWith("hello");
System.out.println(var);
}
}
53. Which of these data type value is returned by equals() method of String class?
54. Which of the following are incorrect form of StringBuffer class constructor?
55. What will be the output of the following Java program?
class output
{
public static void main(String args[])
{
String c = " Hello World ";
String s = c.trim();
System.out.println("\""+s+"\"");
}
}
class output
{
public static void main(String args[])
{
String c = " Hello World ";
String s = c.trim();
System.out.println("\""+s+"\"");
}
}
56. Which of the following statement is correct?
57. What will be the output of the following Java program?
class output
{
public static void main(String args[])
{
String a = "hello i love java";
System.out.println(a.indexOf('e')+" "+a.indexOf('a')+" "+a.lastIndexOf('l')+" "+a.lastIndexOf('v'));
}
}
class output
{
public static void main(String args[])
{
String a = "hello i love java";
System.out.println(a.indexOf('e')+" "+a.indexOf('a')+" "+a.lastIndexOf('l')+" "+a.lastIndexOf('v'));
}
}
58. Which of these class is used to create an object whose character sequence is mutable?
59. Which of these methods can be used to convert all characters in a String into a character array?
60. What will be the output of the following Java code?
class output
{
public static void main(String args[])
{
String s1 = "Hello i love java";
String s2 = new String(s1);
System.out.println((s1 == s2) + " " + s1.equals(s2));
}
}
class output
{
public static void main(String args[])
{
String s1 = "Hello i love java";
String s2 = new String(s1);
System.out.println((s1 == s2) + " " + s1.equals(s2));
}
}
Read More Section(Strings)
Each Section contains maximum 100 MCQs question on Strings. To get more questions visit other sections.