Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!

Albert Kozera

Greenhorn
+ Follow
since Aug 10, 2021
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
12
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Albert Kozera

Appendix wrote:55. F. The first clue is that the -m and -p options are on the java command. Beyond that, you need to memorize the name of the --show-module-resolution option.

Jesse Silverman wrote:
I consider this serious enough that I am going to ask where this got goofed up.
Possible choices:
1. The original authors, Jeanne and Scott (quite unlikely, but I don't have the book yet and don't want to leave anything out).
2. The copy-editors/publishers
3. The rendering process for whichever way Albert is reading this (seems to be good old fashioned paper book due to "Page 258" reference but good to ask).
4. Albert getting bit by a "Smart Clipboard" or a "Smart-Ass Copy-and-Paste"
5. Something at Java Ranch rendering this differently than Albert pasted.



I think the reason is point 4. I corrected it. Sorry for that.
Hi!

In question 55:

55. Fill in the blanks to list a way of getting a lot of information useful in debugging modules:
_______ -m x -p y --______________
A. jar and -show-modules
B. jar and -show-module-detail
C. jar and -show-module-resolution
D. java and -show-modules
E. java and -show-module-detail
F. java and -show-module-resolution



1. Could this option "--show-module-resolution" be placed at the end of an expression?
When I am testing this option in that way it is not working (compiles but not print anything):
It works fine when it is placed like that:

2. Shouldn't it be "show-module-resolution" in answers?
book: OCP Oracle Certified Professional Java SE 11 Developer Complete Study Guide: Exam 1Z0-815, Exam 1Z0-816, and Exam 1Z0-817
chapter: 14
page: 600

As you may remember from Chapter 6, “Lambdas and Functional Interfaces,” we presented functional interfaces like Predicate, Consumer, Function, and Supplier.


but Chapter 6 didn't actually mention anything about Function interface.
Shouldn't it be something like that:

As you may remember from Chapter 6, “Lambdas and Functional Interfaces,” we presented functional interfaces like Predicate, Consumer, Supplier // and eventually Comparator because it was covered in Chapter 6

Let me start by saying that I thank you very much for your time. I really appreciate that.
I think your 3 answers have dispelled my doubts.
It seems that this is just a hard JLS definition of "what is allowed and what is not". These kinds of things are the worst to remember.

Thanks again for all yours answers. I'm going back to learning
Hi!
I have a question about numeric promotion with final modifier which is covered by book.
book: OCP Oracle Certified Professional Java SE 11 Developer Complete Study Guide: Exam 1Z0-815, Exam 1Z0-816, and Exam 1Z0-817
chapter: 4
subchapter: "Creating Decision-Making Statements" ---> "Numeric Promotion and Casting"

Perhaps the best way to start is to quote the book:

Numeric Promotion and Casting
Last but not least, switch statements support numeric promotion that does not require an explicit cast. For example, see if you can understand why only two of these case statements compile:



I was interested in this stuff with 'final' and decided to experiment. Below are some of my examples:












I am so lost in it...
I can't find any logical explanation why #3 compiles and #4 doesn't. Is long some kind of exception? I would be able to understand it, but what happens in #10 then? As you can see in #10, there is no problem anymore and the compiler can handle this long.
#8 and #9 is also strange to me, because looking at #1, #2 and #3 I understood that using 'final' when declaring a variable and assigning it a value immediately will make this variable automatically converted to the smallest possible container in a given type. If I declare a variable of type int but assign the value 127 or -128 to it, the compiler will say "that int is redundant here" and will automatically set the type of the variable to byte because 127 or -128 will fit in the type byte. ---> that's how I got it
If that were the case, why in #9 the compiler doesn't set the type of variable 'a' to float, which is the smallest possible floating point container?

Could someone explain this somehow to me, please? How should I think about this? Because my way of thinking turned out to be extremely incorrect.

Mike Simmons wrote:Why are the options labeled 1, 2, 3 etc and then the answers talk about A, B, C etc?  Very confusing.


I don't know, I copied it from the book.
It also irritates me,

Thanks to everyone for all the explanations .

best regards
Hi!
// Sorry for all possible mistakes! I'm newbie.
I just wanted to submit a possible amendment to the book, which in my opinion introduces misinformation about the default initialization values. I mean not misinformation but I think it is just 'unclear'.

book: OCP Oracle Certified Professional Java SE 11 Developer Complete Study Guide: Exam 1Z0-815, Exam 1Z0-816, and Exam 1Z0-817
chapter: 2


1. Please look at Table 2.3 (Default initialization values by type) in chapter 2.

Variable typeDefault initialization value
booleanfalse
byte, short, int, long0
float, double0.0
char'\u0000' (NUL)
All object references (everything else)null


As you can see in the book it is stated that the default initialization for a variable of type float is '0.0' and for long '0'.

2. Now let's move on to the 'chapter 2 - Review Questions' section

Question 6 - Which of the following are correct? (Choose all that apply.)
1. An instance variable of type float defaults to 0.
2. An instance variable of type char defaults to null.
3. An instance variable of type double defaults to 0.0.
4. An instance variable of type int defaults to null.
5. An instance variable of type String defaults to null.
6. An instance variable of type String defaults to the empty string "".
7. None of the above

Appendix:
C, E. Option C is correct because float and double primitives default to 0.0, which also makes option A incorrect. Option E is correct because all nonprimitive values default to null, which makes option F incorrect. Option D is incorrect because int primitives default to 0. Option B is incorrect because char defaults to the NUL character, '\u0000'. You don’t need to know this value for the exam, but you should know the default value is not null since it is a primitive.

Question 7 - Which of the following are correct? (Choose all that apply.)
1. A local variable of type boolean defaults to null.
2. A local variable of type float defaults to 0.0f.
3. A local variable of type double defaults to 0.
4. A local variable of type Object defaults to null.
5. A local variable of type boolean defaults to false.
6. A local variable of type float defaults to 0.0.
7. None of the above

Appendix:
G. Option G is correct because local variables do not get assigned default values. The code fails to compile if a local variable is used when not being explicitly initialized. If this question were about instance variables, options B, D, and E would be correct. A boolean primitive defaults to false, and a float primitive defaults to 0.0f.

Question 8 - Which of the following are correct? (Choose all that apply.)
1. A class variable of type boolean defaults to 0.
2. A class variable of type boolean defaults to false.
3. A class variable of type boolean defaults to null.
4. A class variable of type long defaults to null.
5. A class variable of type long defaults to 0L.
6. A class variable of type long defaults to 0.
7. None of the above

Appendix:
B, E. Option B is correct because boolean primitives default to false. Option E is correct because long values default to 0L.


In Appendix to question 6, it is repeated again that for float the default initialization is 0.0.
In question 7, apart from the fact that the correct answer is G, the Appendix states that, inter alia, option B would be correct if these were instance variables. According to the information provided in the appendix of question 6 and in Table 2.3, the correct answer should not be B, but F. The same is true for question 8, where the correct answer is E instead of F.

I mean, I know these are the correct answers and Appendix is right. However, I believe that Table 2.3 should be specified a little more, taking into account the fact that this exam like to be tricky.

That's all, because I'm going back to studying for the exam 1Z0-819. I am sorry if I have violated any copyrights - if so, I am asking the moderator to delete the post. I just wanted to thank the authors of the book somehow, because overall it's great and I have no complaints so far. Table 2.3 is the first thing that misled me.