• 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

Error in OCP programmer practice exams book : with proof

 
Ranch Hand
Posts: 637
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Test 2, q18



and the correctly compiled and located:



What is the result for Launcher? (These are correct, as per the book)

C. Compilation fails due to an error on line 5 of Launcher.
D. Compilation fails due to an error on line 6 of Launcher.
E. Compilation fails due to an error on line 7 of Launcher.
F. Compilation fails due to an error on line 8 of Launcher.

The correct option should be C only. Code in lines 6,7,8 may be seen as the trouble-makers as per theory.
Class utils is default. Hence the error :



Make Utils public and then you get :



Now D and E are correct.

PS : They did not/forgot to compile the code before putting them in the book ?




 
Ranch Hand
Posts: 394
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rahul wrote:PS : They did not/forgot to compile the code before putting them in the book ?


Rahul, I just want to remind you that java is so complex that even the IDE's are NOT capable of ABSOLUTELY saving you from mistakes,
REMEMBER that the book was written by humans and we are all prone to mistakes at any given time.
 
author
Posts: 9050
21
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rahul,

You bring up a good point that's worth discussing. AND... I think the book is okay. It could be, after further discussion that there is a problem with the book, but for now let's discuss your point a little bit further.

(Also, just so you know, our policy is to always compile and test every bit of code that goes into our books. However getting the source files we compiled into the book isn't as easy as you might think, and occasionally we make errors. In fact, we found just such an error yesterday.)

Anyway, back to this discussion, on the real exam, the questions are worded very carefully. The real exam says:

"compilation fails due to an error on line X"

The real exam DOES NOT say:

"the compiler will fail on line X"

This is a critical distinction that you MUST understand for the real exam! The problem in the real world is that not all Java compilers behave exactly the same way when they encounter an error. So it's not possible for anyone to predict exactly how a compiler will react. There is no official specification that compiler makers have to follow in this regard.

In other words, given one piece of code that doesn't compile, if you let different compilers look at this one piece of code, you are not guaranteed to get the same message from the different compilers. Sometimes you'll get the same messages, sometimes you won't.

Does that make sense?

Bert
 
Rahul Sudip Bose
Ranch Hand
Posts: 637
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bert Bates wrote:
This is a critical distinction that you MUST understand for the real exam! The problem in the real world is that not all Java compilers behave exactly the same way when they encounter an error. So it's not possible for anyone to predict exactly how a compiler will react. There is no official specification that compiler makers have to follow in this regard.

In other words, given one piece of code that doesn't compile, if you let different compilers look at this one piece of code, you are not guaranteed to get the same message from the different compilers. Sometimes you'll get the same messages, sometimes you won't.

Does that make sense?
Bert



I did not know that compilers can be so different. Thanks for letting me know. Which compiler did you use ? I will try it in that one to see the difference.
I had a doubt about compilers : Is javac the only compiler and IDE's like netbeans , eclipse etc use javac behind-the-scenes ? OR they have their own
compilers ?

Thanks once again.
regards
rb
 
Greenhorn
Posts: 16
Eclipse IDE Firefox Browser Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eclipse uses an own compiler. See Wikipedia.
 
Enthuware Software Support
Posts: 4810
52
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ikpefua Jacob-Obinyan wrote:
REMEMBER that the book was written by humans and we are all prone to mistakes at any given time.



And Mock Exams are written by super humans Just kidding.

Oh we so envy you Kathy and Bert to have such considerate clientele
 
Ikpefua Jacob-Obinyan
Ranch Hand
Posts: 394
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Paul, yea...I noticed you were joking , you see I was EXCLUSIVELY responding to the title of this thread... "Error in OCP programmer practice exams book : with proof". I guess you noticed that as well...
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic