[Logo]
Forums Register Login
Sybex OCP Java 8 Study Guide - Page 346
On page 346:

ScheduledFuture<V> is identical to the Future<V> class, except that it includes a
getDelay() method that returns the delay set when the process was created.



The API_documentation states about the getDelay() method:

Returns the remaining delay associated with this object, in the given time unit.
Returns:
the remaining delay; zero or negative values indicate that the delay has already elapsed

 
Correct. I checked with Scott and he said the delay decreases over time as execution approaches.
on page 563 - explanation to exercise 10:

The problem here is that c1 is a String but c2 is an int, 


It's the opposite way: c1 is an int, and c2 a String.
On page 401 - exercise 17:
there is an import statement which is incomplete, the code doesn't compile

import java.util.concurrent.*;



You must add: import java.util.concurrent.atomic.*;
 

Juerg Bauman wrote:on page 563 - explanation to exercise 10:

The problem here is that c1 is a String but c2 is an int, 


It's the opposite way: c1 is an int, and c2 a String.


Agreed. This is already listed on our errata page.

Juerg Bauman wrote:On page 401 - exercise 17:
there is an import statement which is incomplete, the code doesn't compile

import java.util.concurrent.*;



You must add: import java.util.concurrent.atomic.*;


The instructions on the exam tell you to assume any required imports are there. So missing imports are not errata.
On page 469:

Luckily, Java provides us with the normalize(Path)


normalize() is an instance method and doesn't take a Path argument.
Confirmed and added to the errata. Thanks!
On page 477: the example with newBufferedWriter
it's not really an error, just a needless line of code:

List<String> data = new ArrayList();


List data isn't needed anywhere in that example.
On page 484:

The first method, Files.readAttributes(), returns a read-only view ...
...The second method, Files.getFileAttributeView(), returns


In the previous pages you always mentioned the complete method signatures, incl. parameters.
So in this case it should be:
Files.readAttributes(Path, Class<V>)
Files.getFileAttributeView(Path, Class<A>)
Juerg,
Neither of those are errors. Inconsistencies, sure. But not errors.
on page 571, explanation to question 20:

...the path value after the first line is just the current directory symbol.



The path value after normalize() is empty, so doesn't contain the current directory symbol --> path.toString().isEmpty() outputs true.
Nevertheless getNameCount() results in 1 and the answer B is correct.
True. We meant logically. I'll add that to our private list of things that could be clearer.
On page 551, explanation 7:

D is incorrect, as adding settings is the opposite ...


It should say: ... adding setters ...
Agreed and logged in the errata. Thank you!
On page 191:

The findAny() and findFirst() methods return an element of the stream unless the stream is empty.
If the stream is empty, they return an empty Optional.


These methods return an Optional in any case, wether the stream is empty or not.
It sould be something like: ... methods return an Optional wrapping an element of the stream ...
On page 193:

This code snippet is intended to fail, anyway. Stream s is defined without generics and raw typing shouldn't be used anymore.
So better would be: Stream<Integer> s = ...
. . . or an explanation of the unchecked compiler warning?
 

Juerg Bauman wrote:On page 191:

The findAny() and findFirst() methods return an element of the stream unless the stream is empty.
If the stream is empty, they return an empty Optional.


These methods return an Optional in any case, wether the stream is empty or not.
It sould be something like: ... methods return an Optional wrapping an element of the stream ...


You are correct that they return an optional with the element. It's not an errata because were were talking colloquially.

Juerg Bauman wrote:On page 193:

This code snippet is intended to fail, anyway. Stream s is defined without generics and raw typing shouldn't be used anymore.
So better would be: Stream<Integer> s = ...


Also, not an errata. It doesn't compile with Stream or Stream<Integer>

Campbell Ritchie wrote:. . . or an explanation of the unchecked compiler warning?


There's no warning because it doesn't compile.
On page 565, explanation 1:

...use BufferedReader/BufferedWriter directly on a stream.


it should be: ... directly on a Stream. 
( or Stream class)
stream is a concept there. Which is fine in lowercase.
Something went wrong with the last update of https://www.selikoff.net/java-ocp-8-programmer-ii-study-guide/ ;
pages 483ff: one double entry, one entry missing the original 483)
On page 511:

The UPDATE statement changes one or more rows in the database:
The DELETE statement deletes one or more rows in the database:


In both cases it should be: ... zero or more rows ...  as shown one page earlier:

UPDATE: Change zero or more rows in the table
DELETE: Remove zero or more rows from the table

 
 

Juerg Bauman wrote:On page 511:

The UPDATE statement changes one or more rows in the database:
The DELETE statement deletes one or more rows in the database:


In both cases it should be: ... zero or more rows ...  as shown one page earlier:

UPDATE: Change zero or more rows in the table
DELETE: Remove zero or more rows from the table


Confirmed and added to the errata.
On page 91, Figure 2.9:
The name of the class "ZooKeeper" declared in the factory pattern example doesn't match with figure 2.9, where the same class is called "Client". The other class names are identical in description and figure.
 

Juerg Bauman wrote:On page 91, Figure 2.9:
The name of the class "ZooKeeper" declared in the factory pattern example doesn't match with figure 2.9, where the same class is called "Client". The other class names are identical in description and figure.


The diagram is referring to the generic concept of a Client/caller.
On page 154:

16: String str = "abc";
17: Predicate<String> methodRef2 = str::startsWith;
...
Line 17 shows that we want to call string.startsWith()


It should be: ... to call str.startsWith()
I am afraid somebody else has beaten you to it and found that last misprint last week.
On page 247: Working with Durations

A Duration is stored in hours, minutes, and seconds.


JavaDoc states about Duration:

This class models a quantity or amount of time in terms of seconds and nanoseconds.



This is the reason why above Duration doesn't remember its original input of 3600s and prints the calculated value of 1H.
Period is different: it actually stores years, month, days.
On page 331/332:

Then you start the task by using the Thread.start() method.


...make sure that you remember to start the task with the Thread.start() method.


The start() method of Thread is an instance method, not a static one.
On page 333 - Real World Scenario

Implementing Runnable allows the class to be used by numerous Concurrency API classes.


Above quote is valid for both options: extending the Thread class and implementing Runnable.
Since the Thread class implements the Runnable Interface, Thread IS A Runnable, also.
re threds:
In the Real World Scenario, you are correct. That's not the point were are trying to make. From the context, it is about why Runnable is often better. And with Thread.sleep, it's like writing ArrayList.add - we are expressing the class the method is on, not implying that it is static.
re duration - that's true. We meant logically.
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards


This thread has been viewed 569 times.

All times above are in ranch (not your local) time.
The current ranch time is
Jan 16, 2018 17:57:08.