John Schubert

Ranch Hand
+ Follow
since Sep 21, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by John Schubert

Jeanne Boyarsky wrote:
I'm not catching the distinction. I have "time falls back and we experience the hour from 1:00am to 1:59am" and you are prosing "time falls back from 1:59am to 1:00am". Both say that time falls back. Both say that it is 1am after time falls back. These sound equivalent to me. What am I missing here?



Thanks again for your patience. I now get that the book is talking about the intervals instead of describing the changeover procedure, as it did with the spring one (the book does a really good job there, there is no possible confusion IMHO).

Now for the missing part. Your sentence makes little sense to me because:

Jeanne Boyarsky wrote:
"time falls back..."


Yeah but at what time? You need to go two paragraphs back in the text to find out the time:
"We officially change our clocks at 2 a.m, ..."

And the last (corrected) part:

Jeanne Boyarsky wrote:
"... and we experience the hour from 1:00am to 1:59am"


We experience that interval every day! This part is the most confusing because I was reading it as:
"we experience the hour [going back] from 1:00am to 1:59am"

This is what I now think you are trying to convey:
"time falls back [at 2:00 am] and we experience the hour from 1:00am to 1:59am [again]"

But for me as a first reader there is so much left to interpretation, I'd have appreciated the changeover to have been explicitly described, and then if you wish mention the repeating interval.

I've a final consideration about the last paragraph in this section:
"it is annoying that Oracle expects you to know this even if you aren't in the United States"
Actually DST is a very important topic for every Java programmer, just as much as i18n. Just look at the number of coloured countries in Wikipedia's map:


As a Java programmer chances are that you need to work for an international customer at some point in your career, so one needs to have this in mind. The only part that is US-specific in the exam are the spring and fall changeover times, but the exam creators probably cannot provide a different question tailor-made for each country. There is no need to, because we can abstract the mechanism and apply it to any country just by changing the changeover time, which the exam will probably tell you anyway:
* We change time forward 1h in spring, and so there is a missing interval.
* We change time backwards 1h in fall, and so there is a repeating interval
* The offset relative to GMT changes
* The specific changeover time varies for each country and it doesn't even have to be the same in spring and fall (e.g. in the Brussels timezone, comprising several countries, its 2:00 am in spring and 3:00 am in the fall)
Notice that spring doesn't even mean March, as in the southern hemisphere they do the spring changeover in November and the fall one in March  

Jeanne Boyarsky wrote:
You found an errata. This is wrong. We experience 1-1:59am twice. The diagram on page 251 has it correct. I just added this to the errata and credited you.



Thanks for your response. Glad I made it into the errata, but that was not what I meant. I think there might be now an errata in the errata! In the errata it says the text should say “1:00 a.m. – 1:59 a.m.”, but that sentence is not talking about the intervals in the figure 5.2, but rather it is explaining how the time change goes. The change is going from 1:59 am to 1:00 am (thus the fall back rule, be are adjusting our clocks 1h back). My point is, I don't care at which time change takes place: the important part here is that it consists in going back 1h and the book is saying the complete opposite. That the actual change time in the US happens at 1:59 instead of 2:59 as you spotted is another errata I didn't notice, but it is not as important as my intended errata because the changeover time is different in each country/jurisdiction but the falling back in fall is universal for every country adhering to DST).

It clearly says so in Wikipedia: DST - Procedure

So the corrected first paragraph should say:
"When we change our clocks in November, time falls back from 1:59 a.m. to 1:00 a.m"

This sentence clearly shows the time has gone back 1h and is also symmetric with the sentence describing the March changeover in the previous page, which was correct:
"When we change our clocks in March, time springs forward from 1:59 a.m. to 3:00 a.m."

Actually the diagram in p.251 is also wrong as it goes from the second 1:00 am - 1:59 am interval to 2:00 am - 4:00 am. This last interval spans two hours. It should say 2:00 am - 3:00 am.
From p.252, in the first paragraph:

When we change our clocks in November, time falls back and we experience the hour from 2:00 a.m. to 2:59 a.m. Children learn this as spring forward in the spring and fall back in the fall



First of all, I'm in Europe, we also change the hour back in the fall except we do it in October. We change it from 3:00 AM to 2:00 AM. Apparently in the states its the same, you change the hour 1h back, so the text should say from 2:59 to 2:00.

I actually looked at what happened in New York in 2016 and apparently on November the 5th you went from 2:00 AM to 1:00 AM.

Extra clarification is needed on question 14, because on the end of DST day there are 2 possible 2:15 hours: the one which has the old offset, and the one with the new offset. Creating a LocalTime.of(2,15) for that day is ambiguous, and Java isn't "smart enough to adjust for DST" as per the answer in p.559, but rather has to pick one and defaults to the no DST one (the latter). In spring however we could talk of a "correction" since the conflictive hour doesn't really exist.


