Exam 1z0-808 All QuestionsBrowse all questions from this exam
Question 209

Given the code fragment:

What is the result?

    Correct Answer: C

    C

Discussion
UAK94Option: A

Answer is A. Because String str is "Sweet Sweat" not "Sweet sweat" String str="Sweet Sweat"; String str2=str.trim().charAt(6)+" " + str.indexOf("Sw",1); System.out.println(str2); // S 6

akbiyikOption: A

Answer is A. S 6

carlosworkOption: A

Answer is A.

iSnoverOption: C

The answer is the letter C, it is a little complicated but analyzing the code we managed to answer the question ignoring the difficult part. Looking at "str.indexOf("Sw",1)" we can see that it wants to know what is the position of the first "Sw" that appears in the String content and we can see that it is at position 1. The only alternative that prints the 1 in the second position of the string "str2" is the C option.

Jess1985B

A is correct, tested.