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!

Russ Russell

Ranch Hand
+ Follow
since Jan 24, 2010
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
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Russ Russell

Hi,
I am assigning and array of type Dog to an array of Animals (implicit upcast - Dog extends Animal), and I am getting different results than I expect. Would someone please explain why the array of Animals doesn't receive the Dog values (code below)?

Thank you in advance,
-Russ
9 years ago
Thank you both. Crystal clear.

-Russ
9 years ago
Thank you , Jeff.

Swapping the order of the parameters in the list is considerend a different signature?
9 years ago
Is merely changing x to final in the go() method enough to consider this a different parameter list, and therefore an overloaded version of the method? Or is it the same parameter list and therefore an overridden version of the method?

If I limit the access of the method in Hello2 (by making it default), the compiler complains that I can't do that when overriding, so the compiler must consider final int x the same parameter list. I suppose this answers the question, but I just want to verify this with others.

Thank you,
-Russ

9 years ago
Thank you. I am aware that I can pass a Dog when an Animal is expected (that's polymorphism in action). My question is which method the compiler uses to accomplish this. Upcasting or Widening.

-Russ
9 years ago
I have seen this used in the SCJP Study Guide both as an example of upcasting and of widening. Which one is it? Is Dog being implicilty upcast or widened to Animal?

Thank you,
-Russ

9 years ago
Thanks for the quick and thorough response (as always!)

-Russ
9 years ago
Thank you Joanne. And why doesn't the int-to-byte have the same problem?
9 years ago
Hi,

If I do this:

I am assigning a 32-bit int literal to a byte and it compiles. It appears that the compiler implicitly narrows the literal so that it will fit into the smaller byte.

However, the following will not compile:

I am assigning a double literal to a float. Why dont I get the same "it compiles" behavior when assigning a literal double to a float? The compiler seems willing narrow the big int when assigning to a byte, but not the big double when assigning to a float.

Thank you,
-Russ
9 years ago
Hi,
I am using the SCJP Study Guide by Sierra & Bates. I feel I have a good grasp of each chapter until I do the self-tests. The questions are presented as brain-twister puzzles. I realize that this is how the questions are presented on the exam.

Does anyone have any tips or advice on how to step back and look at these problems, or break them down so that I have the best chance of understanding and solving them?

Thanks in advance,
-Russ
In the SCJP Study Guide, chapter 3 Self-Test question #7, Line 12 has a call to getBidValue(3);

Nowhere in the 16 lines of question 7's source code is there a definition for a method called getBidValue, and the answer to the question is not a compile error. It's much more likely that I am missing something then there is an error in the book. Please point out what I am missing.

Thank you,
-Russ
Thanks for clearing this up for me Rob.

-Russ
9 years ago
Thank you again Rob.

Is Super inheriting Sub's doSomething()? How can Super be a Sub when class Sub extends Super?
The closest thing I've seen to this was in the Polymorphism chapter when you have something like Super s = new Sub();

Thank you,
-Russ
9 years ago

Rob Spoor wrote:the current object inside that Super constructor is still a Sub instance.



Would you point out to me where in your example I can see this? Thanks.
9 years ago