Martin Leon wrote:Chapter 10 Self Test, Question 2, page 811, 812
My book has a "." after the "A" as part of the command line that is invoked. None of the answers have a ".", so none of them are correct.
Try it:
java _ - A .
Always believe in yourself
Chris Devine wrote:In the Chapter 1 Self-test, question 6:
The answer given (A. Compilation succeeds) seems incorrect. If the Device interface contains the method public void doIt(), then all classes implementing that interface should implement that method. However, the class Phone 3 implements the Device interface but only implements a doStuff() method. This would cause a compile error due to a mistake on line 7. Answer E should be the correct answer in that case.
Alan Cowap wrote:
Chris Devine wrote:In the Chapter 1 Self-test, question 6:
The answer given (A. Compilation succeeds) seems incorrect. If the Device interface contains the method public void doIt(), then all classes implementing that interface should implement that method. However, the class Phone 3 implements the Device interface but only implements a doStuff() method. This would cause a compile error due to a mistake on line 7. Answer E should be the correct answer in that case.
Hi Chris,
The answer in the book is correct.
Note that "Phone3 extends Electronic" and that "Electronic implements Device { public void doIt() { } }"
Hence, Phone3 inherits the "public void doIt() { }" implementation from Electronic.
Aside, there's no need for Phone3 to explicitly state it implements Device, since Phone3 already inherits that interface from Electronic.
Regards,
Al
Francky Boy wrote:SELF TEST Page 82, question 7.
Answer:
C,D, and F are correct.
F is wrong !
What is wrong on the enum on line 10, compilation succeeds.
In J2SE version 6, F won't compile:
"The member enum Traffic can only be defined inside a top-level class or interface"
- but it's defined within a method, hence the compiler error.
You could check that you've typed the code correctly, and that you're using the correct compiler (version 6).
Regards,
Al
Jon Frowd wrote:In the question posed on page 433, aren't 9 objects created? Isn't the space character on the last line also a String object?
System.out.println(s1 + " " + s2);
Jon Frowd wrote:In the question posed on page 433, aren't 9 objects created? Isn't the space character on the last line also a String object?
System.out.println(s1 + " " + s2);
Rember, static inner classes can't access instance methods or variables.
Bert Bates wrote:
Also, THANKS to everyone for posting these! I tend to look into these in baches, so pretty soon I'll review all of these and give you all some feedback!
Bert
With either fragment, the first output must be yo.
This tiny ad is suggesting that maybe she should go play in traffic.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|