[Logo]
Forums Register Login
Sybex OCA OCP Practice Test - Errata
Chapter 1 - question 39: (page 13 and 431)

Answer D is correct, since the extension of a source file is .java.
But the explanation is incorrect:

The proper extension for a Java compiled bytecode file is .java


The extension of the compiled bytecode file is .class
Agreed the answer explanation is incorrect (luckily the answer was right). I've logged it in the errata. Thanks for noticing and reporting this.
Chapter 2 - question 27: (page 24 and 435)
Answer B is correct.
But the explanation to the incorrect answer C is strange:

C. You can convert a wrapper class object to a primitive by calling valueOf().


... because this method is used for converting to a wrapper class from a String ...


There is an overloaded Integer.valueOf( int i) which converts primitive to wrapper.
Therefore answer C is wrong because it converts primitive to wrapper, and not vice versa wrapper to primitive.
Chapter 2 - question 32: (page 25 and 435)
The explanation states:

A. Assuming the variables are not primitives ...


A String instance variable (variable containing a reference to a String object?) is never primitive, wrigth?
Chapter 2 - explanation to question 47: (page 436)

Options A and B are static methods rather ...


A and B are incorrect method declarations, since the position of "static" between return type and method-name is wrong.
 

Juerg Bauman wrote:Chapter 2 - question 27: (page 24 and 435)
Answer B is correct.
But the explanation to the incorrect answer C is strange:

C. You can convert a wrapper class object to a primitive by calling valueOf().


... because this method is used for converting to a wrapper class from a String ...


There is an overloaded Integer.valueOf( int i) which converts primitive to wrapper.
Therefore answer C is wrong because it converts primitive to wrapper, and not vice versa wrapper to primitive.


There are two signatures of Integer.valueOf() - one takes a String which is the one the answer alludes to. The other takes a primitive. So neither convert a wrapper class to a primitive.

Remember that the practice tests book is designed to be used with/after a study guide for the exam. It covers the simplified view of the world that is on the OCA exam. For example, page 135 of our OCA book covers the valueOf method with Strings. It does not talk about using it for primitives. And that makes sense. There's no reason for the exam to ask you about calling valueOf to convert from a primitive to an object when you could just use autoboxing. This method was way more useful prior to Java 5.

In any case, we both agree the answer is B!
 

Juerg Bauman wrote:Chapter 2 - question 32: (page 25 and 435)
The explanation states:

A. Assuming the variables are not primitives ...


A String instance variable (variable containing a reference to a String object?) is never primitive, wrigth?



Correct. That explanation is talking about the general case. It's a delicate balance writing explanations that both explain the question and are useful. Disagreeing on where that balance is doesn't make something an errata . Again, we both agree the answer is A.
 

Juerg Bauman wrote:Chapter 2 - explanation to question 47: (page 436)

Options A and B are static methods rather ...


A and B are incorrect method declarations, since the position of "static" between return type and method-name is wrong.


While this doesn't affect the answer, I agree it is an errata and have logged it in our errata list
On page 450, explanation 31:

The outer loop decrements i i, making it 0.


There are too many i's int this line.
On page 456, explanation 32:

The class contains two constructors and one method.


It should be: The class contains one constructor and two methods.
Confirmed and logged both. Thanks.
Chapter 9 - question 22: (page 141)
a reference variable s is used without declaring its type. This question cannot be answered like that, one needs to know that s is of type String.
On page 475 - explanation 36:

Predicate is an interface with one method.


It should say: ... interface with one abstract method.
 

Juerg Bauman wrote:Chapter 9 - question 22: (page 141)
a reference variable s is used without declaring its type. This question cannot be answered like that, one needs to know that s is of type String.


That question is correct. The class that "s" is a type of has the methods contains(), equals() and startsWith(). How many classes did you learn for the OCA? I can only think of one.

Juerg Bauman wrote:On page 475 - explanation 36:

Predicate is an interface with one method.


It should say: ... interface with one abstract method.


True. I'll add it to our private list of things that could be clearer.
On page 9, question 22:

The explanation declares above line 3 as valid definition for a method, and therefore as correct answer.
This is incorrect since the terminal semicolon is missing.
 

Juerg Bauman wrote:On page 9, question 22:

The explanation declares above line 3 as valid definition for a method, and therefore as correct answer.
This is incorrect since the terminal semicolon is missing.


You don't need a semicolon for a method without any statements in it.
Chapter 11 - question 23: (page 197/489)

Option A is allowed because the turnOn() method is public and can be called from anywhere.


This is not correct. The class com.light.Flashlight has no access modifier (=package-protected) and is therefore not visible by any class in package com.dark.
The correct answers should be: A and C
Can the class that method is in be subclassed as a public class? If so, can that method become accessible?
(0 likes, 1 cow)
Page 492 - explanation 14:

For these reason, Options A, C ...


typing error --> For these reasons ...
Page 492 - explanation 15:

Finally, enum constructors must be private, meaning ...


The constructor for an enum type must be package-private or private access.
Page 505 - explanation #31:

B. The ToDoubleFunction interface takes a generic value, not a double value, making
Option D incorrect. It also uses the method name accept().


It should be: ... It uses the method applyAsDouble().
Page 549, explanation #30:

Line 10 is incorrect.


The incorrect code is on line 9.
Page 537 - explanation 15:

If the code was fixed to use the correct method name, then it would complete without issue, ...


There is another error, since f.get() throws checked exceptions, which have to be caught or declared.
This doesn't affect the correct answer, which remains B.
Page 538, explanation #21:

The result is it may output 0, 1000, or anything in-between ...


Just a typo...
Page 538, explanation #23:

If count was marked static, then the application would sum the elements correctly, ...


The variable count is a primitive of type int and several threads are updating it. To avoid race condition it should be declared as AtomicInteger instead of int?
Page 540 - explanation #33:

If push() had been used instead of offer() in the third loop, with new values being inserted at
the tail of the queue instead of at the head, ...


It's the opposite: If offer() had been used instead of push() ...
Page 302 - question#4:

Which methods are classes that implement java.io.Serializable required to implement?


I'm not english native, but something is wrong with that sentence.
Page 304 - question#10:

For a given file, the absolute is the path from ...
... while the relative path is the path from ...


Typo: For a given file, the absolute path is the path ...
Page 196 - question#21 (singleton pattern):
It's just a doubt, probably not an error.

It's about the instance variable which is not declared final. According to your Study Guide, instance should be static final (unless lazy instantiation).
Otherwise there is no method inside the class capable to reassign instance. I suggest you could loose some words in your explanation, that it is ok to omit the final keyword in this case.
Page 494 - explanation #29:

C. Dinosaur.new Pterodactyl();
...
Option C is incorrect. Pterodactyl is a member inner class, not a static nested class.


Option C is not working even for static nested classes. The correct syntax would be: new Dinosaur.Pterodactyl() or just new Pterodactyl()
Page 504 - explanation #22:

The method reference is used for Supplier, not Consumer, since it takes a value and does not return anything.


It should be reverse: ... is used for Consumer, not Supplier, ...
On page 345 - question #19: not an error, just a suggestion

I was surprised that this line actually did compile, because execute() takes a Runnable with return type void. The method getAnswer() has return type String.
The explanation: https://coderanch.com/t/690723/java/ExecutorService-execute-Runnable
Possibly I didn't get that fact earlier, maybe you could add it to your explanation.
Page 523 - explanation#15:

Finally, because both can be used with a byte array, Option D is incorrect.


OutputStream uses byte[], while Writer uses char[].
Page 361 - question#18:

Given the table books in the figure...
...
select * from cert where title = 'OCA'


It should be: select from books ...
Page 542 - explanation#2:

... so the creators of the exam iare free to ...


just a typo
Page 410 and 558 - question#49:

E. Two objects that return true for equals() will always return 0 when passed to compareTo().
...
Option E is incorrect because multiple comparators can use different orders for comparison, which do
not need to match the definition of equality.


The method compareTo() belongs to Comparable which is implemented on the class being compared.
There can be only one implementation, which should follow the contract: compareTo should return 0 if equals returns true.
So answer E should be true, but not always will...
By the way is " ... multiple comparators" meant with Uppercase Comparators?
Page 561 - explanation#67:
there is a fourth error on line 12, since Function apply() takes just one argument, not two.
The answer remains correct: E
Page 562 - explanation#80:

while any class that does not is unchecked and must be declared or handled.


It should be: ... does not is checked and must ...
Page 496 - explanation#2:

Option C is incorrect because the replace() method is available on List, ...


There is no such method available in List, there is one called replaceAll().
Page 452 - explanation#4:

... and trying to output a void return type in the print() method throws an exception at runtime.


The result is a compiler error, not an exception at runtime.

This thread has been viewed 1794 times.

All times above are in ranch (not your local) time.
The current ranch time is
Nov 19, 2018 08:16:56.