Suppose that we have the following property files and code. Which bundles are used on lines 8 and 9 respectively?

Dolphins.properties
name=The Dolphin
age=0

Dolphins_en.properties
name=Dolly
age=4

Dolphins_fr.properties
name=Dolly



...



The correct answer according to page 558 is:
D. Dolphins_fr.properties and Dolphins.properties

It should have been:
D. Dolphins_fr.properties and Dolphins_en.properties

Line 9 should find a match in the English resource file for "age" as it is the default locale (BTW en-US happens to be the default locale on my computer even though I'm in Europe, even without setting it explicitly).
This goes in accordance with table 5.7 in p.264: first we look for the requested locale, as it is not defined there we go to the default locale, and then we would hit the default file but in this case it doesn't need to.

Am I missing something here?

Campbell Ritchie wrote:Please tell us which book it is as well as the question number. That reduces problems about copyright and makes it easier for us to find the original.



Sorry it is the OCP Java SE 8 Certified Programmer  Study Guide, chapter 4 (I thought I wrote it in the title, but apparently I didn't)

Campbell Ritchie wrote: I find it surprising that you think that isn't part of the result.



When I read result, and there is a terminal operation like count, I immediately associate it to a possible correct answer, because it is the result of the stream, and a stream is a computation, fitting the second definition more. The two numbers do not look like THE result, because they are two things (the printing of the two numbers might have been a better candidate for a result). The "and" particle was never printed to the console, so that confused me even more. Maybe if the numbers were collected into a list they could have been considered a result by me.

All this confusion would have not existed had the question asked for the output instead (after all we come from a series of previous questions asking for the output as well).
Or maybe keep the question as is but rewrite the correct option as:
D. 1.2 and 2.4 are printed




In chapter 4, Functional Programming, question #18 reads:


18. What is the result of the following?


A. 1
B. 2
C. 2.4
D. 1.2 and 2.4
E. There is no output.
F. The code does not compile.
G. An exception is thrown.



The correct answer is D. I'd have said that the result is clearly 1 while the printing of the numbers is the side effect.

If we refer to the definition of 'result':


1 : something that results as a consequence, issue, or conclusion; also : beneficial or tangible effect : fruit
2 : something obtained by calculation or investigation



We find that the question could have been written with both definitions in mind. I think the question should have been worded so that it explicitly asked for the output or the outcome of the execution of the code, as in the context of a programming language the reader has a tendency to interpret 'result' by its second definition.

MOREOVER

If we take for granted that we are being asked for the output, and more specifically, for the console output, then the answer D is incorrect as well, since the " and " in "1.2 and 2.4" is never printed.


I'm sorry if I'm being picky here but the questions are tricky as well.
Sorry I meant correct answer is B and I chose B and E (why can't I edit my own post?)

John Schubert wrote:From chapter 3, Review question #1:

Suppose that you have a collection of products for sale in a database and you need to display those products. The products are not unique. Which of the following collection classes in the package best suit your needs for this scenario?
A. Arrays
B. ArrayList
C. HashMap
D. HashSet
E. LinkedList



My answer: A,E
Correct answer:A

According to the solution

"LinkedList is both a list and a Queue"

, and no further explanation is given.

In my opinion LinkedList is perfectly fine for the job, and you would chose it over ArrayList if you needed to access it in a sequential manner rather than randomly. Which would be the case if there was a GUI showing the products in a form style, like Access does (there is a database, so why wouldn't there be a GUI?). Now for a normal console printout, granted it would be less performant, but there are other questions where Vector is shown to implement List as well, albeit it has all the synchronization overweight, and is given as valid, so I think any List would be a correct answer here, considering the question has multiple possible answers.
The excuse given in the answer, that LinkedList does not qualify for being also a Queue, is a poor one, for we don't care which other functionality does a class offer as long as it covers our use case.

I find this answer arbitrary and unfair. I really hope Oracle doesn't come up with questions like these in the real exam.

From chapter 3, Review question #1:

Suppose that you have a collection of products for sale in a database and you need to display those products. The products are not unique. Which of the following collection classes in the package best suit your needs for this scenario?
A. Arrays
B. ArrayList
C. HashMap
D. HashSet
E. LinkedList



My answer: A,E
Correct answer:A

According to the solution

"LinkedList is both a list and a Queue"

, and no further explanation is given.

In my opinion LinkedList is perfectly fine for the job, and you would chose it over ArrayList if you needed to access it in a sequential manner rather than randomly. Which would be the case if there was a GUI showing the products in a form style, like Access does (there is a database, so why wouldn't there be a GUI?). Now for a normal console printout, granted it would be less performant, but there are other questions where Vector is shown to implement List as well, albeit it has all the synchronization overweight, and is given as valid, so I think any List would be a correct answer here, considering the question has multiple possible answers.
The excuse given in the answer, that LinkedList does not qualify for being also a Queue, is a poor one, for we don't care which other functionality does a class offer as long as it covers our use case.

I find this answer arbitrary and unfair. I really hope Oracle doesn't come up with questions like these in the real exam.

Paul Anilprem wrote:Composition requires having an instance of some class as a field of your class, instead of extending that class. Whether that field is public or private and whether there is a method that makes that field accessible to other classes or not is irrelevant.


I don't think it is irrelevant. In fact I think its key to understand the question.

We are talking about accessing that field from a different package. That can be done in four different ways from that class:
  • 1. declaring the field as public
  • 2. declaring the field as protected (accessible only through inheritance)
  • 3. providing a public getter
  • 4. providing a protected getter (accessible only through inheritance)


  • There are other more exotic options such as caching the field before passing it to the class, and even reflection hacks. If we ignore those, the question implies only options 1 and 3 are to be taken into account. The other two are totally plausible and I get to see them in the field very often.
    For me to ignore the possibility of having both composition and inheritance was a simplification that was somehow in contradiction with the strict mindset required for some of the previous questions. Perhaps a commentary explaining that the two approaches shouldn't be considered at the same time would help.



    Jeanne Boyarsky wrote:I think you are reading into this


    Yes that might well be the case. All those previous questions about singletons and immutable objects required very careful thinking, so the student arrives at question #18 in a paranoid state.
    I'm currently reading the OCP Study Guide. Its a great book so far.
    I'm reporting this issue as I've read the current errata and didn't see anything related.

    In Chapter 2, Review questions, p101, question #18:


    Which of the following statements about inheritance and object composition are correct? (Choose all that apply.)
    ...
    E. Object composition requires a class variable to be declared public or accessible from a public method to be used by a class in a different package.
    ...



    According to the answer (p.553) this option is correct because:


    object composition has no notion of inheritance and variables must be exposed publically if they are to be used by other classes in different packages




    I think this option is not correct as it is worded, since you can still access a protected variable trough multiple means from a class in a different package. Even from the composed instance. E.g.: through inheritance:



    Moreover, even if the variable were private or package default, you could still keep a reference to the variable in the subclass constructor and cache it for later use:



    Similarly you could also use a variable that has been passed to our composed class' constructor by keeping a reference to it:



    This last example might seem far-fetched but please be aware that in this chapter the reader has been conditioned to look for this kind of subtleties. For instance, we have seen similar problems with collections being passed in the constructor to "immutable" objects and still being mutable from references cached outside (question #7 options E and G); we have also seen "singletons" that were not such due to the object being public or thread-unsafe getInstance implementations (question #9 options D and F).


    In my opinion, the problem with option E is that it is assumed that:
  • Composition and inheritance are exclusive (which they are not).
  • Every variable mentioned in the question is a "component" variable passed as a dependency to this class and not any other variable that the class or any of its superclasses might already have.
  • You need to access the "component" instances through the composed class.
  • You have no means to access the components from outside of the composed class' package.


  • So I find this option very ambiguous and context-lacking. It is frustrating because when it comes to what is possible or not, real questions in the exam are full of trickery and hacks to mislead the student!

    Thanks for the link, but I don't have an Oracle account. I only gave my data to Pearson VUE.
    Does this mean that they are not sending me the certificate unless I register?
    After passing the test, do they send you something?
    And if so, how could I know if it has been sent or not?

    It has passed some time since I passed the test and I haven't received any email nor mail. I'm going to need an official paper to attach to my CV for a job interview, and I doubt the printed score report they gave me at the examination centre is accepted.

    Have you received something? How long it took to your home?

    Thanks.

    Frits Walraven wrote:Hi John,
    Congratulations! Well done, and it is good to hear that you could use my notes.


    Thanks! And not only me, other people in this forum are using them too!

    Frits Walraven wrote:
    Please share with me the errors that you found, so that I can correct them.
    Frits


    I'll try to review the errata I found and send you a private message. However, as I said, I'm not sure I downloaded the latest version, because I used a link some dude posted. (BTW, I don't know if you have published an "official" link at all XD)

    Sam Hazim wrote:Just a question about this - I thought Threads were taken off scope - I assume that's not the case then, and Threads are still on the exam?



    I'm not sure what objectives are. In the official exam page, they list three topics:
    * Write code to define, instantiate, and start new threads using both java.lang.Thread and java.lang.Runnable.
    * Recognize the states in which a thread can exist, and identify ways in which a thread can transition from one state to another.
    * Given a scenario, write code that makes appropriate use of object locking to protect static or instance variables from concurrent access problems.


    mark juszczec wrote:I'll second the "zen mind" thing. I've been programming in Java since 2000 and thought I'd be ready for this in a matter of weeks.


    I'm on Java since 2001, and it took me 3.5 months with no life XD