Multiple choice technology web technology

What following line of code returns "unhappy".substring(2)

  1. a. "un"

  2. b. "unh"

  3. c. "happy"

  4. d. None of the above

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

String.substring(index) returns characters starting from the specified index to the end. For "unhappy", index 0='u', 1='n', 2='h', so substring(2) returns "happy". Remember that string indexing is zero-based in Java.