aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Compiling errata for K&B, SCJP 6 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Compiling errata for K&B, SCJP 6" Watch "Compiling errata for K&B, SCJP 6" New topic
Author

Compiling errata for K&B, SCJP 6

Bob Condon
Greenhorn

Joined: Jun 17, 2012
Posts: 2

Ch. 3 Qn. 12
My output was "4 6" - which is not a choice in the book.
go() method listed b2, b1 out of order...so, book choice of "6 4" is good answer.
Vijay Tyagi
Ranch Hand

Joined: Feb 15, 2010
Posts: 52
There is a line in Chapter 1 of KB SCJP 6 book

"Finally, you need to know that the abstract modifier can never be combined
with the static modifier."

on
page 45


Static nested classes can be abstract ,so it is not entirely true.


It is under the topic Non access modifiers for members so it's right , but this statement can be a bit misleading.
Yalvin Duha
Ranch Hand

Joined: Apr 07, 2012
Posts: 40

I don't know if this is a valid errata, but Chapter 7, Self-Test section, Question 3 (answered on page 648-649) says that the correct choice is "E" (a run-time error).

Frankly, I don't know whether inclusion of proper "import" statements/packages/classes only applies when the code contains the class definition, i.e. public class Animal { }, but given the code as is, it would not compile because of a missing "import java.util.*" statement.

--------------------

Chapter 7, Self-Test, Question 7 (answered on page 653-654): although the answer is "B", the output is partially correct. When a PriorityQueue is empty and peek() is called, it returns "null". Therefore, the output should also contain "null".

The correct answer is (B) 2 2 3 4 null

--------------------

Chapter 7, Self-Test, Question 13: at no point in the chapter SortedMap.firstKey() was mentioned or said to be required to be on the exam. Nonetheless, the question relies on it for the answer. Please clarify whether this method and others in SortedMap/SortedSet , that are not mentioned in the book, are going to be on the test.
Carrie Hall
Greenhorn

Joined: Aug 01, 2012
Posts: 5
I may be missing something here, but I tried to compile Chapter 7 Self Test - q1 and could not compile any of the listed answers.

B is meant to be the answer, i.e.

but I get a compilation error :

The type List is not generic; it cannot be parameterized with arguments <Integer>

sarvesh dikonda
Ranch Hand

Joined: Apr 08, 2012
Posts: 58

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 .


You are wrong Martin Leon when you compile and run the above code it prints A. i.e it prints the Letter 'A' with a dot(.) Try once again


Always believe in yourself
Chris Devine
Greenhorn

Joined: Jun 13, 2012
Posts: 3

In the Chapter 1 Self-test, question 6:

6. Given:

1. public class Electronic implements Device { public void doIt() { } }
2.
3. abstract class Phone1 extends Electronic { }
4.
5. abstract class Phone2 extends Electronic { public void doIt(int x) { } }
6.
7. class Phone3 extends Electronic implements Device { public void doStuff() { } }
8.
9. interface Device { public void doIt(); }

What is the result? (Choose all that apply.)
A. Compilation succeeds
B. Compilation fails with an error on line 1
C. Compilation fails with an error on line 3
D. Compilation fails with an error on line 5
E. Compilation fails with an error on line 7
F. Compilation fails with an error on line 9

Answer:
A is correct; all of these are legal declarations.
B, C, D, E, and F are incorrect based on the above information. (Objective 1.2)


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
Greenhorn

Joined: Oct 16, 2012
Posts: 6

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

This is my .sig. There are many .sigs like it, but this one is mine.
Chris Devine
Greenhorn

Joined: Jun 13, 2012
Posts: 3

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




Thanks, Al. I see that now. One my biggest difficulties (being new to Java and coding in general) is being able to see when and how things work even if they violate good programming practices and conventions. Having a class implement an interface that its superclass already implements appears to be one of those cases where just because it's legal doesn't mean it's right.

All the best,
Chris
Francky Boy
Greenhorn

Joined: Dec 20, 2012
Posts: 2
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.
Alan Cowap
Greenhorn

Joined: Oct 16, 2012
Posts: 6

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
Francky Boy
Greenhorn

Joined: Dec 20, 2012
Posts: 2


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


You're right ! When I try that example under Eclipse with compiler version 6 , the enum line wasn't red !

Thanks and Regards


Shannon Sims
Ranch Hand

Joined: Jul 03, 2003
Posts: 197
Error??? Page 76, question #7, the answer on page 83 states that C, D and F are correct. However, since line 9 is not initialized, this should be a compile error according to page 71 - "Local Variables - Local variables don't get default values, so they must be initialized before use". Therefore, the answer should be C, D, E and F, please verify?

Thank you.

Never mind, the key word to watch for was "before use".
Joe Boman
Greenhorn

Joined: Dec 10, 2009
Posts: 20
doubt in k&b, page 92,
currently reads:
....that the PlayingPiece class inherits the generic display() method...

maybe should read:
...that the PlayerPiece class inherits the generic displayShape() method...

There are other references to the display() method
Omar Nassar
Greenhorn

Joined: Mar 25, 2013
Posts: 26
I would like to thank you all for these feedback
Jon Frowd
Greenhorn

Joined: Apr 23, 2013
Posts: 1
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);
Steven Squeers
Ranch Hand

Joined: Aug 19, 2013
Posts: 62
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);


String literals are different to String objects. String s = "x" is not the same as String s = new String("x"). AFAIK the former creates a String literal in the String pool, unless the literal already exists, in which case it doesn't; the latter always creates a new String object.
Daya Moon
Greenhorn

Joined: Aug 06, 2013
Posts: 4
Chapter 5. page 398.
line7th from the bottom
Using break and continue (Objective 2.2)
"An unlabeled break statement will cause the current iteration of the innermost looping construct to stop and, the line of code following the loop to run."
As break will exit the loop.
Daya Moon
Greenhorn

Joined: Aug 06, 2013
Posts: 4

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);


Until
System.out.println() there will be 8 objects created.

Math Silva
Greenhorn

Joined: Nov 26, 2013
Posts: 3
Page 682. Last sentence says:

Rember, static inner classes can't access instance methods or variables.


I believe it should be "static nested class", right?
YinLi Tao
Greenhorn

Joined: Oct 29, 2013
Posts: 7

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


Hi,

I'm trying to find the official errata for SCJP Sun Certified Programmer for Java 6: Exam 310-065 book. The publisher's errata list doesn't list such. Is this thread what I'm looking for? Where can I find the feedback Bert mentioned in his post?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Compiling errata for K&B, SCJP 6