Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!

Curtis Rutter

Greenhorn
+ Follow
since Sep 17, 2010
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
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 Curtis Rutter

Looks like the forums on JavaRanch include lots of folks who are willing to help everyone, including greenhorns like me. I'm impressed with the JavaRanch community. I'm running Java5, BTW.
Muchas gracias. CR
11 years ago
OK, sometime you miss the forest for the trees.

Great answer, and quick. And the Google suggestion was a good idea that helped.

Thanks!

CR
11 years ago
I've looked for an answer to this question and haven't found anything. Hopefully I haven't missed a post somewhere.
Background: I'm studying for the SCJP at a technical school where, unfortunately, none of the instructors at my location are Java experts. I'm stumped by the answer to one of the questions about the following code snippet (commented lines are those I've added to get the code to compile, line numbers as in the test question):

1. class SuperClass {

// public class A {
2. public A getA() {
3. return new A();
4. }
// }
5. }
6. class SubClass extends SuperClass {

// public class B {
7. public B getA() {
8. return new B();
9. }
// }
10. }

The "correct" answer says: "Compilation will succeed if B extends A." Other, "incorrect" answers are that A. compilation will fail because of an error in line 3 and that B. compilation will fail because of an error in line 9.

Given that I had to add code to even get the original code to compile (and doing so without "B extending A"), any thoughts on how the code should look to get to the answer as stated? What concept are they trying to test here? NetBeans pukes on lines 2, 3, 7, & 8.

Thanks!
11 years ago