Computer Applications
What is the output of the following statement:
“MONOPOLY”.lastIndexOf(‘O’);
- 1
- 3
- 2
- 5
Java
Java String Handling
7 Likes
Answer
5
Reason — In the string "MONOPOLY", the character 'O' occurs at indexes 1, 3, and 5 (indexing starts from 0). The lastIndexOf('O') method returns the last occurrence of 'O', which is at index 5.
Answered By
4 Likes
Related Questions
Which statement is correct for the method prototype given below:
int check(char ch, String s)- check() does not return any value
- check() has return type int
- check method has two actual parameters
- check() is a constructor
The Math method which returns int value is:
- round()
- cbrt()
- ceil()
- random()
Typecasting is often necessary when dealing with financial data. Identify the correct syntax to typecast a double to an int using the variables:
int amount; double valueINR- int amount = valueINR;
- int amount = Integer.parseInt (valueINR);
- int amount = (int) valueINR;
- int amount = int (valueINR);
What is the output of the code snippet given below?
int lives = 5; System.out.print(lives--); System.out.print(lives);- 4 3
- 5 4
- 5 3
- 4 4