Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • 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
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

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: 3778
40
  • 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: 9695
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: 41184
848
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