b) Substring()
c) SubString()
d) None of the mentioned
2. What will s2 contain after following lines of Java code?
StringBuffer s1 = "one";
StringBuffer s2 = s1.append("two")
a) one
b) two
c) onetwo
d) twoone
3. Which of this method of class StringBuffer is used to reverse sequence of characters?
a) reverse()
b) reverseall()
c) Reverse()
d) reverseAll()
4. Which of this method of class StringBuffer is used to get the length of the sequence of characters?
a) length()
b) capacity()
c) Length()
d) Capacity()
5. Which of the following are incorrect form of StringBuffer class constructor?
a) StringBuffer()
b) StringBuffer(int size)
c) StringBuffer(String str)
d) StringBuffer(int size , String str)
6. What will be the output of the following Java code?
class output
{
public static void main(String args[])
{
StringBuffer c = new StringBuffer("Hello");
System.out.println(c.length());
}
}
a) 4
b) 5
c) 6
d) 7
7. What will be the output of the following Java code?
class output
{
public static void main(String args[])
{
StringBuffer sb=new StringBuffer("Hello");
sb.replace(1,3,"Java");
System.out.println(sb);
}
}
a) Hello java
b) Hellojava
c) HJavalo
d) Hjava
8. What will be the output of the following Java code?
class output
{
public static void main(String args[])
{
StringBuffer s1 = new StringBuffer("Hello");
s1.setCharAt(1,'x');
System.out.println(s1);
}
}
a) xello
b) xxxxx
c) Hxllo
d) Hexlo
9. What will be the output of the following Java code?
class output
{
public static void main(String args[])
{
StringBuffer s1 = new StringBuffer("Hello World");
s1.insert(6 , "Good ");
System.out.println(s1);
}
}
a) HelloGoodWorld
b) HellGoodoWorld
c) HellGood oWorld
d) Hello Good World
10. What will be the output of the following Java code?
class output
{
public static void main(String args[])
{
StringBuffer s1 = new StringBuffer("Hello");
s1.insert(1,"Java");
System.out.println(s1);
}
}
a) hello
b) java
c) Hello Java
d) HJavaello
Answer & Explanation
at, ul, consectetur
iciturur laoree
Fusce, consectetu
lestiefacilisis.
iciturac, dictum vitae odio. Donec aliquet.
risusce d
ec facipsum dolo
, dictu, consec
usce duicitur laoreet. Nam
inia pulec facilisis
gue
Unlock full access to Course Hero
Explore over 16 million step-by-step answers from our library
Subscribe to view answer
Step-by-step explanation
leamet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque d
gue
iacongue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dol
gue
acifacilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie co
gue
, cur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac m
gue
dicdictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam
gue
fmolestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsu
gue
remur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec alique
gue
tctum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor
gue
ces a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem
gue
ce dat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum