Computer Applications
Give the output of the following string functions:
- "MISSISSIPPI".indexOf('S') + "MISSISSIPPI".lastIndexOf('I')
- "CABLE".compareTo("CADET")
Related Questions
The following code to compare two strings is compiled, the following syntax error was displayed – incompatible types – int cannot be converted to boolean.
Identify the statement which has the error and write the correct statement. Give the output of the program segment.
void calculate() { String a = "KING", b = "KINGDOM"; boolean x = a.compareTo(b); System.out.println(x); }The output of the statement "talent".compareTo("genius") is:
- 11
- –11
- 0
- 13
Which of the following returns a String?
- length()
- charAt(int)
- replace(char, char)
- indexOf(String)
The output of the statement "CONCENTRATION".indexOf('T') is:
- 9
- 7
- 6
- (-1)