Multiple choice

What will be the output of the program? String a = "newspaper"; a = a.substring(5,7); char b = a.charAt(1); a = a + b; System.out.println(a);

  1. apa

  2. app

  3. apea

  4. apep

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

Both substring() and charAt() methods are indexed with a zero-base, andsubstring() returns a String of length arg2 - arg1.