Java String Constructors Quiz

SmittenSerenity avatar
SmittenSerenity
·
·
Download

Start Quiz

Study Flashcards

Questions and Answers

Which constructor in the String class creates an empty string?

String str = new String();

What is the purpose of the String constructor String(byte[] bytes)?

To create a new String by decoding the specified array of bytes using the platform's default charset.

Which constructor is used to create a String object with the same sequence of characters as a specified StringBuffer?

String str = buffer.toString();

Which constructor creates an empty string?

<p>String str = new String();</p> Signup and view all the answers

Which constructor creates a string with the specified content?

<p>String str = new String(&quot;Hello World&quot;);</p> Signup and view all the answers

Which constructor creates a string with the same content as the given StringBuffer object?

<p>String str = new String(new StringBuffer(&quot;example&quot;));</p> Signup and view all the answers

More Quizzes Like This

Java String Class Methods
12 questions
Java String Class and Operations Quiz
18 questions
Use Quizgecko on...
Browser
Browser