String s = "banana";
System.out.println(s.indexOf('a'));What is printed?
- A
5
- B
0
- C
3
- Dcheck_circle
1
Explanation
indexOf returns the index of the first occurrence; the first 'a' in "banana" is at index 1.
AP Computer Science A· difficulty 3/5
String s = "banana";
System.out.println(s.indexOf('a'));What is printed?
5
0
3
1
Explanation
indexOf returns the index of the first occurrence; the first 'a' in "banana" is at index 1.
Want 10 more like this — adaptive to your weak spots?