398). 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

Show Answer

399). Which of this method of class StringBuffer is used to reverse sequence of characters?
StringBuffer s1 = "one";
StringBuffer s2 = s1.append("two")

[A]reverse()
[B]reverseall()
[C]Reverse()
[D]reverseAll()

Show Answer

400). Which of this method of class StringBuffer is used to get the length of the sequence of characters?
StringBuffer s1 = "one";
StringBuffer s2 = s1.append("two")

[A]length()
[B]capacity()
[C]Length()
[D]Capacity()

Show Answer

401). Which of the following are incorrect form of StringBuffer class constructor?
StringBuffer s1 = "one";
StringBuffer s2 = s1.append("two")

[A]StringBuffer()
[B]StringBuffer(int size)
[C]StringBuffer(String str)
[D]StringBuffer(int size , String str)

Show Answer

402). 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

Show Answer

403). 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

Show Answer

404). 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

Show Answer

405). 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

Show Answer

406). 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

Show Answer