• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

OCP 17 Study Guide Chapter 5 Review Question 14

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why is every online Java compiler showing only 2 errors while JShell is showing 4 errors. I understand the solution clearly that the correct answer is 4 errors but still I was curious. If someone can help see the attached screenshot.
Screenshot-from-2022-07-07-12-50-46.png
[Thumbnail for Screenshot-from-2022-07-07-12-50-46.png]
 
Bartender
Posts: 3958
43
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Vishal !
Welcome to CodeRanch!
Apparently JShell provides more accurate report.
You should address your question to the creators of the online service, indeed there are more problems than 2.
Also, I am not sure if exam really will ask you questions like: how many lines are invalid (at least there was no such pattern on older exams)
Best regards,
MZ
 
Vishal Singh Adhikari
Greenhorn
Posts: 2
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So the thing is these online compilers are just displaying the output of "javac" from OpenJDK which I confirmed by compiling this program in my local javac and that shows 2 errors too.

So by chance, a question comes like this in the exam which asks for the total lines with errors do I need to answer it according to javac or JShell?
 
Sheriff
Posts: 9709
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As Mikalai mentioned, there is generally an option which says the code won't compile, but it won't ask how many lines won't compile. The creators of the exam make extra effort to make questions which are not ambiguous (or dependent on compiler behavior like this).
 
author & internet detective
Posts: 42151
937
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
They may also ask if a given line compiles. We ask for # of lines or first line to make our questions harder and you to be better prepared. And we use javac as the source of truth. (Sometimes IDEs give different counts as well)
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic