Home / Questions / Give the output of the following program
Explanatory Question

Give the output of the following program

👁 22 Views
📘 Detailed Answer
🕒 Easy to Read
Read the answer carefully and go through the related questions on the right side to improve your understanding of this topic.

Answer with Explanation


class MainString
{
    public static void main(String args[])
    {
        StringBuffer s = new StringBuffer("String");

        if (s.length() > 5 && s.append("Buffer").toString().equals("X"))
        {
            // empty statement
        }

        System.out.println(s);
    }
}

Output:


StringBuffer