Khalid A. Mughal

author
+ Follow
since Jul 30, 2002
Khalid likes ...
Java
Merit badge: grant badges
Biography
Khalid A. Mughal is associate professor (emeritus) in the Department of Informatics, University of Bergen, Norway. During his extensive career, he has designed and implemented many courses on Java, object-oriented system development, web application development, software security, and compiler techniques. He has also given seminars for the IT industry. He is the principal author of several books on Java.
For More
Bergen, Norway
Cows and Likes
Cows
Total received
12
In last 30 days
0
Total given
0
Likes
Total received
33
Received in last 30 days
0
Total given
13
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Khalid A. Mughal

Hi, exactly which book are you talking about?
If it is the OCP Oracle Certified Professional Java SE 17 Developer (Exam 1Z0-829) Programmer's Guide, clicking on the title will take you to the publisher's website where you can find information about the PDF version of the book.
Hi, Gouri.

Sincerely hope the book continues to be useful.
Look forward to your questions or any other feedback on the book.

All the best!
-- khalid
Hi,

I am sure the publisher can be asked to send a code to download the ebook. No waiting, in other words. 😀👍
Congratulations to the winners!
If you get the book, you will never run out of  conversation topics at the dinner table.
Sincerely hope you will post an unbiased review at your favorite pub, restaurant, takeaway, bus stop, gym, website, ranch, and bookstore. 🙏🏼

Lastly, I want to thank Coderanch for hosting the promo for our book and all who participated in the lively discussions in the different thread these past 4 days. I picked up a few pointers as well.

Hope to drop in on the ranch frequently, and will not be a stranger.

All the best in your endeavor to ace the Java certification exam.

Sincere thanks!
— Khalid
Hi,

See if the explanation below makes sense for the results you are seeing.

Consider this method:
T reduce(T identity, BinaryOperator<T> accumulator)
This method on a parallel stream uses the accumulator as a combiner (i.e. for combining partial results).

The accumulator and the combiner must satisfy the following relationship for any t1 and t2:
combiner.apply(t1, accumulator.apply(identity, t2)) == accumulator.apply(t1, t2)

In the code:
    System.out.println(List.of(1,2,3,4,5)
     .parallelStream()
     .reduce(0, (a,b) -> (a-b)));

The identity value is 0 and the accumulator is (a,b) -> (a-b).
For t1 = 1 and t2 = 2:
     1 - (0-2) != 1 - 2
                3 != -1
The above relationship does not hold for elements in the stream.
Not surprising, this method does not compute the correct result when used on a sequential stream.

Now consider this method:
<W> W reduce(W identity, BiFunction<W,? super T,W> accumulator, BinaryOperator<W> combiner)

In the code:
      System.out.println(List.of(1,2,3,4,5)
     .parallelStream()
     .reduce(0, (a, b) -> (a - b)), (x, y) -> x + y));

The identity value is 0, the accumulator is (a, b) -> (a - b) and the combiner is (x, y) -> x + y).
For t1 = 1 and t2 = 2:
     1 + (0-2) = 1 - 2
            -1 = -1
The above relationship holds for all elements in the stream.
The result is computed correctly for parallel streams.

I think we are trying to kill a mouse with an elephant gun.
The errata for most books is minor and not extensive, so the changes can be incorporated manually into the edition you already have, thereby any notes you have in the book remain intact.
Major updates to a book usually mean a new edition.
Of course, it would be great if a publisher would provide the solution you are suggesting.

Burk Hufnagel wrote:

I know that for the Sun exams, the pool was much larger than the number of questions on the exam ….



I believe this is still the case.

I am sure new questions are added to the pool and a set of questions selected/generated that is representative of the exam.
My sense is the questions emphasize code scenarios rather than esoteric syntax.
I am hoping my co-author can enlighten us some more. :-)
Hi Charles,
Yes. You are right. It is a bummer.
But I guess that would be the case with any publication that had your notes and was updated by the publisher.
Hi Burk,

The publisher informs me that customers who have registered their eBook on InformIT can "refresh" their digital product and will receive the updated file.
The physical book will be reprinted with corrections but less frequently and you will have to fork out to get the reprinted book.

No matter, we will update the errata on the book website regularly.

You are right in that an ebook can be updated faster and with less cost than the printed book.
Hi Babu,

We are also trying to get info on Java training subscription from Oracle University.
Any info we get, will be posted here.
Sorry can't help any more than that at the moment.
Hi Charles,

Just so that I do not give any wrong information, I have reached out to the publisher.
Please watch this space.
Hi Charles,

Diagrams, tables, and complete runnable examples are all integral in teaching a topic.
Many tables provide summaries of important concepts as "memory joggers". (If I understand this term correctly.)
A few examples of such tables: overriding vs. overloading, arrays vs. lists, and switch statements vs. switch expressions.
The copy-righted images below will give you an idea of kind of diagrams in the book.
Hi Charles,

Can't emphasize enough how important it is to do quiz questions/mock exams to acquire the right mindset and have enough time on the exam.
All the best!