String s = "abcdef";
System.out.println(s.substring(0, s.length()));What is printed?
- Acheck_circle
abcdef
- B
abcde
- C
Error
- D
bcdef
Explanation
substring(0, length()) returns the entire string; it is legal because the end index can equal length().
AP Computer Science A· difficulty 4/5
String s = "abcdef";
System.out.println(s.substring(0, s.length()));What is printed?
abcdef
abcde
Error
bcdef
Explanation
substring(0, length()) returns the entire string; it is legal because the end index can equal length().
Want 10 more like this — adaptive to your weak spots?