Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming 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
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

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

 
Ranch Hand
Posts: 62
2
  • Mark post as helpful
  • send pies
  • 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: 39528
776
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • 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!
 
today's feeble attempt to support the empire
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!