Ask Question
14 July, 05:51

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

+4
Answers (1)
  1. 14 July, 08:05
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers