Jos Roseboom

Greenhorn
+ Follow
since Aug 29, 2020
Cows and Likes
Cows
Total received
1
In last 30 days
0
Total given
0
Likes
Total received
4
Received in last 30 days
0
Total given
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jos Roseboom

Congratulations Please search for “Wall of Fame” and add your name.


Thanks. I found and did.
Hi Jeanne,

thanks for your explanations and judging my findings.

There is one finding you didn't judge: https://coderanch.com/t/734474/certification/Sybex-Java-OCP-Programmer-II . Do you agree with the reply of Thomasz there? I've had some Enthuware questions that try to trick me into the difference of autoboxing/unboxing.

Also, have a cow for the detailed and useful errata reports!


Thanks. I've always loved cows.

And good luck on the exam.


Thanks. I passed the exam last Friday.



Some more issues not mentioned on https://www.selikoff.net/ocp11-2/ from Java OCP 11 Programmer II Study Guide:

page 469, question 11: the questions mentions execution deleteTree("/storage"). This should be deleteTree(new File("/storage")).
page 473, question 22: ...created on line 15 => ...created on line 17
page 491, the tip: On the exam, when you see Files.resolve() => Path.resolve()
page 511, Walking a Directory with walk(), first sentence: Steam API => Stream API
page 514, table 9.6: nest.gif => wings.gif
page 525, question 18: the questions asks about possible results. If the directory consists solely of .java files, all files are printed. B is a possible answer.
page 607, question 7: stmt.executeQuery(sql) is called on a PreparedStatement. Since sql contains a bind variable, a SQLException is thrown. This still makes the correct answer F, but since the explanation did not mention throwing an exception, I guess the code should be stmt.executeQuery()
page 608, question 12, answer says whitelist, but should be blacklist? : The code checks a condition. If the condition is true, an exception is thrown to block the protected code. This seems the recipe for Blacklist, not for Whitelist (which checks on a condition to be true and only if so runs the protected code)

Those two sentences don't actually contradict each other.


They do not contradict, but the reasoning is not in line with eachother, which could be confusing.
Some issues not mentioned on https://www.selikoff.net/ocp11-2/ from Java OCP 11 Programmer II Study Guide:

page 200, 4rd sentence: The noneMatch() method also returns false because one matches. => 2 match. Although you could argue that one match would be enough to result in false, this would not be in line with sentence 2 "The anyMatch() method returns true because two of the three elements match"  
page 326, just above figure 6.9: Notice the new module zoo.tickets.discount => the newly introduced module here is named zoo.tickets.etech
page 362, first sentence of the section "Submitting Task Collections": The last two methods listed in Table 7.2 that... => that should be table 7.1
page 375: section title "Applying a ReentrantLock Interface" ReentrantLock is a class. I guess this should either be something like "Applying a Lock Interface" or "Applying the ReentrantLock Class"
On page 163 in Exam Essentials, the part Use autoboxing and unboxing ends with Character is autoboxed into char . This should be  Character is unboxed into char
Thanks for your elaborate answer. Your explanation is not different than my understanding on which I based my idea that the conclusion was wrong.

My whole point is that the premiss/conclusion does not fit:

You might be sorting Product objects by name, but names are not unique. Therefore, the return value of compareTo() might not be 0 when comparing two equal Product objects, so this compareTo() method is not consistent with equals().

For 2 products to be equal, their id has to be equal. For two objects to have compareTo returning not 0, their name must be different. So, to have not 0 from compareTo from two equal object, there must be objects with the same id, but different names.

This could be the case if ids are not unique. If this is true, the part 'Therefore, the return value of compareTo() might not be 0 when comparing two equal Product objects, so this compareTo() method is not consistent with equals().' is correct, but the uniqueness of names (premiss) has nothing to do with it. Besides this, ids being not unique is counter intuitive. Maybe my assumption in my original post 'Returning not 0 for equal objects would occur if 2 objects with the same id have a different name, which is not what is meant here I guess.' was wrong and it is what is meant here. There is never stated that the id field is unique for this product, but I just assumed that.

The explanation in the book on Comparable feels very clear to me, but I just cannot fit this example into it.
I added a bit to the original post. It all refers to the page 140/141 section Keeping compareTo() and equals() Consistent

On page 129 in the section on Map.of() and Map.copyOf() is the fragment:



Right below that fragment the first line says:

This code compiles but throws an error at runtime.
Just after the example compareTo method on top of page 141:

You might be sorting Product objects by name, but names are not unique. Therefore, the return value of compareTo() might not be 0 when comparing two equal Product objects, so this compareTo() method is not consistent with equals().

The consequence of the names not being unique seems that compareTo() returns 0 for non-equal objects instead of the other way around. Returning not 0 for equal objects would occur if 2 objects with the same id have a different name, which is not what is meant here I guess.

The Product class referred to here has an id (int) and a name (String). It implements Comparable<Product>. The compareTo method compares the names (return this.name.compareTo(obj.name);) where the equals method compares the id's (this.id == obj.id if obj is an instance of Product).
The text on Map.of says Map.of("key1", "value1", "key2"); compiles and throws runtime error, but it does not compile. Map.of is only overloaded with even parameter numbers https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Map.html
Hi Scott,

Thanks for sharing this. I am a bit lost what to do now.

I have my OCA 8 and my plan was to get the 816 exam. Now I am in doubt with 2 options:

- study hard and take 816 before October
- wait and take 819 when it arrives

For 816 I can focus on the harder study material. But will passing the 816 be considered less valuable than passing 819?

What is your advise on this matter?

Thanks,
Jos