Computer Applications

Output of the following statement is …………… .

System.out.println("WONDERFUL".substring(3,4));

  1. DERF
  2. NDER
  3. D
  4. N

Java String Handling

9 Likes

Answer

D

Reason — The function substring(startindex, endindex) returns a substring which begins from startindex and ends at endindex - 1.

Here, "WONDERFUL".substring(3,4) returns a substring which begins at startindex 3 and ends at endindex - 1, i.e., 4 - 1 = 3. The character at index 3 is D.

Answered By

4 Likes


Related Questions