Charles O'Leary

Ranch Hand
+ Follow
since Jul 10, 2014
Cows and Likes
Cows
Total received
5
In last 30 days
1
Total given
0
Likes
Total received
25
Received in last 30 days
1
Total given
9
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Charles O'Leary

Katherine Reut wrote:
    a) I "x"ed out the arrow pointing from a1 to "Alpha Object #1".
            *This makes the arrow from "a1.b1" to "Beta Object #1" and the arrow from "a1.b2" to "Beta Object #1" be x'ed out too!



Hi Ranchers,

Could you kindly refresh my memory on the specific rules for the above asterisk?  Or, perhaps, provide more insight?  By the way, I think this is one of the better diagrams that I've seen since it "keeps" both sets of b1&b2 within heap objects referenced by a1 and a2.  If you have a better diagram, by all means, please feel free to share it.

Answer:


It should be clear that there is still a reference to the object referred to by a2, and that there is still a reference to the object referred to by a2.b2. What might be less clear is that you can still access the other Beta object through the static variable a2.b1—because it’s static.



My memory somehow wants to see a1, a1.b1, and a1.b2 as three separate (independent) references, similar to how the above answer seemingly (to me) treats a2, a2.b1, and a2.b2 as separate references?

Thanks in advance!
Welcome. Congratulations on your latest book Hanumant!
page 96 & 104, "argument" should be "parameter"
96:

Now imagine a test class has a method with a declared argument type of GameShape, which means it can take any kind of GameShape.
....
The key point is that the doShapes() method is declared with a GameShape argument but can be passed any subtype (in this example, a subclass) of GameShape.


104:

Of course, the cool thing here is that any class from any inheritance tree can also implement Animatable, so that means if you have a method with an argument declared as type Animatable, you can pass in PlayerPiece objects, SpinningLogo objects, and anything else that’s an instance of a class that implements Animatable




reference page 49 of OCA Java SE 8 Programmer I Exam Guide (Exams 1Z0-808)

As a bit of background, we’d like to clarify how we’re going to use the terms “argument” and “parameter” throughout this book:

   arguments  The things you specify between the parentheses when you’re invoking a method:

   parameters The things in the method’s signature that indicate what the method must receive when it’s invoked:



I found that changing the code, at the top of page 374 on OCA Java SE 8 Programmer I Exam Guide Exams 1Z0-808 1st Edition by Kathy Sierra  Author, Bert Bates Author, allowed me to properly compile/run/understand the point of the provided just-in-time array example.

Alejandro Daza wrote:I Really dont know why the mask gets 2 increment if there is only one mask++ in the code and I more that sure when you refer a variable to itself it does not increment, so I am really confused I really dont know what it is.



Alejandro Daza wrote:Thanks, So I am right, the answer on the book is incorrect then.


Assuming we have the same book, it's possible that some of the originally posted question was truncated.  If so, the book answer would be correct.

   

Charles O'Leary wrote:Since you already know the output, the specifics are:
IllegalArgumentException thrown on line 8  is caught on line 9
RuntimeException  thrown on line 11  isn't caught;  line 11 is not "guarded" inside its own try and catch)
line 16 executes inside the finally because the finally always executes (unless System.exit(0) and/or JVM shuts down)
RuntimeException  thrown on line 17 inside the finally is never caught


My apologies for the re-numbering:
Welcome to the Ranch
Since you already know the output, the specifics are:
IllegalArgumentException thrown on line 8  is caught on line 9
RuntimeException  thrown on line 11  isn't caught;  line 11 is not "guarded" inside its own try and catch)
line 16 executes inside the finally because the finally always executes (unless System.exit(0) and/or JVM shuts down)
RuntimeException  thrown on line 17 inside the finally is never caught

Welcome to the Ranch,

Please specify exactly what you are seeing since we don't all use the same review (and/or book) materials.  What is the question?  What are the provided choices?
Welcome to the Ranch

Pete Letkeman wrote:Please note that the Java OCA 7 and OCP exams will be retired by Jan 1, 2019 as noted here https://coderanch.com/t/691480/certification/Java-exam-retirements.
However as noted here https://coderanch.com/t/683846/certification/Writing-Java-OCA-IZ-EXAM#3209694 you can use an Java 7 OCA study guide to the Java 8 OCA.

I would strongly suggest that you go for the Java OCA 8 exam instead of the Java OCA 7 exam.



To your question, Static Initializers are in the prep books that I own for OCA 8.  If you haven't noticed, including the Objectives, the FAQ has many anticipated questions covered:  https://coderanch.com/wiki/659981/Ocajp-Faq
(Your average score is 74.6%.)  Have your Study Guide mock exams averaged 80% or above?  To Pete's point, perhaps these (Study Guide mock exams) maybe closer to better indicators?  

Alexander Caleb wrote:after the if/else statements, won't another Cardinal object with c2 reference variable be created?

  Yes and subsequently the object will become lost.

Alexander Caleb wrote:Why does this compile because isn't this a case of a duplicate variable?

The first (and only since the code takes either the if or the else) c2 lives within the confines of the if/else.  Outside the if/else I would think that the first c2 is out of scope.  The subsequent declaration, in this case, would not be a duplicate.  Is this consistent with any provided explanation? 

Thanks,
Charles