Juerg Bauman

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

Recent posts by Juerg Bauman

Page 548 - explanation#22:

5: Locale.setDefault(new Locale("en", "AU"));
The three lines printed by the code are ko, en_US and en.

It should be: ... ko, en_AU and en.
Page 309 - question#21:

It should be:  ... new File("C:/students.data") or new File("C:\\students.data")
Page 457 - explanation#36:

Finally, the declaration of thursday does not compile because the final modifier cannot appear before the access modifier.

Above declaration of thursday compiles without any problem.
The correct answer should therefore be: B instead of C
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.
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 549 - explanation#14: not an error, just a clarification

F does compile because Runnable is an interface. In theory, someone could subclass Chipmunk and have the subclass implement

This works only because Chipmunk is not final. If you change Chipmunk to final or use an immutable class like String, "str instanceof Runnable" results in compiler error.
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 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 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?
Mock exam#3 - question about what is stored in Duration:
The explanation says hours/minutes/seconds, which is incorrect. There is a difference between storing and accessing.
JavaDoc states:

This class models a quantity or amount of time in terms of seconds and nanoseconds.
It can be accessed using other duration-based units, such as minutes and hours.
getNano(): The length of the duration is stored using two fields - seconds and nanoseconds.

By the way, this online Mock Testing Tool only offers a "Next Question"-button, there is no way to move backwards with a "Previous Question"-button.
Mock exam#2 - the question with System.console / Writer / append:
It's the same topic as mentioned earlier. It's true that the Writer append() method throws an IOException, for compile time reasons this exception has to be catched/declared.
But the instance is of type PrintWriter, its append() is overridden and no IOException can be thrown.
The Option E: An IOException may be thrown is incorrect.
Writer readline() could throw an IOError, not Exception.
Page xliii - Assessment Test #11:

C. magic(Stream.iterate(1, x ->> x++)); ...
D. ...

I'm not sure wether the lambdas in option C and D are incorrect intentionly or it's just a typo.
Page 542 - explanation#2:

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

just a typo
Page 361 - question#18:

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

It should be: select from books ...
Page 565 - explanation#5:

The append() method throws an IOException.

The Console method writer() returns PrintWriter, its append() is overridden and does not throw any checked exceptions anymore.
JavaDocs says to PrintWriter:

Methods in this class never throw I/O exceptions, ...