| 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 12 students
String indexOf Method
< 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(“Java”);

B

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

C

int index = sentence.indexOf(“in 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
Time
Score
#1kaisuki11 0m 00s 100
#2liuwilliam07241011 0m 17s 83
#3cphong200911 0m 30s 70
#4bommasam00011 1m 22s 18
#5lsj0803092211 1m 37s 3
#6richa.tuli01 1m 30s -100
#7y.seong202712 4m 33s -183
#8jeonsaw172311 16m 03s -863
#9chunxiangxu.cxu22 31m 05s -1,665
Items per page:
10
1 – 9 of 9
No comments yet. Be the first to comment!

AI Tutor

How can I help?

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