Possible errata in Practice Exam 2, OCA: Oracle Certified Associate Java SE 8 Programmer I Study Guide: Exam 06Z0-808
There is a question about true statements regarding String and StringBuilder. One of them is:
For a StringBuilder, capacity would be a redundant property.
The exam scores that statement as false. I say that the statement is true, because you already have access to the capacity() method. You could use the capacity() method without ever needing the capacity property. Hence, adding a property for capacity adds no value, and is superfluous/redundant. This may be a matter of semantics, but I think that my answer deserves credit.
That's not an errata. If there weren't a capacity property, there wouldn't be a capacity method either. That answer is right after whether capacity is redundant for String, which is it.
On the real exam, you know how many choices are correct. But try not to read into the questions. Since the String/StringBuffer answers are paired, it's fairly obvious the choices are about the difference between the two rather than subtle implications of the English language.
David Quinn wrote:For a StringBuilder, capacity would be a redundant property.
The exam scores that statement as false. I say that the statement is true, because you already have access to the capacity() method.
For what it's worth, I agree with Jeanne on this one. From the context of the question (and the different statements), it should be really obvious that this question is testing you about the differences between the String and StringBuilder classes. The actual exam tells you how many answers are correct. If answers are borderline correct, choosing the best answer becomes an important skill. And then the "context of a question" could be (very) important. In this thread you'll find a nice discussion about this "context of a question", it's definitely worth reading.