• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Bear Bibeault
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • salvin francis
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Jj Roberts

Programmer Certification (OCPJP) » OCP Java SE 11 Programmer I Study Guide (Sybex) Flash Card Issues

 
Ranch Hand
Posts: 60
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As both of the authors of the excellent Programmer Certification (OCPJP) » OCP Java SE 11 Programmer I Study Guide (Sybex) Flash Cards monitor this site, I am posting some quibbles with flash cards that I think could be improved, or where the answers seem likely to confuse someone about the identical or a closely related topic.

I saw a couple on first look, but am going thru them now more thoroughly, as I am trying to wrap up preparation on the 815 material, moving on to the 816 portion of the festivities.

Programmer Certification (OCPJP) » OCP Java SE 11 Programmer I Study Guide (Sybex) Flash Cards [Set 1]

I am striking a balance between respect for the IP for this paid material, and providing the ability for knowledgeable users not in possession of the text to chime in on my quibbles.
I will post nothing I don't have an issue with, but I think an attempt to paraphrase would defeat the intention to resolve any issues with the cards in question.

1.
"True or false? Instance initializer blocks run before any constructors are initialized."

When I see that, my mind immediately says "FALSE!!  I see that sneaky word ANY!!  All parent constructors will fully complete before my own instance initializer block begins!"  At one point in my studies I either forgot that or was hesitant enough of the fact that I took too long on the question.

Provided Answer:
"True. Fields and instance initializer blocks are run first, in the order they appear, followed by any constructor calls."

That is certainly true in absence of any inheritance, tho knowledge of whether or not Object itself has any meaningful constructor may or may not be in scope for the exam otherwise.

I am not sure of the precise best wording, but I would want the flash card to remind me of the results of this test program I quickly ran and compiled in my anxiety to indeed be:
Parent Instance Initializer Block
Parent Constructor
Child Instance Initializer Block
Child Constructor

As worded, the card would be useful for a unit test before inheritance was introduced, but feels counterproductive for someone trying to instantly recall what the output of the test shown above would yield.

It is doubly confusing, because I believe the effect is as if my own initializer block runs between the call to super() and the body of my first constructor.  The card contents don't suggest that to me, and I have seen this material on both mock tests and interviews.

I am not sure what I was thinking when I first did the set.  Just ran thru 'em all, and the only other thing I can quibble about is that the text seems to waffle on whether char is an integer/numeric type or not, as one sentence in the book says that all the integral types are signed.  But the card agrees with what I think.  That char is an integral numeric type, but is unsigned with a range from '\u0000' thru '\uFFFF'.

Thanks,
Jesse
 
Marshal
Posts: 71098
292
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jesse Silverman wrote:. . . "True or false? Instance initializer blocks run before any constructors are initialized."

I am not sure that I would say, “initialised.” I would probably say, “executed,” but the Java® Language Specification (=JLS) is clear about the order of execution. Please look for yourself. Please say superclass and subclass rather than parent and child.

. . . char is an integral numeric type, but is unsigned . . .

Another JLS section.
 
Jesse Silverman
Ranch Hand
Posts: 60
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Campbell!

I would say then that the (admittedly, just one) place in the book that says "all integral types" are signed in the book should say "except char".

The JLS is magisterial, as one instructor I had would always say, but most people aren't reading it.
Older books I had around when I wasn't taking the test explicitly encouraged all readers to go read it, the current Sybex book doesn't push it very hard, and is mostly self-contained.
The flash card could lead someone to a false sense of understanding here, and could probably be improved even within the scope of a flash card.

This fell out of scope now for the 819 exam, but is still flat-out wrong:
-cp, --classpath, and -class-path
are described as the ways to pass CLASSPATH as a command parameter to java and javac.

My new mnemonic for remembering it is that you either have one - or three, never two.
Again, out-of-scope (apparently) for 819, but still a basic part of command line Java builds.

Overall, their flash cards are Grrrrrreat!!  Very few errors.
 
Jesse Silverman
Ranch Hand
Posts: 60
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know for sure I saw on either a flash card or a mock exam question in the extra materials supplied with the book that says that .removeIf() can only be called on a List<T>.
Admittedly, you can't call it on a Map, but I just coded and confirmed it works fine for a Set<T>.
The docs make it a little confusing, as they don't go ahead and describe it further, but it is listed as an available method inherited from Collection<T>.
 
