Knowee
Questions
Features
Study Tools

Which of the following are incorrect form of StringBuffer class constructor?ans.StringBuffer(String str)StringBuffer(int size)StringBuffer(int size , String str)StringBuffer() Previous Marked for Review Next

Question

Which of the following are incorrect form of StringBuffer class constructor?ans.StringBuffer(String str)StringBuffer(int size)StringBuffer(int size , String str)StringBuffer() Previous Marked for Review Next

🧐 Not the exact question you are looking for?Go ask a question

Solution

The incorrect form of StringBuffer class constructor is:

StringBuffer(int size , String str)

This is not a valid constructor for the StringBuffer class in Java. The valid constructors are:

  • StringBuffer(): Constructs a string buffer with no characters in it and an initial capacity of 16 characters.
  • StringBuffer(int capacity): Constructs a string buffer with no characters in it and the specified initial capacity.
  • StringBuffer(String str): Constructs a string buffer initialized to the contents of the specified string.

This problem has been solved

Similar Questions

Write a short note on StringBuffer class in java

Out of these classes, which one is used for reading strings and characters in Java from the console?1 point(a) StringReader(b) BufferedReader(c) InputStreamReader(d) BufferedStreamReader

Which class is commonly recommended for string manipulation when performance is not a primary concern?a)StringBufferb)StringManipulatorc)StringBuilderd)String

What will be the output of the following Java program? package pkg; class output {public static void main(String args[]) {   StringBuffer s1 = new StringBuffer("Hello");   s1.setCharAt(1, x);   System.out.println(s1);   } }

StringBuffer is used to create  ______________.Select one:a.an immutable Stringb.a mutable String

1/2

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.