Choosing how to earn college credit? CLEP vs AP guide
| preferred AP College board partner for AP classes
hard Solved by 58 students

Java String Method Analysis

Mark
< Prev
Next >

Consider the following processWords method. Assume that its String parameters, word1 and word2, each have a length of two or more.

public void processWords(String word1, String word2) {
    String str1 = word1.substring(0, 2);
    String str2 = word2.substring(word2.length() - 1);
    String result = str2 + str1;
    System.out.println(result.indexOf(str2));
}

Which of the following best describes the value printed when processWords is called?

A

The value 0 is always printed.

B

A substring containing the last two characters of word2 is printed.

C

A substring containing the last character of word2 is printed.

D

The value result.length() - 1 is printed.

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
#1varunrajaram122 - 200
#2malaikashahid50122 0m 14s 186
#3l.alzahrani0411 - 100
#4avantikaabaid1090111 - 100
#5sgarv251311 - 100
#6tuba.azarkan11 0m 01s 99
#7testsss111 0m 02s 98
#8mlhkrds11 0m 13s 87
#9liuwilliam07241011 0m 17s 83
#10zhenmunse11 0m 27s 73
Items per page:
10
1 – 10 of 60
No comments yet. Be the first to comment!

AI Tutor

How can I help?

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