1.
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);
    }
}

2.
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);
    }
}

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

5.
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());
    }
}

7.
What will be the output of the following Java code?
class output 
{
    public static void main(String args[])
    { 
       String s1 = "Hello";
       String s2 = new String(s1);
       String s3 = "HELLO";
       System.out.println(s1.equals(s2) + " " + s2.equals(s3));
    }
}

Read More Section(Strings)

Each Section contains maximum 100 MCQs question on Strings. To get more questions visit other sections.