Home » Java Programming » Java.lang Class

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);

Correct Answer: app

Explanation:

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

← Previous Question Next Question→

More Questions from Java.lang Class

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion