Discussion Forum : Introduction To Methods And Streams
Question -


What is the output of this program?


class output {
public static void main(String args[])
{
StringBuffer c = new StringBuffer("Hello");
System.out.println(c.length());
}
}
Options:
A .  4
B .  5
C .  6
D .  7
Answer: Option B

length() method is used to obtain length of StringBuffer object, length of "Hello" is 5.
Output:
$ javac output.java
$ java output
5




Was this answer helpful ?
Next Question
Submit Your Solution hear:

Your email address will not be published. Required fields are marked *