Strings
- What is the output of this program?
public class Result
{
public static void main(String args[])
{
String str1 = "Interview";
String str2 = str1 + " Mania";
System.out.println(str2);
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
Interview Mania
- What is the output of this program?
public class Result
{
public static void main(String args[])
{
String str0 = " Interview mania ";
String str1 = str0.trim();
System.out.println("\""+str1+"\"");
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
trim() method is used to remove leading and trailing whitespaces in a string.
- Which of the following statement is correct?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
replace() method replaces all occurrences of one character in invoking string with another character.
- What is the value returned by function compareTo() if the invoking string is greater than the string compared?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
value greater than zero
- Which of these method of class String is used to remove leading and trailing whitespaces?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
trim()