Mark Kevin

Ranch Hand
+ Follow
since Sep 09, 2015
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 Mark Kevin

It's not complicated. The online mock exam # 2 grades the following incorrectly because E. is wrong due to the fact that the lambda is missing the return statement, and F. as not correct. But that's backwards.

E. caller((0) -> {5}); [correct]
F. caller((0) -> {return 5;}); [not correct]

But the authors got it right. They identified E. as incorrect (because no return) and F. as correct. That's all I'm saying. It's a software glitch they might want to correct through the errata. One of the problems is trying to identify the question because they don't have fixed numbers or page numbers in the bonus exams. But the authors should be able to identify it with the information provided above. Just trying to be helpful.


It's not listed in the errata, and it's not in the book. It's part of Sybex's online mock exams, an extra bonus exam. They don't even use question numbers in the errata because they can be randomized and shuffled. Hence, it's difficult identifying the exact question. But the authors should be able to locate it with the information I provided.

I'm working through Bonus Exam # 2, a question about lambdas, and according to what they reported, E and F are reversed. In other words, the authors' answer is correct, but the software graded it incorrectly. This is the solution to the question which might help you identify it:

"C, F.
Since the interface doesn’t take any parameters, we need to pass an empty parameter list. Option A is incorrect because it does not specify a parameter list. Options B and D are incorrect because they pass one parameter. Option E is incorrect because the return keyword is missing."

But while E is missing the return keyword, when graded, it tells me it is okay, and F, where there is the return keyword, is incorrect. That's backwards.

E. caller((0) -> {5});
F. caller((0) -> {return 5;});

I don't know if you have control over the software glitch that grades it, but they have it wrong. Your answer is correct, though.


You should also know what happens if you call binarySearch() on an unsorted array/list.

It produces an unpredictable result, as per the book. Thanks.

Okay, so for the exam I'm expected to know that println(String) doesn't throw IOException. That's pretty granular. So you can't catch a checked exception unless there is code in the try block which might throw that checked exception, which includes a call to a method that might throw a checked exception. The reason is that the catch is unreachable, it would never get used. And declaring throws IOException in main wouldn't make a difference. Thanks. This clears up my confusion about unreachable code.

I suppose it would help if I typed in the code.

Maybe it's because it's the second to the last question in the book and my eyes are blurry, but the answer on # 19 reads, "Option B is not allowed because the method called inside the try block doesn't declare an IOException to be thrown." But what method is called inside the try block? All I see is a println(). Is that what they are referring to? It's question 19 on p. 331. How is the IOException an unreachable catch block? Totally confused. Sorry if I'm missing the obvious.

Thanks, Jeanne. It threw me off as well. I feel like I'm breaking the law holding an illegal copy in my hands. The part that bothers me is the "Indian context." What the heck does that mean? I don't speak Hindi. And I might have a problem answering the online question to get access if the pages don't line up exactly. When I unwrap the shrink wrap I'll let you know what I find. I don't think Amazon will be pleased about this.


Through Amazon, a third party seller sent me an Indian version of this book. On the front it has the statement, "Illegal for Sale in USA" and on the back it says, "Special India Edition. The content of this book may have been modified to suit Indian context." Needless to say I'm not happy as I'm in the USA which they should know simply by looking at the mailing address.

So, can the authors tell me how different this version is from an American/English version, and has any American (English as a first language) in the USA used it to pass the exams? I don't want to return it but will.

Thanks, Henry. That makes sense. The book didn't explain it as well as you did.

I see it now. I thought writeLock() constructed an instance, but it only "Returns the lock used for writing." So it returns the same lock. Okay. Thanks.

I'm studying for the ocp 7 exam and have been hung up on one thing for quite some time. This code on p. 796 uses a ReentryReadWriteLock (rwl) to acquire a lock using rwl.writeLock().lock(), but then in releasing or unlocking the lock it creates ANOTHER lock to unlock it (rwl.writeLock().unlock(). However it thereby is unlocking a lock it has not acquired but unlocking a completely different lock which should throw an exception. Shouldn't it be unlocking the same lock used to acquire the lock initially?

Thanks for any insight.


I can't find the publisher's website errata page either, but it hasn't been listed on coderanch's errata page. Also, it would make much more sense and be clearer if the interface snippet BookDao on p. 558 directly preceded class Student on page 557. It really threw me off.

I believe the third object they left out was class Student referred to on page 557? Then it would be one interface and three objects, a) Student, b) InMemoryBookDao. and c) Book.

Confused. Why does the first sentence of the first paragraph refer to there being three objects, when there are only two that I can see. The first is an interface BookDao which by definition isn't an object, not an instance of the interface. Shouldn't it be two objects and one interface?

Just wondering.