Which of the following will compile successfully?

Last Updated :
Discuss
Comments

Which of the following will compile successfully?

Java
StringBuffer sb = "Hello";

No, it will not compile

Yes, it will compile

Yes, but with a warning

Only if sb is declared as final

Share your thoughts in the comments