• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Compiling errata for K&B, SCJP 6

 
Greenhorn
Posts: 2
Android IntelliJ IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 52
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 46
Eclipse IDE Slackware Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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>

 
Ranch Hand
Posts: 58
Firefox Browser Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Greenhorn
Posts: 3
Mac Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Chris Devine
Greenhorn
Posts: 3
Mac Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Fred Butler
Greenhorn
Posts: 6
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



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


 
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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".
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would like to thank you all for these feedback
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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);
 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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.

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Greenhorn
Posts: 7
Netbeans IDE Debian Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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?
 
Ranch Hand
Posts: 209
13
VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Chapter 9: Threads self test q15

With either fragment, the first output must be yo.



I don't think this is so. It's possible for 'dude' to get printed first.

https://coderanch.com/t/657902/java-programmer-SCJP/certification/SCJP-Chapter-Threads-test
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic