• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Taking SCJD Exam Monday: Exceptions?

 
William Wagers
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
My wife and I are taking the written SCJD exam on Monday. Someone wrote that they ask about exception handling. What do they ask? What are reasonable responses? I really don't know what they are asking if they say, "Explain the exception handling in your code."
Thanks for the help.
 
Mike Southgate
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One thing I can think of is how you handle exceptions that are thrown but not covered in the specified interface (like IOException). You have to decide how you'll handle that. You can either have the methods throw unchecked exceptions or just use one of the exceptions the medhod does throw indstead of the real one. I wnt for the latter because using unchecked exceptions allows calling classes to ignore the exceptions altogether which is dangerous. Seems safer to document what you're doing and force them to handle the exceptions somehow.
ms
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well mostly my answer was that the Exceptions would be chained and thrown up to the client as much as possible. So if the client calls a method on my Facade, which in turn calls a method on the DataAccess class and it calls a method on the Data class, and there is an exception thrown. I make sure that the exception gets passed through up to the client, so that the client can handle it and display a message.
Handling exceptions is important. You want to handle them at the most appropriate point. For instance if the exception dealt with the server based on the server starting or such, the exception gets handled by the server, or in my case the server GUI. (You do not need to have a server GUI, it was a feature I decided to add).
If for instance you have an exception, and you don't pass it up to the client, and therefore the client either aborts abruptly, or never receives the message, then the user could get a false sense of security that their request was processed, even though it wasn't. Of course if it ends abruptly, without letting the client know, then the user gets very angry.
Thats a gist of what they ask.
Mark
 
William Wagers
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your help!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic