Question 1 of 25
Hints left: 3
Q1
What could be output of the following fragment of code? public class Test{ public static void main(String args[]){ String x = "hellow"; int y = 9; System.out.println(x += y); } }
Q2
What method is used to convert an integer to a string in Java?
Q3
What is the purpose of the substring() method of a String object in Java?
Q4
What will be the output of the following program code? class LogicalCompare{ public static void main(String args[]){ String str1 = new String("OKAY"); String str2 = new String(str1); System.out.println(str1 == str2); } }
Q5
How do you find the index of the last occurrence of a substring in a string in Java?
Q6
Which of the following is true about string concatenation in Java?
Q7
Determine output: public class Test{ public static void main(String args[]){ String s1 = "SITHA"; String s2 = "RAMA"; System.out.println(s1.charAt(0) > s2.charAt(0)); } }
Q8
What is the result of the expression "Java".replace("a", "o") in Java?
Q9
How do you find the first index of a specified character in a string in Java?
Q10
In Java, what is the purpose of the endsWith() method of a String object?
Q11
How do you find the last index of a specified character in a string in Java?
Q12
What will be the output of the following program? public class Test{ public static void main(String args[]){ String s1 = "java"; String s2 = "java"; System.out.println(s1.equals(s2)); System.out.println(s1 == s2); } }
Q13
In Java, what does the concat() method of a String object do?
Q14
toString() method is defined in
Q15
In Java, what is the purpose of the isEmpty() method of a String object?
Q16
Which method is used to extract a substring from a string in Java?
Q17
What will be the output? String str1 = "abcde"; System.out.println(str1.substring(1, 3));
Q18
The String method compareTo() returns
Q19
In Java, what is the purpose of the endsWith() method of a String object?
Q20
The output of the following fraction of code is public class Test{ public static void main(String args[]){ String s1 = new String("Hello"); String s2 = new String("Hellow"); System.out.println(s1 = s2); } }
Q21
How do you check if a string contains a specific character in Java?
Q22
What is the purpose of the toLowerCase() method of a String object in Java?
Q23
What is the result of the expression "Hello".toUpperCase().toLowerCase() in Java?
Q24
Which of the following is the correct way to compare two strings in a case-insensitive manner in Java?
Q25
Which method is used to split a string into an array of substrings based on a specified delimiter in Java?