Question 1 of 25
Hints left: 3
Q1
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)); } }
Q2
Which of the following is the correct way to compare two strings in a case-insensitive manner in Java?
Q3
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); } }
Q4
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); } }
Q5
What is the result of the expression "Hello".toUpperCase().toLowerCase() in Java?
Q6
What is the purpose of the substring() method of a String object in Java?
Q7
In Java, what is the purpose of the endsWith() method of a String object?
Q8
What method is used to convert an integer to a string in Java?
Q9
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); } }
Q10
In Java, what is the purpose of the isEmpty() method of a String object?
Q11
Which method is used to split a string into an array of substrings based on a specified delimiter in Java?
Q12
The String method compareTo() returns
Q13
What is the result of the expression "Java".replace("a", "o") in Java?
Q14
toString() method is defined in
Q15
How do you find the last index of a specified character in a string in Java?
Q16
What will be the output? String str1 = "abcde"; System.out.println(str1.substring(1, 3));
Q17
Which of the following is true about string concatenation in Java?
Q18
In Java, what is the purpose of the endsWith() method of a String object?
Q19
Which method is used to extract a substring from a string in Java?
Q20
What is the purpose of the toLowerCase() method of a String object in Java?
Q21
How do you check if a string contains a specific character in Java?
Q22
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); } }
Q23
In Java, what does the concat() method of a String object do?
Q24
How do you find the first index of a specified character in a string in Java?
Q25
How do you find the index of the last occurrence of a substring in a string in Java?