• 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

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

 
Ranch Hand
Posts: 499
9
  • 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: 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
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: 499
9
  • 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: 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
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: 499
9
  • 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.
 
Jeanne Boyarsky
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
It says second element in the printed book. Added to errata as online only
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic