387). Which of these class is used to create an object whose character sequence is mutable?

[A]String()
[B]StringBuffer()
[C]String() & StringBuffer()
[D]None of the mentioned

Show Answer

390). What is the string contained in s after following lines of Java code?
StringBuffer s new StringBuffer("Hello");
s.deleteCharAt(0);

[A]Hell
[B]ello
[C]Hel
[D]llo

Show Answer

391). Which of the following statement is correct?
StringBuffer s new StringBuffer("Hello");
s.deleteCharAt(0);

[A]reverse() method reverses all characters
[B] reverseall() method reverses all characters
[C] replace() method replaces first occurrence of a character in invoking string with another character
[D] replace() method replaces last occurrence of a character in invoking string with another character

Show Answer

392). What will be the output of the following Java program?
    class output 
    {
        public static void main(String args[])
        {
            String a = "hello i love java";
            System.out.println(a.indexOf('e')+" "+a.indexOf('a')+" "+a.lastIndexOf('l')+" "+a.lastIndexOf('v'));
        }
    }

[A]6 4 6 9
[B]5 4 5 9
[C]7 8 8 9
[D] 1 14 8 15

Show Answer

393). What will be the output of the following Java program?
   class output 
    {
        public static void main(String args[])
        { 
             StringBuffer c = new StringBuffer("Hello");
             c.delete(0,2);
             System.out.println(c);
        }
    }

[A]He
[B]Hel
[C]lo
[D]llo

Show Answer

394). What will be the output of the following Java program?
    class output 
    {
        public static void main(String args[])
        { 
             StringBuffer c = new StringBuffer("Hello");
             StringBuffer c1 = new StringBuffer(" World");
             c.append(c1);
             System.out.println(c);
        }
    }

[A]Hello
[B]World
[C]Helloworld
[D]Hello World

Show Answer

395). What will be the output of the following Java program?
    class output 
    {
        public static void main(String args[])
        { 
           StringBuffer s1 = new StringBuffer("Hello");
           StringBuffer s2 = s1.reverse();
           System.out.println(s2);
        }
    }

[A]Hello
[B]olleH
[C]HelloolleH
[D]olleHHello

Show Answer

396). What will be the output of the following Java program?
    class output 
    {
       class output 
       {
         public static void main(String args[])
         {
            char c[]={'A', '1', 'b' ,' ' ,'a' , '0'};
            for (int i = 0; i < 5; ++i)
            {
                   i++; 
                   if(Character.isDigit(c[i]))
                       System.out.println(c[i]+" is a digit");
                   if(Character.isWhitespace(c[i]))
                       System.out.println(c[i]+" is a Whitespace character");
                   if(Character.isUpperCase(c[i]))
                       System.out.println(c[i]+" is an Upper case Letter");
                   if(Character.isLowerCase(c[i]))
                       System.out.println(c[i]+" is a lower case Letter");
                   i++;
            }
        }
    }

[A] a is a lower case Letter is White space character
[B] b is a lower case Letter is White space character
[C] 1 is a digit a is a lower case Letter
[D] a is a lower case Letter 0 is a digit

Show Answer