• 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

Amount of lines of code that does not compile to answer in OCA exam

 
Ranch Hand
Posts: 84
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys. The following example is based on exercice 71 p.179 from OCA/OCP Practice Test of Scott and Jeanne.

The exercice asks about how many lines of the application does not compile. Well, in the code below i will transcribe the application and I make a change on line 13 by adding a new error changing the original name of the variable "ex" by "e".

So, leaving the code like this and running javac commmand, compiler says that there is an error on line 13:
Test.java:13: error: variable e is already defined in method make()
} catch(Exception e){

But besides this error i know there are another two on lines 10 and 23. And a proof of this is that if i fix the error from line 13, and then i run again javac, now the compiler will say that there are two compiler errors on those two lines (10 and 23).

So what would be the right answer for the exam?.
* There are one compiler error (based on what originally compiler says)

* There are three compiler errors based on what we can see about the code.

 
author & internet detective
Posts: 41860
908
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
Three because that's how many things are wrong.

The real exam is more likely to ask you whether a specific line has a compiler error. Or if there are any. We like to make you count so we get you to think more. If you can solve our harder questions, you'll have no trouble on the real exam!
reply
    Bookmark Topic Watch Topic
  • New Topic