Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Confusing wording regarding compilation failure in Enthware's exam

 
Ranch Hand
Posts: 113
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The following question comes from one of Enthuware's mock exams.

Identify correct statement(s) about the following code:

You are supposed to select only one answer. Three of the possible answers are as follows:

  • Compilation error because of //1
  • Compilation error because of //3
  • Compilation error because of //1 and //3


  • The third answer is the correct answer. I know why line 1 fails (comma's aren't allowed in numbers) and why line 3 fails (duplicate case value). However, I selected the first answer, because line 1 is where the compilation fails and consequently halts. So the compilation error occurs because of line 1, and not because of line 3. When I try to run the code, only the error on line 1 is addressed:

    TwoReasonsToFail.java:5: error: <identifier> expected
                   int value = 1,000,000; //1
                                 ^
    TwoReasonsToFail.java:5: error: illegal start of expression
                   int value = 1,000,000; //1
                                    ^
    TwoReasonsToFail.java:5: error: ';' expected
                   int value = 1,000,000; //1
                                     ^
    3 errors



    Can I expect similar wording on the exam, and should I then always pick the options which has all the possible compilation failures, rather than the option that causes the first compilation failure (if these options are both present, that is)? Is the way Enthuware and the exam handle examples like these exactly the same?

    Thanks again!

    Regards,
    Shane
     
    author & internet detective
    Posts: 40035
    809
    Eclipse IDE VI Editor Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Shane,
    No. On the real exam, they will either ask for the first line to have a compiler error OR how many lines contain compiler errors. If the later, you'd answer two because there are two compiler issues in the code.
     
    Enthuware Software Support
    Posts: 4448
    41
    • Likes 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I agree that the options are not 100% clear but I would also like to mention that the wording of options that I have seen personally in one of the questions on my test (i.e. the real OCAJP8 test) was as follows -

    Compilation fails only at line n1
    Compilation fails only at line n2
    Compilation fails at line n1 and n2.

    I think the word "only" made it clear what the option was getting at.


     
    Jeanne Boyarsky
    author & internet detective
    Posts: 40035
    809
    Eclipse IDE VI Editor Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I saw the option Paul did as well on the real exam. I consider that a subset of how many lines fail in my mind so it didn't occur to me to mention it explicitly.
     
    Sheriff
    Posts: 11604
    178
    Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Shane Jensen wrote:However, I selected the first answer, because line 1 is where the compilation fails and consequently halts. So the compilation error occurs because of line 1, and not because of line 3.


    That doesn't really matter! Assume you fix the compiler error on line1, then the code snippet will still not compile successfully due to the compiler error on line3. Also please keep in mind that the compiler performs different steps to verify that no rules are violated: sometimes the compiler halts on the first compiler error, sometimes it doesn't. Knowing (and remembering) these differences (which might even be compiler dependent) would be really hard! The real exam will mention how many correct answers you must select, so you should be capable to pick the best fitting answer(s) when needed.

    Shane Jensen wrote:When I try to run the code, only the error on line 1 is addressed:


    I would be very surprised if you were able to run the above code snippet as it will not compile due to two compiler errors
     
    Rebecca Wolf
    Ranch Hand
    Posts: 113
    7
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Roel De Nijs wrote:

    Shane Jensen wrote:When I try to run the code, only the error on line 1 is addressed:


    I would be very surprised if you were able to run the above code snippet as it will not compile due to two compiler errors


    I know. My point was that the compilation error only addresses the error on line 1, so that would be the point where the compilation fails. Anyway, it's clear to me now what I can expect.
     
    Rebecca Wolf
    Ranch Hand
    Posts: 113
    7
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Jeanne, Paul and Roel,

    Thanks for the clarifications.

    Paul Anilprem wrote:I agree that the options are not 100% clear but I would also like to mention that the wording of options that I have seen personally in one of the questions on my test (i.e. the real OCAJP8 test) was as follows -

    Compilation fails only at line n1
    Compilation fails only at line n2
    Compilation fails at line n1 and n2.

    I think the word "only" made it clear what the option was getting at.



    That would be fine of course. These answers are slightly different, but clearly have a different meaning.
     
    Roel De Nijs
    Sheriff
    Posts: 11604
    178
    Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Shane Jensen wrote:My point was that the compilation error only addresses the error on line 1, so that would be the point where the compilation fails.


    I was just nitpicking about your choice of words: you can only "run" a Java class (application) if it was successfully compiled.
     
    Rebecca Wolf
    Ranch Hand
    Posts: 113
    7
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Roel De Nijs wrote:

    Shane Jensen wrote:My point was that the compilation error only addresses the error on line 1, so that would be the point where the compilation fails.


    I was just nitpicking about your choice of words: you can only "run" a Java class (application) if it was successfully compiled.


    Ah, right. Good point, thanks.
     
    crispy bacon. crispy tiny ad:
    Thread Boost feature
    https://coderanch.com/t/674455/Thread-Boost-feature
      Bookmark Topic Watch Topic
    • New Topic