Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Some possible errata and doubts (Java OCA 8 Programmer I Study Guide, Sybex)

 
Jimmy Pannier
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I've read the book and there is some 'mistakes'

p86
This sample code would ouput the following:
-5, 10,  // there is no comma in result

p124
L    System.out.print(number + " "); //   L string cannot be there


p125

Line [i]5
searches for the index of 1  // No it's line 6


p170
int long() {]       // ] cannot be there


p219
last line :
""Mrs. Anderson"); // the string must be "Mrs. Anderson" and not ""Mrs. Anderson"

p313
the correct answer is beforecatchfinallydone without spaces

p342
result of question 26 has wrong answer text  ->the code compiles

p351 NOT SURE
Are you that A is correct ?



I have found some mistakes while passing mock exams of sybex site:
- sometimes some strings begin with ' and finish with "   so i answer  "it doesn't compile but it's not the right response or there is no such option"!
- an other one in attachement : there is a sample code with 2 public classes in same file and anwser is B --> the result should be 'it doesn't compile'



Capture.PNG
[Thumbnail for Capture.PNG]
 
Ganesh Patekar
Bartender
Posts: 694
23
Eclipse IDE Hibernate Java jQuery MySQL Database Netbeans IDE Oracle Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to CodeRanch!
Thank you for informing. All these erratas of OCAJP 8 are already listed, click here --->OCAJP 8 Erratas List to see.
Jimmy Pannier wrote:p351 NOT SURE
Are you that A is correct ? 
Question no?
 
Jimmy Pannier
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
question no18
 
Ganesh Patekar
Bartender
Posts: 694
23
Eclipse IDE Hibernate Java jQuery MySQL Database Netbeans IDE Oracle Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jimmy Pannier wrote:- an other one in attachement : there is a sample code with 2 public classes in same file and anwser is B --> the result should be 'it doesn't compile' 
I don't think so they are in a same file because they haven't mentioned that both classes are in a file so you should assume that both are in their separate respective files.

What answer they have given? I think answer is B and F. B because freeze is instance method and you can't invoke instance method from a static method. F because Car.drive(null) compiles but throws exception if invoked because of null which is passed to drive method which will try to invoke static method inTheHeadLights on null and also their is CE in Deer method so It only compiles but can't run.
 
Jimmy Pannier
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
- I'm confused because each line starts with a sequential number.

- I've not the answers anymore. But i'm agree with B and F if not in the same file
 
Ganesh Patekar
Bartender
Posts: 694
23
Eclipse IDE Hibernate Java jQuery MySQL Database Netbeans IDE Oracle Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jimmy Pannier wrote:question no18
If you are sure B is correct answer then you should not have doubt about A being correct answer.

For an example: Suppose teacher says, Students must attaind the lecture and we know this statement is true then If you are asked, Are students allowed to attaind the lecture? What would be your answer  

Yes correct answer is A, B, C and E. If you still have doubt just go through Table 6.1 of chapter 6 on page no 305, will clrear your doubt for sure. After going through that table still has doubt, you can ask again
 
Jimmy Pannier
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's playing with words !

"allowed", for me, lets thinking it's not required !

But ok, i understand now. Thanks
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ganesh Patekar wrote:What answer they have given? I think answer is B and F.

Answer F clearly states "The code compiles ...", but the code does not compile due to an error on line3 (directly invoking an instance method from a static context is not allowed). Hence the only correct answer for this question is B.
 
Ganesh Patekar
Bartender
Posts: 694
23
Eclipse IDE Hibernate Java jQuery MySQL Database Netbeans IDE Oracle Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jimmy Pannier wrote:- I'm confused because each line starts with a sequential number.

- I've not the answers anymore. But i'm agree with B and F if not in the same file
Don't worry. Nothing to get confused. If you think you are not yet clear about this chapter then better not to solve questions rather start reading that chapter again and again until you understand It. It is just 25 pages and If want more then you can also search on this forum about exception. They have given line numbers because to point out exact line of code in given program which may cause error. Certain thing you have to assume.
You're welcome
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jimmy Pannier,

First of all, a warm welcome to CodeRanch!

Jimmy Pannier wrote:p351 NOT SURE
Are you that A is correct ?

That seems to be an English thing. So it is not a typo. We had a fairly lengthy discussion on the topic though. Here is another topic about this question (with exactly the same conclusion).

Hope it helps!
Kind regards,
Roel
 
Ganesh Patekar
Bartender
Posts: 694
23
Eclipse IDE Hibernate Java jQuery MySQL Database Netbeans IDE Oracle Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roel De Nijs wrote:
Ganesh Patekar wrote:What answer they have given? I think answer is B and F.

Answer F clearly states "The code compiles ...", but the code does not compile due to an error on line3 (directly invoking an instance method from a static context is not allowed). Hence the only correct answer for this question is B.
Ahh   I missed that. Yes you are correct It will not compile. Correct answer is only B. Thank you Roel
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jimmy Pannier wrote:- an other one in attachement : there is a sample code with 2 public classes in same file and anwser is B --> the result should be 'it doesn't compile'

I agree that the line numbers can be a little bit confusing and suggest that both public classes reside in the same source code file (which would of course be invalid). But there are three reasons why I don't consider it an errata item:
  • if the line numbers for both classes started at 1, then option D would be "Line 3 does not compile". And that's exactly the same as option B. So to distinguish between both options, some text should be added (e.g. "Line 3 of class Car does not compile"). So for conciseness of the questions and code snippets, the authors used continuous numbering for both classes
  • the context of this question: this question clearly doesn't test your knowledge about only one public class can reside in a source code file. Based on the different options, this question obviously tests your knowledge about invoking an instance/class method from another instance and/or class method. This context of a question can be (very) important when answering questions. In this thread you'll find a nice discussion about this "context of a question", it's definitely worth reading.
  • One of the official assumptions you should consider when taking the exam (and which can be found on the official OCAJP8 certification page) states the following: No file or directory path names for classes: If a question does not state the file names or directory locations of classes, then assume one of the following, whichever will enable the code to compile and run: (a) All classes are in one file or (b) Each class is contained in a separate file, and all files are in one directory.


  • Hope it helps!
    Kind regards,
    Roel
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic