Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
AP Computer Science A/Unit 2: Using Objects
Start Practice TestPractice Test
About Exam
easy Solved by 11 students

String indexOf Method

Mark
< Prev
Next >

Which statement should replace // Missing line in the code segment below to correctly find and assign the starting index of the substring "Java" to the variable index?

public class SubStringSearch {
    public static void main(String[] args) {
        String sentence = "I love programming in Java";
        // Missing line
        System.out.println("Index: " + index);
    }
}
A

int index = sentence.indexOf(“programming”);

B

int index = sentence.indexOf(“in Java”);

C

int index = sentence.indexOf(“Java”);

D

int index = sentence.indexOf(“java”);

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total Time
Score
#1kaisuki11 0m 00s 100
#2Potter1611 0m 11s 89
#3liuwilliam07241011 0m 17s 83
#4cphong200911 0m 30s 70
#5pandasiteitei11 1m 13s 27
#6bommasam00011 1m 22s 18
#7lsj0803092211 1m 37s 3
#8richa.tuli01 1m 30s -100
#9y.seong202712 4m 33s -183
#10jeonsaw172311 16m 03s -863
Items per page:
10
1 – 10 of 11

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy|