Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization 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
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

OCA / OCP Java SE 8 Programmer Practice Tests: Chapter 4 Question 16 Errata?

 
Ranch Hand
Posts: 434
8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Answer is both m3 and m4?  Or should I have interpreted the question to be which line of code is the first to cause the ArrayIndexOutOfBoundsException?
Chapter4Q16ErrataQuestion2017-05-27_12-28-49.png
[Thumbnail for Chapter4Q16ErrataQuestion2017-05-27_12-28-49.png]
 
author & internet detective
Posts: 40359
820
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
Charles,
Once line m3 throws the exception, the code is no longer continuing to run. Since m4 never runs, it doesn't  have the opportunity to throw an exception. I agree that if line m3 were commented out, line m4 would be the answer.

Also note that only one answer is correct in all chapters except the two mock exam chapters. And in the mock exam chapters, we tell you how many are correct if more than one.

We do this to better simulate the exam where you know how many are correct. Which lets you use the # of answers as a clue to the answer - a good skill to have for the real exam!
 
Charles O'Leary
Ranch Hand
Posts: 434
8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Agreed ... trying to find ways to increase my speed (18 & 26 use "first"  ... book thorough has been pretty consistent about treating each line separately)
 
Jeanne Boyarsky
author & internet detective
Posts: 40359
820
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
Charles,
We tried to write "first" with compiler errors. The reason being you get all the compiler errors at the same time when you type javac. There's still a "first" one, but it feels less straightforward. For #16 (runtime), it is more clear what causes the error.

Note i said "tried". I'm sure there are examples in the book where we didn't follow this.
 
Charles O'Leary
Ranch Hand
Posts: 434
8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Understood.  Thanks Jeanne.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is a typo in the answer explanation in the online version. It says "Line m3 attempts to reference the third element of the outer array.", but it should be the second element.
 
I'm thinking about a new battle cry. Maybe "Not in the face! Not in the face!" Any thoughts tiny ad?
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic