Question
1 StringBuilder sb1 = new StringBuilder("123");
2 String s1 = "123";
3 // insert code here
4 System.out.println(sb1 + " " + s1);
a.
sb1.append(“abc”); s1.append(“abc”);
b.
sb1.append(“abc”); s1.concat(“abc”);
c.
sb1.concat(“abc”); s1.append(“abc”);
d.
sb1.append(“abc”); s1 = s1.concat(“abc”);
Posted under Java Programming
Engage with the Community - Add Your Comment
Confused About the Answer? Ask for Details Here.
Know the Explanation? Add it Here.
Q. In the below code, which code fragment should be inserted at line 3 so that the output will be: “123abc 123abc”?
Similar Questions
Discover Related MCQs
Q. Which of the following are incorrect form of StringBuffer class constructor?
View solution
Q. Which of this method of class StringBuffer is used to get the length of the sequence of characters?
View solution
Q. Which of this method of class StringBuffer is used to reverse sequence of characters?
View solution
Q. Which of these methods of class StringBuffer is used to extract a substring from a String object?
View solution
Q. Which of the following statement is correct?
View solution
Q. Which of these method of class StringBuffer is used to find the length of current character sequence?
View solution
Q. Which of this method of class StringBuffer is used to concatenate the string representation to the end of invoking string?
View solution
Q. Which of these class is used to create an object whose character sequence is mutable?
View solution
Q. Which of the following statement is correct?
View solution
Q. What is the value returned by function compareTo() if the invoking string is greater than the string compared?
View solution
Q. Which of these method of class String is used to remove leading and trailing whitespaces?
View solution
Q. Which of this method of class String is used to extract a substring from a String object?
View solution
Q. Which of these data type value is returned by equals() method of String class?
View solution
Q. Which of these methods of class String is used to check whether a given object starts with a particular string literal?
View solution
Q. Which of these methods is used to compare a specific region inside a string with another specific region in another string?
View solution
Q. Which of these method of class String is used to compare two String objects for their equality?
View solution
Q. Which of these method of class String is used to extract more than one character at a time a String object?
View solution
Q. Which of these is an incorrect statement?
View solution
Q. Which of these method of class String is used to extract a single character from a String object?
View solution
Q. Which of this method of class String is used to obtain a length of String object?
View solution
Suggested Topics
Are you eager to expand your knowledge beyond Java Programming? We've curated a selection of related categories that you might find intriguing.
Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!