Computer Applications
The output of the function "COMPOSITION".substring(3, 6):
- POSI
- POS
- MPO
- MPOS
Java String Handling
ICSE 2023
14 Likes
Answer
POS
Reason — The substring() method returns a substring beginning from the startindex and extending to the character at endIndex - 1. Since a string index begins at 0, the character at index 3 is 'P' and the character at index 5 (6-1 = 5) is 'S'. Thus, "POS" is extracted.
Answered By
9 Likes
Related Questions
Predict the output of the following code snippet:
String P = "20", Q ="22"; int a = Integer.parseInt(P); int b = Integer.valueOf(Q); System.out.println(a + " " + b);- 20
- 20 22
- 2220
- 22
The String class method to join two strings is:
- concat(String)
- <string>.joint(string)
- concat(char)
- Concat()
int x = (int)32.8; is an example of …………… typecasting.
- implicit
- automatic
- explicit
- coercion
The code obtained after compilation is known as:
- source code
- object code
- machine code
- java byte code