What is the result of the following expression scharAt1 if t

What is the result of the following expression: s.charAt(1) if the following statement has been executed:

String s = new String(\"Arizona_State_University\");

Arizona_State_University

\'r\'

\'_\'

\'i\'

none of these

Arizona_State_University

\'r\'

\'_\'

\'i\'

none of these

Solution

Answer: \'r\'

String s = new String(\"Arizona_State_University\");

In above string object, characters index will start from 0 to length minus 1.

In above string, 0 index indicates \'A\' and 1 index indicates \'r\'

What is the result of the following expression: s.charAt(1) if the following statement has been executed: String s = new String(\

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site