What will be the output of the following Java program? class output ...
View Question
What will be the output of the following Java program?
class output
{
public static void main(String args[])
{
String s1 = “Hello World”;
String s2 = s1.substring(0 , 4);
System.out.println(s2);
}
}
What will be the output of the following Java program? class output ...
View Question
What will be the output of the following Java program?
class output
{
public static void main(String args[])
{
String s1 = “Hello”;
String s2 = s1.replace(‘l’,’w’);
System.out.println(s2);
}
}
What will be the output of the following Java program? class output ...
View Question
What will be the output of the following Java program?
class output
{
public static void main(String args[])
{
String s1 = “one”;
String s2 = s1 + ” two”;
System.out.println(s2);
}
}
What will be the output of the following Java program? class output ...
View Question
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+”\””);
}
}
What will be the output of the following Java program? class output ...
View QuestionWhich of the following statement is correct?
a) replace() method replaces all occurrences of one character in invoking string with ...
View QuestionWhat is the value returned by function compareTo() if the invoking string is greater than the string compared?
a) zero b) value less than zero c) value greater than zero d) none of ...
View QuestionWhich of these method of class String is used to remove leading and trailing whitespaces?
a) startsWith() b) trim() c) Trim() d) doTrim() Answer: b Explanation: trim()
View Question
What will s2 contain after following lines of Java code?
String s1 = “one”;
String s2 = s1.concat(“two”)
What will s2 contain after following lines of Java code? String s1 = "one"; String s2 = ...
View QuestionWhich of this method of class String is used to extract a substring from a String object?
a) substring() b) Substring() c) SubString() d) None of the mentioned Answer: a Explanation: substring()
View Question