Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!

Steve Marriott

Greenhorn
+ Follow
since Jun 06, 2009
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
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Steve Marriott

Earlier this past summer I purchased the PK-CSPJ-W02B (Java Programmer Certification Package) from Sun. I don't recommend this course, because I found that this was a very poor preparation for the SCJP6 exam. I was able to easily absorb the concepts and move through the entire course within about three weeks, but I learned far more from the SCJP6 Study Guide from K. Sierra and B. Bates than I did from Sun's course.

However, the ONE thing I DID enjoy about the course were the labs. Actually working with the code to produce something was very rewarding, and I liked having the validation of my nascent understanding. Since I don't actually program for a living, I'd like to find sources of 'You-Build Projects' that will give me opportunity to work with the language and confirm that my solutions are valid. I'd particularly like to find something that will guide my OO design approach, since OO programming is about more than the technical requirements of any particular language. Is there something like this available without participating in a protracted instructor-led course? I like the freedom of self-paced learning.

Thanks in advance for any suggestions. I passed the SCJA two days ago, since I wanted to have something to show for my efforts the last six months!

Steve
That is the right question! Thanks!
9 years ago
Thanks for the attempts, but your responses still come up short.

<E> can be any subtype of Plant. Consider how Sheep is a valid type for the munch method parameter in the Carnivore interface. What makes the use of Sheep valid is because it is a subtype of Animal, and the Carnivore interface was defined with <E extends Animal>. In the same way, the Herbivore interface was defined with <E extends Plant>, therefore Grass (which extends Plant) should be a valid type for the munch method parameter in the Herbivore method.

If someone can accurately explain why the above is not correct, I'd appreciate it!

Otherwise, moderators please post this in the Errata forum. Thanks!
9 years ago
Mr. Ritchie, the explanation provided in the book as to why answer C is incorrect is the following:

"C doesn't work because an Herbivore<Plant> must have a munch(Plant) method, not munch(Grass)."
9 years ago
You guys make it seem like there's ALWAYS someone here!

The SCJP 6 Study Guide says that the correct answer to #6 on pg 651 is:

interface Herbivore<E extends Animal> extends Hungry<E> {}

which I agree will work. However, I don't see how answer C doesn't work since Grass IS-A Plant.
9 years ago
Attention Moderator:
Since there has not been a reply to this post I assume that there is nothing wrong with my solution, which means that there is an error in the book. Can you please transfer this thread to the Errata forum? Thanks.
9 years ago
I don't understand why the SCJP Study Guide doesn't like this as a way to 'fix' the code below.
I can get this to compile and I believe it's acceptable because Grass is a type of Plant.

class Sheep extends Animal implements Herbivore<Plant> {
public void munch(Grass x){} }

9 years ago

Campbell Ritchie wrote:This is the McGraw-Hill link to what I think is the book in question. I tried ctrl-F --- errata/corrigenda and didn't find anything. There may be an "errata" or "corrigenda" link in the book.

I think this thread would sit better on another forum. Moving.



Thanks for moving this thread; I didn't realize this was here. Presumably, the editors read this thread, so I expect my posting to the link you provided is redundant and unnecessary.
Cheers.
9 years ago

Rob Prime wrote:This error has probably been corrected in the errata. Check those out; you can probably get them from their website.



Rob, I found the following link from a posting several years ago (below is an excerpt). I followed the specified link, but don't see any mention of errata; can you provide a current link to the errata page? Thanks.

....Once the majority of the content is written, updates and corrections are handled by the editors. It's a McGraw-Hill publication, so you're best providing the feedback to them:

McGraw Hill Editorial Services

9 years ago

David Newton wrote:In any book containing any significant amount of code you will almost *always* find a number of errors.

The exception is with companies that actually do the right thing and use live code snippets with accompanying unit tests. These are the exception rather than the rule.



Who would expect otherwise (even though the book was undoubtably thoroughly reviewed by the writers and publsher)? I'm just pleased and gratified to have found one myself; it validates my effort to learn and confirms that I am in fact making progress in my studies. My objective is, after all, to understand this stuff.
9 years ago

Rob Prime wrote:This error has probably been corrected in the errata. Check those out; you can probably get them from their website.



I'll do that just to make sure they know about it, but it's gratifying to have identified it myself.
9 years ago

Ernest Friedman-Hill wrote:

They invoke the method "getValue()" as "getBidValue()".



Very good; you got it!
9 years ago
The following code has been entered exactly as printed in the SCJP6 Study Guide. The Guide says that the correct answer to this question is: A) "The output could contain 30", and B) "The output could contain @bf73fa".

It is true that the designated output is produced IF you change one line...if you don't, the code as written wont compile.
9 years ago
Ah yes. I see that now: a1.b1 == a2.b1 Brilliant! Thanks for the response.

Follow up:
static Beta b1;

Is it fair to say that the line above is a static initializer, even though it has no braces as one would find in a 'textbook' static initializer? If that's true, then this helps me to understand even better that this line executes when the JVM loads the Alpha class, not just when the Alpha class is instantiated.
9 years ago
"...you can still access the other Beta object through the static variable a2.b1 - because it's static."

The book says that a2.b1 still points to the other Beta object after this code runs, but I don't see that a2.b1 was ever assigned to anything. I think it's actually a1.b1 that still points to the Beta object that was previously referenced by variable b1. Do I have it wrong?

9 years ago