[HD Pg 23, Sec. 1.9.0 - nomenclature]

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
Username987654
Posts: 95
Joined: Sat Dec 26, 2015 6:37 pm
Contact:

Re: [HD Pg 23, Sec. 1.9.0 - nomenclature]

Post by Username987654 »

1.9.11
Similarly, literals such as the numbers 1, 2, and 3, or the characters written in code within single quotes such as ’a’, or boolean values true and false, are all compile time constants because the compiler knows that these values will never change.

(In my Review Copy) The text preceding this statement and 3.3 Declare and Initialize variables' examples appear to contradict the above (when not specified as final)? This does not currently appear to be found on the Errata page? Is the quote an error and/or possible opportunity for clarification?
will be removed tomorrow
Was the whole section removed in a later edit?

admin
Site Admin
Posts: 10046
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: [HD Pg 23, Sec. 1.9.0 - nomenclature]

Post by admin »

Username987654 wrote:
Sun Nov 25, 2018 2:32 am
1.9.11
Similarly, literals such as the numbers 1, 2, and 3, or the characters written in code within single quotes such as ’a’, or boolean values true and false, are all compile time constants because the compiler knows that these values will never change.

(In my Review Copy) The text preceding this statement and 3.3 Declare and Initialize variables' examples appear to contradict the above (when not specified as final)? This does not currently appear to be found on the Errata page? Is the quote an error and/or possible opportunity for clarification?
Do you mean this sentence on pg 24?
For example, if you define an int variable as final int x = 10; then x is a compile time constant because the compiler knows that x will
always have a value of 10 at run time
This statement is correct. Could you please specify which part/statement in 3.3 did you find contradictory to this statement?
will be removed tomorrow
Was the whole section removed in a later edit?
It was about the test post in this thread. Removed now.

thank you,
Paul.
If you like our products and services, please help us by posting your review here.

Username987654
Posts: 95
Joined: Sat Dec 26, 2015 6:37 pm
Contact:

Re: [HD Pg 23, Sec. 1.9.0 - nomenclature]

Post by Username987654 »

Similarly (***when defined as final?***[would better? clarify this quote?]), literals such as the numbers 1, 2, and 3, or the characters written in code within single quotes such as ’a’, or boolean values true and false, are all compile time constants because the compiler knows that these values will never change.

admin
Site Admin
Posts: 10046
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: [HD Pg 23, Sec. 1.9.0 - nomenclature]

Post by admin »

Username987654 wrote:
Sun Nov 25, 2018 10:48 am
Similarly (***when defined as final?***[would better? clarify this quote?]), literals such as the numbers 1, 2, and 3, or the characters written in code within single quotes such as ’a’, or boolean values true and false, are all compile time constants because the compiler knows that these values will never change.
The similarity that is being referred to in those two things (i.e. final int x = 10 and literals 1, 2 etc.) is that both of them are compile time constants.

Normally, a variable can take any value (that is why it is called a "variable"). But, by applying the final modifier to x, we say that the variable x will always have the same value of 10.
1, 2, 3, 'a' etc, OTOH, are literals, they are not variables. They are values. So, the modifier "final" or any other modifier doesn't make sense for them.

That is why, saying "Similarly, when defined as final, literals such as the numbers 1, 2, and 3, ...", would be incorrect.

Section 3.3.3 Page 66 explains literals in more detail.
If you like our products and services, please help us by posting your review here.

Username987654
Posts: 95
Joined: Sat Dec 26, 2015 6:37 pm
Contact:

Re: [HD Pg 23, Sec. 1.9.0 - nomenclature]

Post by Username987654 »

Very well explained. Thanks!

Post Reply

Who is online

Users browsing this forum: No registered users and 84 guests