Exam 1z0-819 All QuestionsBrowse all questions from this exam
Question 77

Given:

What is the result?

    Correct Answer: E

    When the program is executed, the main method calls the foo method and passes a StringBuilder with the value 'hey'. Inside the foo method, the input StringBuilder ('hey'), the string ' oh ', and the static StringBuilder 'sb2' ('hi ') are printed. The foo method then returns a new StringBuilder with the value 'ey', which is appended to the static StringBuilder 'sbl' ('yo'). So the print output is 'hey oh hi' followed by 'yo ey'. Therefore, the output of the program is 'hey oh hi yo ey'.

Discussion
d7bb0b2Option: E

The correct answer is E. "hey oh hi yo ey" The foo method in the StrBldr class is called within the main method with a StringBuilder argument of "hey". Inside the foo method, it prints s ("hey"), " oh ", and sb2 ("hi "), then returns a new StringBuilder with "ey". After the foo method is called, the returned StringBuilder ("ey") is appended to sbl ("yo "). So, the final output of sbl is "yo ey". Therefore, the output of the program is the concatenation of the print inside the foo method and the print of sbl in the main method, which is "hey oh hi yo ey".

tmuralimanoharOption: E

Answer: E

StavokOption: E

E is correct TESTED