1(xiv)
To extract the word NOW from the word "ACKNOWLEDGEMENT", the Java statement "ACKNOWLEDGEMENT".substring(3, ...............) is used.
Choose the correct number to fill in the blank.
- (a)6
- (b)7
- (c)5
- (d)8
Show SolutionHide Solution↓
6
Reason — The method substring(beginIndex, endIndex) extracts characters from the starting index up to (but not including) the ending index. In "ACKNOWLEDGEMENT", the word "NOW" starts at index 3 (N) and ends at index 5 (W). Since the ending index is exclusive, we use 5 + 1 = 6 to include index 5. Hence, substring(3, 6) correctly extracts "NOW".