All times are UTC - 5 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: About Question enthuware.ocajp.i.v8.2.1385 :
PostPosted: Fri Oct 14, 2016 1:13 am 
Offline

Joined: Mon Oct 03, 2016 3:41 am
Posts: 5
A student submitted the following error and it was verified by a course mentor:


I've attached screenshots about a question I believe may be incorrectly written. In my understanding the method doSomethingElse() is throwing an unchecked expression therefor should be wrapped in either a try/catch or declared thrown in the signature or it will be a compiler error. The material however ignores this fact.

http://screencast.com/t/uSYprVQH
http://screencast.com/t/08xgVslaUB


Top
 Profile Send private message  
 
 Post subject: Re: About Question enthuware.ocajp.i.v8.2.1385 :
PostPosted: Fri Feb 17, 2017 2:12 pm 
Offline

Joined: Wed Feb 08, 2017 5:42 pm
Posts: 27
MyException class must extends RuntimeException.

I can't see this in your images.


Top
 Profile Send private message  
 
 Post subject: Re: About Question enthuware.ocajp.i.v8.2.1385 :
PostPosted: Fri Feb 17, 2017 9:30 pm 
Offline
Site Admin

Joined: Fri Sep 10, 2010 9:26 pm
Posts: 6513
corptrainer1 wrote:
I've attached screenshots about a question I believe may be incorrectly written. In my understanding the method doSomethingElse() is throwing an unchecked expression therefor should be wrapped in either a try/catch or declared thrown in the signature or it will be a compiler error.

Your understanding is not correct. An unchecked exception need not be caught or be declared in the throws clause.


Top
 Profile Send private message  
 
 Post subject: Re: About Question enthuware.ocajp.i.v8.2.1385 :
PostPosted: Fri Jun 09, 2017 9:02 am 
Offline

Joined: Wed Jun 07, 2017 3:13 am
Posts: 5
How can I modify the code to remove the ArrayIndexOutOfBoundsException and see MySpecialException in action?


Top
 Profile Send private message  
 
 Post subject: Re: About Question enthuware.ocajp.i.v8.2.1385 :
PostPosted: Fri Jun 09, 2017 9:18 am 
Offline
Site Admin

Joined: Fri Sep 10, 2010 9:26 pm
Posts: 6513
Instead of calling doSomething(); in main, you can call doSomethingElse();


Top
 Profile Send private message  
 
 Post subject: Re: About Question enthuware.ocajp.i.v8.2.1385 :
PostPosted: Fri Jun 09, 2017 9:22 am 
Offline

Joined: Wed Jun 07, 2017 3:13 am
Posts: 5
There is a CTE saying 'Cannot resolve MySpecialException.


Top
 Profile Send private message  
 
 Post subject: Re: About Question enthuware.ocajp.i.v8.2.1385 :
PostPosted: Fri Jun 09, 2017 9:46 am 
Offline
Site Admin

Joined: Fri Sep 10, 2010 9:26 pm
Posts: 6513
Well, you have to write it as well. The problem statement says, (Assume that MySpecialException is an unchecked exception.) Adding the following line will do -

class MySpecialException extends RuntimeException{ }


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: Bing [Bot] and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Template made by DEVPPL/ThatBigForum