About Question com.enthuware.ets.scjp.v6.2.438 :

All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.

Moderators: Site Manager, fjwalraven

Post Reply
ETS User

About Question com.enthuware.ets.scjp.v6.2.438 :

Post by ETS User »

Which of these are not part of the StringBuffer class?
choose 2
trim( )
ensureCapacity(int )
append(boolean )
reverse( )
setLength(int)

trim() and setLength(int) were the correct answers.

In the explaination of the answer it says the following:
public void setLength(int newLength)
Sets the length of this String buffer. This string buffer is altered to represent a new character sequence whose length is specified by the argument. For every nonnegative index k less than newLength, the character at index k in the new character sequence is the same as the character at index k in the old sequence if k is less than the length of the old character sequence; otherwise, it is the null character '' (\u0000). In other words, if the newLength argument is less than the current length of the string buffer, the string buffer is truncated to contain exactly the number of characters given by the newLength argument.
If the newLength argument is greater than or equal to the current length, sufficient null characters ('\u0000') are appended to the string buffer so that length becomes the newLength argument.
The newLength argument must be greater than or equal to 0.
Parameters:
newLength - the new length of the buffer.
Throws:
IndexOutOfBoundsException - if the newLength argument is negative.

Is this an error or am I missing something about the answer?

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question com.enthuware.ets.scjp.v6.2.438 :

Post by admin »

You are right. setLength() should not be a correct answer. Should be fixed asap.

thank you!
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests