Ask Question
28 November, 17:33

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".

+5
Answers (1)
  1. 28 November, 18:39
    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?
Get 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 there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers