Which of the following statements about strings in Java is true?
What will be the output of the following code?
String str1 = "Hello";
String str2 = new String("Hello");
System.out.println(str1 == str2);
1 Crore+ students have signed up on EduRev. Have you? Download the App |
Which of the following methods is used to concatenate two strings in Java?
What will be the output of the following code?
String str = "Java";
str.toUpperCase();
System.out.println(str);
Which of the following methods is used to determine the length of a string in Java?
What will be the output of the following code?
String str = "Hello,World";
String[] tokens = str.split(",");
System.out.println(tokens.length);
What will be the output of the following code?
String str = "Hello,World";
String[] tokens = str.split(",");
System.out.println(tokens[0]);
What will be the output of the following code?
String str = "Hello,World";
String[] tokens = str.split(",");
System.out.println(tokens[1]);
What will be the output of the following code?
String str = "Hello, World";
String[] tokens = str.split("\\s+");
System.out.println(tokens[0]);
What will be the output of the following code?
String str = "Java Programming";
String result = str.replace("Java", "Python");
System.out.println(result);
What will be the output of the following code?
String str = "CodeChef";
String result = "";
for (int i = str.length() - 1; i >= 0; i--)
result += str.charAt(i);
System.out.println(result);
What will be the output of the following code?
String str = "Hello, World";
String result = str.substring(7, 12);
System.out.println(result);
What will be the output of the following code?
String str = "Hello";
String result = str.replace("l", "L");
System.out.println(result);
What will be the output of the following code?
String str = "Hello";
String result = str.substring(1, 4);
System.out.println(result);
What will be the output of the following code?
String str = "OpenAI";
String result = str.substring(0, 2) + str.substring(3);
System.out.println(result);