Bassam Gemayel

+ Follow
since Feb 28, 2021
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 Bassam Gemayel

Hey Jeanne, Scott, Staff team,

In the "Why the Hippo Program Printed C After AB" table

The penultimate sentence says:

"For the exam, you just need to know that a class must be initialized before it is referenced or used."

There is one catch to this rule, using constants in a class.

A constant is a static final variable that either of type primitive or String.

If the constant is defined in the same line as it is declared, the static initializer-blocks are no more called.

It is a corner case, thus, not really useful in real life, just thought I would share it.

For example,


Hey Jeanne, Scott, Staff team,

Answer 19 should be A. and B.

binarySearch() will always yield the middle element index if it is a match regardless of whether the array is sorted or not.

I understand the intent is to explain the unpredictability of binarySearch() in case the array is unsorted.

I would suggest changing: B. to B. 0 and F. to F. one output is unpredictable

The term undefined might imply the wrong interpretation.

Thanks for a great book,

Hey Jesse,

Use the instanceof type comparison operator for any non-primitive type.

If (koko instanceof T) is true then koko is of type T.

Hey guys,

The answer should be A, B, C, F.

Every non-primitive type is of type Object. String is a non-primitive type, making option B correct. koko is both an Object and a String.



Jesse Silverman wrote:
In terms of the sentence in the summary on page 208, I would change it to:
'Calling == on String references will check whether they point to the same object'

That would be correct but redundant. You can remove "String" and the statement would remain valid.

Jesse (edited) wrote:
'Calling == on (compatible type) references will check whether they point to the same object'

My intent was to add an informational value and underline the distinction between pooled and non-pooled strings.

Keep it up,


I would use "correct" instead of "precise" when describing an assertion.

"Precise" begs the question of how much precision is requested.

"Correct" is an absolute and does not have varying degrees of intensity or grade.

Thanks again,


We agree.


The main discussion here is that readers understand that NOT ALL String objects are stored in the String Constant Pool (aka, pool).

Only compile-time constants Strings and Strings interned using the intern() method, are stored in the pool.

The rest of the String objects are stored somewhere else on the heap.

Thank you, both,


Hey guys,

The third paragraph states: "Calling == on String objects will check whether they point to the same object in the pool."

This is correct for string compile-time constants, eg. literals, and interned Strings.

This is incorrect for all String objects since the POOL is NOT used for ALL String objects.

Suggested edit: "Calling == on literal or interned String objects will check whether they point to the same object in the pool. "



Brilliant! Did not even think about trying this! :-)

Thus, you CAN have multiple classes in the file and they are compiled.

Thank you, Jeanne!

PS.: You and Scott created a gem, I learned faster and more accurately reading your book than I ever did reading any other Java material, kudos!
Hi Jeanne,

The second sentence states that "If two operators have the same level of precedence, then Java guarantees left-to-right evaluation".

This is incorrect as it does not apply to all operators. It does NOT apply to the assignment operators.

The correct statement would be:

"If two operators have the same level of precedence, then Java evaluates the expression left-to-right, except for the assignment operators that are evaluated right to left."

An example is as follows:

int a = 9;
int b = a = 10; //First a is assigned the value 10, Second b is assigned the value of a


Hey Jeanne, Ilkay,

The java option ONLY works for a SINGLE class in the file

It is the FIRST class that is declared.

If you have 2 or more classes, they are ignored.

You cannot extend another class in the file

If the first declared class extends another class in the same file, the command will fail.

Hope this helps and thanks,