KnowledgeBoat Logo
|

Computer Applications

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.

  1. 6
  2. 7
  3. 5
  4. 8

Java String Handling

2 Likes

Answer

7

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 6 + 1 = 7 to include index 5. Hence, substring(3, 7) correctly extracts "NOW".

Answered By

1 Like


Related Questions