In The Following Java Code Which Code Fragment Should Be #373
In the following Java code, which code fragment should be inserted at line 3 so that the output will be: “123abc 123abc”?</p> <pre><code class="language-java"> 1. StringBuilder sb1 = new StringBuilder("123"); 2. String s1 = "123"; 3. // insert code here 4. System.out.println(sb1 + " " + s1);</code></pre>
This multiple choice question (MCQ) is related to the book/course gs gs128 Java. It can also be found in gs gs128 Java String Handling - String Comparison in java - Quiz No.1.
In the following Java code, which code fragment should be inserted at line 3 so that the output will be: “123abc 123abc”?
1. StringBuilder sb1 = new StringBuilder("123"); 2. String s1 = "123"; 3. // insert code here 4. System.out.println(sb1 + " " + s1);
sb1.append(“abc”); s1.append(“abc”);
sb1.append(“abc”); s1.concat(“abc”);
sb1.concat(“abc”); s1.append(“abc”);
sb1.append(“abc”); s1 = s1.concat(“abc”);