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

Given:

What is the result?

    Correct Answer: B

    The method trim() in Java removes leading and trailing whitespace from the string but does not affect spaces between words. The given string 'Java SE 8 1' contains no leading or trailing whitespace, so the trim() method does not modify it. The length of the string 'Java SE 8 1' is 11 characters including spaces. Therefore, the correct answer is 11.

Discussion
Zafar_NasimOption: D

D is correct because trim() only removes leading and lagging spaces.

haisaco

No trim() just remove space on first and last string

carlosworkOption: B

Answer is B. String s = "Java SE 8 1"; int len = s.trim().length(); System.out.print(len);

tawa_z58Option: B

Answer is B trim() removes only begining and end white spaces of a string

iSnoverOption: B

See the code: public static void main (String[] args) { String s = "Java SE 8 1"; int len = s.trim().length(); System.out.print(len); }

JoseCG

Correct.

Jess1985BOption: B

Answer is B - 11. Just calculate spaces before and after string.

haisacoOption: B

Answer is B.

dsmsOption: B

Answer is: 11

iSnoverOption: D

D is correct, because trim remove only spaces and remember, can't be 8 because is true that Java indexes form 0, but not in case of count de size of String. I tested

archer1903Option: D

Tested D. 9

lilzOption: D

String s = "Java Duke"; int len = s.trim().length(); System.out.println(len); D