Home » JAVA Programming » Strings » Question
  1. In the below code, which code fragment should be inserted at line 3 so that the output will be: “234pqr 234pqr”?

    1. StringBuilder strbuilder = new StringBuilder("234");
    2. String str = "234";
    3. // insert code here
    4. System.out.println(strbuilder + " " + str);
    1. strbuilder .append(“pqr”); str.concat(“pqr”);
    2. strbuilder .append(“pqr”); str1 = str1.concat(“pqr”);
    3. strbuilder .append(“pqr”); str.append(“pqr”);
    4. strbuilder .concat(“pqr”); str.append(“pqr”);
    5. None of these
Correct Option: B

append() is stringbuffer method and concat is String class method.
append() is stringbuffer method and concat is String class method.



Your comments will be displayed only after manual approval.