Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!

Michael Marr

Greenhorn
+ Follow
since Sep 06, 2016
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Michael Marr

I checked the online errata list @ selikoff.net before posting and it's not listed there.

Michael
It's OCA: Oracle® Certified Associate Java® SE 8 Programmer I Study Guide Exam 1Z0-808 by Jeanne Boyarsky, Scott Selikoff.

The question referred to, quetion 9, is in the Review Questions at the end of Chapter 4. It looks to me like an error too, that's why I posted it.

Michael



On p.206 in Chapter 4 Methods and Encapsulation, Table 4.5 'Rules for JavaBeans Naming Conventions' gives the following rule:

The method name must have a prefix of set/get/is, followed by the first letter of the property in uppercase, followed by the rest of the property name.

Ouestion 9 in the Review Questions on that chapter asks the following:

Which are methods using JavaBeans naming conventions for accessors and mutators?
(Choose all that apply)

One of the answers given as correct in the answers on p344 is answer C which is:


So, the property name is 'numberWings' not 'numWings'. Surely, for this answer to be correct C should be:


Or maybe some rules are just made to be broken?

Michael



Under the heading 'charAt(), indexOf(), length(), and substring()' it states that:

"These four methods work exactly the same as in the String class.".

However I've noticed from running the subsequent 5 lines of code that indexOf(char ch) does not compile with the StringBuilder class. In other words you can't pass a character as a parameter to 'indexOf), it will only compile, with the StringBuilder class, if you pass it a string.

So, the line:will not compile if it is written as...ie if you substitute the character 'a' for the string "a" in the first occurence of sb.indexOf()