Jesse Silverman
Ranch Hand
Posts: 60
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also found this flash card confusing or ambiguous:
True or false? A switch statement can use a var, provided the var is marked final.

The answer is false either way, but it was not clear if they meant the value to switch on, or as one of the case values.

I answered "False, because it needs to be a compile time constant, not just some variable that is set only once at runtime to a value not yet known at compile time."  I was led there because I have seen presentations saying (falsely) "you can use a variable as a case value as long as it is final".

Given answer:
"False. A switch statement can use a var, provided the var resolves to one of the acceptable switch expression types."

That seems to be about the value in the switch( variable ) part, and focuses only on LVTI rather than acceptable case values.
Not wrong, but I wouldn't want to see it on a mock (or worse yet) a real exam question, where everything is in testing scope.
 
Jesse Silverman
Ranch Hand
Posts: 60
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This one is probably just a silly typo, but really had me wracking my brains thinking it was a trick question:

Write a statement to create a three-dimensional primitive integer array initialized with the values [1 2] [3 4].

The answer:
int[][] array = {{1,2}, {3,4}};

seems to show they just meant to ask for a two-dimensional primitive integer array.
Please note that trick questions are intentionally included on flash cards, so it wasn't paranoia.
 
Jesse Silverman
Ranch Hand
Posts: 60
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q: What three statements can be used to execute a loop early?

A: continue, break, return

Great card if we said "terminate execution of a loop early" as it is just a weird thing to say as phrased.
Secondly, continue only terminates one specific iteration of a loop early, break and continue say bye-bye to the whole loop (or more if used with break label; )
 
Jesse Silverman
Ranch Hand
Posts: 60
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Almost done, and I am being picky, but the darn exams are so picky:

Q: "When are you required to call super() in your constructor?"

A: "You are required when not calling this() and the parent class does not define a default no-argument constructor."

I would say "and the parent class neither defines a no-argument constructor nor receives a default one from the compiler due to declaring no explicit constructors at all"
 
Jesse Silverman
Ranch Hand
Posts: 60
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q:"What is the syntax of a case statement?"
A: "case <value> : <expression>"

I may be confused, and Java 12 added switch expressions which I haven't looked at yet, but for classic switch/case statements,
I would say:
case <value> : <statement or code block>
an expression can be a statement (sometimes), but  a code block can certainly be the target of a case statement, and that is NOT an expression, right?
 
Jesse Silverman
Ranch Hand
Posts: 60
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm getting more pedantic as I get to the end, but I feel like I am on trial under oath in court on every mock test...

Q: Which interface is used to declare a custom sort on an arbitrary class?

A: "Comparator. Note that Comparable would be used to define a sort as part of the class definition."

I would say a custom ordering, or custom sort ordering.
To me, "custom sort" means replacing the algorithm, not the parameterized ordering method to be used in the standard sort method..

 
Jesse Silverman
Ranch Hand
Posts: 60
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I really hope Scott and Jeanne don't hate me, but...

Q: "What must appear immediately before a method name?"

A: "The return type"

I would have put "in a declaration or a definition" in the question, it certainly doesn't need to be there when mentioned in a call / statement / expression.
 
Jesse Silverman
Ranch Hand
Posts: 60
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All done.  No more quibbles.  I loved the flash cards and heartily would recommend the book (which comes with access to the flash cards as a bonus goodie) as a gift for a friend or loved one (or oneself) facing the 819...there were 252 of the cards and I did nothing but nod my head or snap my fingers at any of the other featured cards (depending on whether I got them right at first sight or not).
 
Marshal
Posts: 26135
77
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think Jeanne and Scott should hire you on as a full-time reviewer, Jesse! I gave you a cow for all your hard work.
 
Jesse Silverman
Ranch Hand
Posts: 60
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the cow.
When I was posting the last quibble (right before the apology/plug)...

I couldn't remember the fancy term that I'd heard in an advanced Java talk that I don't hear mentioned very often round the ranch.

It was "Type Witness" and (probably?) not in scope for the 819 exam.

I don't really know how to use it, but I did see it is even mentioned in the classic Java Tutorial...I may look it up but it is probably not important for 819, which is my focus for now...
https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html
 
Campbell Ritchie
Marshal
Posts: 71098
292
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jesse Silverman wrote:. . . "Type Witness" . . .

I looked up the Java8 JLS version because it has what some more recent versions don't: a proper index. I couldn't find “type witness”. If it isn't in the JLS it probably won't come up in the exam. Look in the JLS in preference to the Java™ Tutorials.
 
author & internet detective
Posts: 40286
819
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Scott and I sometimes wonder if anyone uses the flash cards because we don't hear about them frequently so it is nice to get detailed feedback on them! And it is absolutely fine to post the ones you have questions on verbatim.

The classpath one is already in the errata so not responding to that here. I also didn't reply to the ones that are colloquial English type things.

Jesse Silverman wrote:
1.
"True or false? Instance initializer blocks run before any constructors are initialized."

When I see that, my mind immediately says "FALSE!!  I see that sneaky word ANY!!  All parent constructors will fully complete before my own instance initializer block begins!"  At one point in my studies I either forgot that or was hesitant enough of the fact that I took too long on the question.

Provided Answer:
"True. Fields and instance initializer blocks are run first, in the order they appear, followed by any constructor calls."


This question is about the blocks and constructors at the same level. That said, the point of flashcards is to make sure you understand the material. You clearly do.

Jesse Silverman wrote:I also found this flash card confusing or ambiguous:
True or false? A switch statement can use a var, provided the var is marked final.

The answer is false either way, but it was not clear if they meant the value to switch on, or as one of the case values.


You would not believe how much Scott and I went back and forth on the verbiage of this!

Jesse Silverman wrote:This one is probably just a silly typo, but really had me wracking my brains thinking it was a trick question:

Write a statement to create a three-dimensional primitive integer array initialized with the values [1 2] [3 4].

The answer:
int[][] array = {{1,2}, {3,4}};

seems to show they just meant to ask for a two-dimensional primitive integer array.
Please note that trick questions are intentionally included on flash cards, so it wasn't paranoia.


Yes, we meant 2D on that one. I've added it to the errata.


Jesse Silverman wrote:Q:"What is the syntax of a case statement?"
A: "case <value> : <expression>"

I may be confused, and Java 12 added switch expressions which I haven't looked at yet, but for classic switch/case statements,
I would say:
case <value> : <statement or code block>
an expression can be a statement (sometimes), but  a code block can certainly be the target of a case statement, and that is NOT an expression, right?


Yes, but this is a Java 11 book. Nothing in Java 12+ exists on the Java 11 exam . Seriously though, this matters. If you answered a question using Java 11 syntax on the Java 8 cert, you'd lose points.
 
Jesse Silverman
Ranch Hand
Posts: 60
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But that was waffling, because of what you said I feel doubly strong saying:

case <value> : <statement or code block>
an expression can be a statement (sometimes), but  a code block can certainly be the target of a case statement, and that is NOT an expression, right?
 
Campbell Ritchie
Marshal
Posts: 71098
292
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think, if you go through the grammar for statements in the JLS, you will find that a block is defined as a kind of statement.
 
Jesse Silverman
Ranch Hand
Posts: 60
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But not as an expression....my quibble stands.
 
Jeanne Boyarsky
author & internet detective
Posts: 40286
819
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesse,
Yes. But we aren't writing a specification. We are writing a book to prepare people for the exam. I feel the way we described is is clear and gets the point across.
 
Jesse Silverman
Ranch Hand
Posts: 60
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fair enough.  There is a lot of hair-splitting on the exams, but it seems each author or set of authors gets totally OCD about different particular issues and remains merely "normal" levels of OCD about others.

I got enough questions wrong when I knew "almost" everything about some topic that my naturally tendency towards insane precision kicked in, also, some of the helpful hands around here refer one to the JLS whenever questions about the Ultimate Truth of the Java Universe comes up.  I did notice that very old SCPJP books referred people to go read it, and neither yours nor the other I read seems to actually push it anymore.

Regardless, there is a LOT of material in the 816 book, so I have my hands more than full just making my way thru that!

'nuff said!
 
Shiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic