Computer Applications
The output of the statement of "TIGER".indexOf('G') is:
- 3
- 2
- -1
- 0
Java String Handling
1 Like
Answer
2
Reason — The indexOf() method in Java returns the position (index) of the first occurrence of the specified character in the string.
In the string "TIGER":
Tis at index 0Iis at index 1Gis at index 2
So, "TIGER".indexOf('G') returns 2.
Answered By
2 Likes
Related Questions
Which of the following statement is an example for explicit typecasting?
- int amount = 45;
- int amount = 24*24;;
- int amount = Integer.parseInt("45")
- int amount = (int)45.75;
The output of the statement
Math.ceil.(89.9) + Math.floor(90.5)is:- 0.0
- 180
- 180.0
- 180.4
Choose the statement which is equivalent to the given:
if(a>b) System.out.println("Honest"); else System.out.println("Sincere");a>b? System.out.println("Honest"):System.out.println("Sincere");System.out.println(a>b? "Honest":"Sincere");a>b? "Honest": "Sincere";a>b: "Honest"? "Sincere";
The two Java statement are used to check for the equality of the strings "COP" and "cop" are as follows:
"COP".equals("cop") "COP".equalsIgnoreCase("cop")The output of the above statements is:
- false, true
- true, false
- false, false
- true, true