-
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);
-
- strbuilder .append(“pqr”); str.concat(“pqr”);
- strbuilder .append(“pqr”); str1 = str1.concat(“pqr”);
- strbuilder .append(“pqr”); str.append(“pqr”);
- strbuilder .concat(“pqr”); str.append(“pqr”);
- 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.