Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning 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
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Clarification on question from assessment test in the OCP java 11 book

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Can you please clarify the answer to this question from the book:

Which of the following statements about error handling in Java are correct? (Choose all that apply.)

A)Checked exceptions are intended to be thrown by the JVM (and not the programmer).
B)Checked exceptions are required to be handled or declared.
C)Errors are intended to be thrown by the JVM (and not the programmer).
D)Errors are required to be caught or declared.
E)Runtime exceptions are intended to be thrown by the JVM (and not the programmer).
F)Runtime exceptions are required to be handled or declared.

the book says the answer is -  B, C
my assertion is that the answer is B, C and E
could you please clarify why E) is not a correct statement?

thanks
Bobby

I am using this book:
OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide
by Jeanne Boyarsky, Scott Selikoff
 
Master Rancher
Posts: 3704
44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because runtime exceptions can be thrown by the JVM or the programmer.  It's totally OK.  You can get into arguments over whether you should use a checked or runtime exception in a given situation (which I will skip over for the moment)... but one way or another, there are situations where it's appropriate for a programmer to throw a runtime exception.
 
Bobby Kareer
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the answer.  I guess the "intended" made me select this as a valid choice.  probably just overthinking it...
 
author & internet detective
Posts: 40246
819
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bobby,
"Intended" means the language designers imagined people would. As a counterexample, nothing stops you form writing "throw new Error()". But you shouldn't and the language designers certainly didn't intend for you to!
 
Bobby Kareer
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
another question clarification:

chapter 1: question 14 : Which options are valid on the jar command without considering module options? (Choose all that apply.)
answer given : A, B, C, E
I did not include [C] in my answer which seems to be correct if you run the jar command (don't see any -cp option)
 
Jeanne Boyarsky
author & internet detective
Posts: 40246
819
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bobby Kareer wrote:another question clarification:

chapter 1: question 14 : Which options are valid on the jar command without considering module options? (Choose all that apply.)
answer given : A, B, C, E
I did not include [C] in my answer which seems to be correct if you run the jar command (don't see any -cp option)


Yes. As noted in your other post, this is listed as an errata
 
He does not suffer fools gladly. But this tiny ad does:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic