# OCA Study Guide Errata

## ERRATA

Chapter Page Details

Introduction xxxix Errata in text Corrections in Book and Online: In Point number 1: Currently reads: a_b defaults to a null value Should read: \$ defaults to 0 In Point number 3: ‘Puma is invalid’ should be ‘Cougar is invalid’ for the explanation for D ‘E is incorrect’ should be ‘E is correct’ In Point number 4: The first bullet should say ‘starts’ rather than ‘continues’ ‘With y taking a new value’ should be ‘With count taking a new value’ Also, in the second bullet, 1 + 4 should say 1 + 5.

Introduction xli Errata in Text Point Number 10 currently reads:Reference one points to g1 Should read:Reference two points to g2 Point Number 13 currently reads:D and E are correct Should read:D and E are incorrect

Introduction xlii Errata in text Corrections in Book and Online: Point number 16: Currently Reads: ‘because an interface may inherit two abstract methods with the same signature’ Should Read: ‘because a class may inherit two abstract methods with the same signature’

1 Chapter 1 Errata in text eBook Correction Only: In some of the review questions, the line break is missing between the code that would be in different files. You can assume that each package statement starts a new file.

1 4 Errata in text Corrections in Book Only: ‘each of these five words is in’ should be ‘each of these six words is in’

1 8 Errata in text The code currently reads: Zoo.mainmethod(Zoo.java:7) Should Read: Zoo.main(Zoo.java:4)

1 10 Errata in text In the fourth line of the second paragraph, ‘From example’ should be ‘For example’.

1 12 Errata in text Corrections in Book Only: ‘java.nio.files.Paths’ should be ‘java.nio.file.Paths’ Note:This change should carried out in two instances

1 18 Errata in text Corrections in Book Only: The middle code block should have } instead of { on line 5.

1 30 Errata in text The compiler error message at the top of the page should refer to line 7 rather than line 5.

1 31 Errata in text At the end of the second paragraph, ‘simplest type it can give the value’ should be ‘simplest value it can give the type’

2 53 Errata in text Corrections in Book Only: On the first line of table 2.1, ~ should be in the other unary operators section. And on the last line of the table, !=, should be |=.

2 54 Errata in text Corrections in Book Only: In ‘resulting in a value of x of 7. Make sure you understand why the result is 24’, the 7 should be 14

2 54 Errata in text Corrections in Book Only: In ‘int x = 2 * ((5 + 3) * 4 - 8); This time you would evaluate the addition operator 10 + 3’, the 10 should be 5.

2 57 Errata in text Corrections in Book Only: In the second sentence, ‘multiplied’ should be ‘divided’

2 61 Errata in text Corrections in Book Only: 9l should be 9f on the first row

2 62 Errata in text Corrections in Book Only: Currently Reads: The compound operator will first cast x to a long Should Read: The compound operator will first cast y to a long

2 64 Errata in text Corrections in Book Only: Figure 2.1 says ‘true tables’ rather than ‘truth tables’

2 69 Errata in text ‘block of statement’ should be ‘block of statements’

2 71 Errata in text The first code example shouldn’t have ‘final’ so the ternary operator is equivalent.

2 72 Errata in text Corrections in Book Only: Remove ‘As of Java 7’ from the first sentence

2 73 Text Correction ‘int’ and ‘Integer’ is listed twice in the bulleted list.

2 82 Errata in text Corrections in Book Only: In the first example on the page, System.out.println(x) should be removed.

2 82 Errata in text Corrections in Book Only: In the first example, ‘y and z were both long’ should be ‘In the multiple terms example, y and z were both long’

2 83 Errata in text Corrections in Book Only: Figure 2.8 says ‘semicolon’ rather than ‘colon’ when pointing to a colon

2 83 Errata in text Corrections in Book Only: In Figure 2.8, the title should be ‘enhanced for-each statement’ rather than ‘enhancement for statement’

2 86 Errata in text Corrections in Book Only: values[i]-values[i-1] should be (values[i]-values[i-1]) + “,”

2 91 Errata in text Corrections in Book Only: In table 2.5, the second table header should be ‘Allows unlabeled break’

2 96 Errata in text Corrections in Book and Online: In Point number 8: Choice E should be changed to ‘None of the above’

3 107 Errata in text Corrections in Book Only: int indexOf(char ch) should be int indexOf(int ch) and int indexOf(char ch, index, fromIndex) should be int indexOf(int ch, int fromIndex) int indexOf(String str, index fromIndex) should be int indexOf(String str, int fromIndex).

3 107 Errata in text Corrections in Book Only: ‘int substring’ should be ‘String substring’ in both substring methods

3 108 Errata in text Corrections in Book Only: Currently reads: toLowerCase(String str) Should read: toLowerCase() Currently Reads: toUpperCase(String str) Should Read: toUpperCase()

3 108 Errata in text Corrections in Book Only: Currently Reads: because the indexes can be backward Should Read: because the indexes can’t be backward

3 109 Errata in text Corrections in Book Only: boolean equals(String str) should be boolean equals(Object obj) Note: You only have to know about String for the exam

3 111 Text Correction Currently reads: Animal Should read: AnimAl

3 111 Errata in text Corrections in Book Only: In the third paragraph, there is a stray quote. “‘C’ should be ‘C’

5 115 Errata in text Corrections in Book Only: On line 6, the line should have a dash at the end

3 118 Errata in text Corrections in Book Only: In the code example, line 7 should have been t1 == t3.

3 120 Errata in text Corrections in Book Only: On the first line, ‘set all the elements’ should be ‘all elements are set’

3 124 Errata in text Corrections in Book Only: import java.util.* should be import java.util.*;

3 124 Errata in text Currently Reads: Using the length variable Should Read: using the length field

3 124 Errata in text Currently Reads: \ L System.out.print Should Read: System.out.print

3 125 Errata in text Corrections in Book Only: In the last paragraph, ‘line 5 searches for the index of 1’ should be ‘line 6’

3 126 Errata in text Corrections in Book Only: In the first paragraph, ‘line 3 gave the wrong answer’ should be line 7.

3 126 Errata in equation Corrections in Book Only: int numbers = should be int[] numbers =

3 126 Errata in text Corrections in Book Only: In the last paragraph of the Autoboxing section, ‘outputs 1’ should be ‘outputs[1]’

3 129 Errata in equation Corrections in Book Only: import java.util.* should be import java.util.*;

3 141 Errata in text Corrections in Book Only: Currently Reads: public static LocalDateTime of(LocalDate date, LocalTime) Should Read: public static LocalDateTime of(LocalDate date, LocalTime time)

3 141 Errata in text Corrections in Book Only: Month.January, 32) should be Month.January, 32);

3 143 Errata in text Corrections in Book Only: LocalDateTime.of(date2 should be LocalDateTime.of(date

3 146 Errata in text Corrections in Book Only: toEpochTime should to toEpochSecond

3 147 Errata in text Corrections in Book Only: Currently Reads: wrong = Period.ofWeeks(7); Should Read: wrong = Period.ofWeeks(1);

3 148 Errata in text Corrections in Book Only: System.out.println(date.format(DateTimeFormatteer.ISO_LOCAL_DATE)); should have a line break immediately before “System”

3 150 Errata in text Corrections in Book Only: ‘dd means to include the leading zero for a single-digit month’ should be ‘dd means to include the leading zero for a single-digit day’

4 168 Errata in text Corrections in Book Only: ‘And since it is optional, you can’t have any of them at all.’ should be ‘And since it is optional, you are allowed to not have any of them at all.’

4 170 Errata in text Corrections in Book Only: Currently Reads: int long() {] Should Read: int longMethod(){

4 172 Errata in text Corrections in Book Only: Currently Reads: Walk1() is a valid method declaration without an empty method body. Should Read: Walk1() is a valid method declaration with an empty method body.

4 172 Errata in text Corrections in Book Only: Currently Reads: public void walk2; Should Read: public void walk2();

4 173 Errata in text Corrections in Book Only: Currently Reads: Line 20 calls a vararg parameter two parameters Should Read: Line 20 calls a vararg method with two parameters.

4 179 Errata in text ‘Bird is not a subclass of Bird’ should say ‘Bird is not a subclass of Goose’

4 181 Errata in text Table 4.2 INCORRECT: superclass CORRECT: subclass

4 184 Errata in text Corrections in Book Only: Currently Reads: public static average Should Read: public static double average

4 184 Errata in text Corrections in Book Only: In Table 4.3, the empty ‘How?’ cell should be ‘Not without instantiating the object’

4 188 Errata in text Corrections in Book Only: Currently Reads: 4: newNumber(5) Should Read: 4: newNumber(num)

4 191 Errata in text Corrections in Book Only: In the third paragraph, fifth sentence, ‘numbers’ should be ‘number’

4 191 Errata in text Corrections in Book Only: In the first sentence of the overloading methods section, it should say ‘same name’ not ‘same signature’

4 192 Errata in text Corrections in Book Only: Currently Reads: everything other than the method signature can vary for overloaded methods Should Read: everything other than the method name can vary for overloading methods

4 192 Errata in text Corrections in Book Only: Currently Reads: public void fly(int numMiles) { System.out.println(“short”); Should Read: public void fly(int numMiles) { System.out.println(“int”);

4 194 Errata in text Insert spaces after the answer text, preferably using double quotes, such as: [Start of First paragraph] The answer is "string object " [Start of Third paragraph] The answer is "int long ". [Middle of Third paragraph] parameter list, the output becomes "long long ".  (Note the spaces before the second double quotes in each of the three corrections.)

4 199 Errata in text Corrections in Book Only: Currently Reads: When overloading methods, the method name and parameter list needed to match. Should Read: When overloading methods, the method name needs to match

4 203 Errata in text Corrections in Book Only: In the third sentence ‘lines 4 and 5’ should be ‘lines 4, 5 and 6’ when referring to the static initializer

4 204 Errata in text Corrections in Book Only: After ‘output Torchie.’, it should say ‘Line 6 then outputs 1.’

4 206 Errata in text Corrections in Book Only: In Table 4.5, ‘Getter methods begin with is if the property is a boolean’, should be ‘Getter methods begin with is or get if the property is a boolean’ ‘Line 14 doesn’t follow the JavaBeans naming conventions. Since playing is a boolean, the getter must begin with is’ should be ‘Line 14 is correct. SInce playing is a boolean, getter is allowed to begin with get or is’

4 209 Errata in text Corrections in Book Only: ‘that that’ has a duplicate word on the seventh line

4 210 Errata in text Corrections in Book Only: Currently Reads: 1: public class TraditionalSearch Should Read: 1: import java.util.*; public class TraditionalSearch

4 211 Errata in text Corrections in Book Only: ‘Java replies’ should be ‘Java relies’.

4 211 Errata in text Corrections in Book Only: a -> a.canHop(); should be a -> a.canHop()

4 213 Errata in text Corrections in Book Only: ‘Lambdas are allowed to access variables’ is in the real world scenario twice. The first sentence should be removed.

4 216 Errata in text Corrections in Book Only: In the summary section, (a -> a.equals(b) has an extra open paren. It should be a-> a.equals(b)

4 219 Errata in text Corrections in Book and Online: In Point number 7: ‘ClassRoom’ should be ‘Classroom’ In the line 6, “Mrs. Anderson” should be “Mrs. Anderson”

4 222 Errata in text Corrections in Book and Online: In Point number 11: Answers D and E should have an extra space at the end

4 226 Errata in text Corrections in Book and Online: In Point number 19: In the choice G, the closing } is missing

4 229 Errata in text In Point number 25: 1000L should be 100L. This does not affect the correct answer.

4 229 Errata in text Corrections in Book and Online: In Point number 25: Answers A through D should have an extra space at the end

5 237 Errata in text In the first paragraph after the note, second sentence: Remove “subclass or “ in the sentence. Updated sentence should read as: “The default package private modifier, which is the lack of any access modifier, indicates the class can be accessed only by a class within the same package”

5 239 Errata in text Corrections in Book Only: ‘user’ should be ‘use’ in ‘Notice the user of both super() and super(age)’

5 246 Errata in text Corrections in Book Only: “a method a method” should be “a method”

5 247 Errata in text Corrections in Book Only: The numbers output should be 50.0 and 70.0, not 50.00 and 70.00

5 249 Errata in text Corrections in Book Only: ‘The return type void is not a subclass of int’ is reversed. Swap int and void in the sentence

5 249 Errata in text In the last paragraph, ‘on the example’ should be ‘on the exam’

249 Errata in Text Currently reads:’constructor to a constructor’ Should read: ‘method to a method’

5 254 Errata in text Corrections in Book Only: ParentClassName.method() should be super.method()

5 261 Errata in text Corrections in Book Only: In the first sentence, ‘brackets’ should be ‘braces’.

5 263 Errata in text The second to last sentence in the second paragraph should read ‘The key point is that the first concrete class to extend the abstract class must implement all inherited abstract metthods’.

5 265 Errata in text In the First numbered list entitled “Abstract Class Definition Rules”, item #3: Add ‘protected’ to the list of items in the sentence. The words, private/protected/final - should use Inline Code font. Updated sentence should read as: “Abstract classes may not be marked as private, protected, or final.”

5 267 Errata in text Corrections in Book Only: Point number 4 should be - All top-level interfaces areassumed to have public or default access. They are assumed to be abstract whether this keyword is used or not. Therefore, making a method private, protected or final will trigger a compiler error as it is incompatible with these assumptions.

5 269 Errata in text Corrections in Book Only: ‘using the extend keyword’ should be ‘using the extends keyword’

5 272 Errata in text Corrections in Book Only: The second Bear class should have //DOES NOT COMPILE on line 1 as well.

5 274 Errata in text Corrections in Book Only: ‘The compile will’ should be ‘The compiler will’

5 285 Errata in text Corrections in Book Only: At the bottom of the page, the coding ‘Feeding reptile’ should be ‘Feeding:’

5 276 Errata in text Corrections in Book Only: At the bottom of the page, ‘the following class’ should say ‘the following interface’

5 291 Errata in text Corrections in Book and Online: In Point number 2: Choice E should reference line 7, not line 8

5 294 Errata in text Corrections in Book and Online: In Point number 10: In choice C, ‘extend’ should be ‘extends’

5 295 Errata in text Corrections in Book and Online: In Point number 13: The { is missing on line 1 of the provided code

301 Errata in Text Currently reads:’at mainmethod.Zoo.main(Zoo.java:7)’ Should read: ‘at Zoo.main(Zoo.java:4)’

6 312 Errata in text Corrections in Book Only: “There aren’t any, so the main method throws that new exception” should be “This exception is caught on line 23.”

6 313 Errata in text Corrections in Book Only: Lines 35, 37 and 42 should have a space before the final quote on the line

6 314 Errata in text Corrections in Book Only: In the ClassCastException section, ‘cast an exception to a subclass’ should be ‘cast an object to a subclass’

6 317 Errata in text Corrections in Book Only: ‘Common runtime exceptions’ should be ‘Common checked exceptions’

335 Errata in text Corrections in Book and Online: In Point number 14: In the explanation currently reads: ‘Option B is incorrect because package names are case sensitive’ Should read: ‘Option C is incorrect because package names are case sensitive’

338 Errata in text In Point number 14: In the explanation currently reads: ‘The value of result is computed by adding 4 to the original value of 8’ Should Read: ‘The value of result is computed by adding 8 to the original value of 4’ In Point number 18: The answer should be B (not A)

338 Errata in text Corrections in Book and Online: Corrections in Book and Online: In Point number 17: The explanation should say ‘keep going remains true’ rather than ‘keep going is false’

339 Errata in text Corrections in Book and Online: In Point number 2: The explanation should say ‘Line 8 also compares references but is true since both references point to the object from the string pool. Finally, line 9 compares one object from the string pool with one that was explicitly constructed and returns false.’

340 Errata in text Corrections in Book and Online: In Point number 10: The explanation should say ‘The if statement on line 18 returns true because’ rather than ‘The if statement on line 18 returns true’ In Point number 4: In the explanation, abbbaa has an extra b. There should only be two b’s.

341 Errata in text Corrections in Book and Online: In Point number 14: The explanation should say ‘Option B does not reverse the string’ rather than ‘Option B is a nice distraction resulting avaJ’ The explanation should say ‘starting with 0’ rather than ‘starting with 1’

342 Errata in text Corrections in Book and Online: In Point number 26: The explanation should say ‘The code does compile’ rather than ‘The code does not compile’

Appendix A 344 Errata in text Corrections in Book and Online: In Point number 9: A,C,E. Options B and D are incorrect because they don’t follow the naming convention of beginning with get/is/set. Options C and E follow normal getter and setter conventions. Option A is correct, but the book doesn’t explain this and is out of scope for the exam so give yourself credit if you answered C and E. Note: The ‘get/is/set’ within the explanation should be styled as Inline Code.

344 Errata in text Corrections in Book and Online: In Point number 10: should say ‘swing ‘ instead of ‘swing’ (missing space)

344 Errata in text Corrections in Book and Online: We autobox to objects so it should say ‘can be autoboxed to a Boolean’ rather than ‘boolean’ and ‘autoboxed to a Double’ rather than ‘double’

344 Errata in text Corrections in Book and Online: In Point number 17: ‘pass by reference’ should be ‘pass by value’

345 Errata in text Corrections in Book and Online: In Point number 23: In the explanation, ‘created on line 4’ should be ‘created on line 12’ and ‘created on line 5’ should be ‘created on line 13’

346 Errata in text Corrections in Book and Online: In Point number 2: The last sentence of the explanation should be removed

347 Errata in text Corrections in Book and Online: In Point number 8: In the first sentence of the explanation, ‘public and static’ should be ‘public, static and final’

347 Errata in text Corrections in Book and Online: In Point number 3: ‘CanHope’ should be ‘CanHop’

348 Errata in text Corrections in Book and Online: In Point number 18: In the explanation, ‘since int is not a subclass of String’ should be ‘since String is not a subclass of int’

350 Errata in text Corrections in Book and Online: In Point number 8: ‘try try’ should be ‘the try’