Ask Question
15 July, 18:03

What would be the results of executing the following code? StringBuilder str = new StringBuilder ("Little Jack Horner "); str. append ("sat on the "); str. append ("corner"); A. The program would crash. B. str would reference "Little Jack Horner ". C. str would reference "Little Jac Horner sat on the ". D. str would reference "Little Jack Horner sat on the corner".

+3
Answers (1)
  1. 15 July, 18:11
    0
    Correct answer is option (D) that is, str would reference "Little Jack Horner

    sat on the corner".

    Explanation:

    StringBuilder are the objects which can be modified like strings object. It will first create a string builder and initialize with "Little Jack Horner". Then it will append string "sat on the " to initial string. In the last it will append string "corner" to the initial string. So in this way, str will have a string "Little Jack Horner sat on the corner ".
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “What would be the results of executing the following code? StringBuilder str = new StringBuilder ("Little Jack Horner "); str. append ("sat ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers