Forums Register Login

throw or throws ?

+Pie Number of slices to send: Send


How will you declare mymethod so that it will throw a Exception? Select one?
A. In method declaration give throw Exception and inside the method
give throws Exception
B. In method declaration give throws Exception and inside the method
give throw Exception
C. In method declaration give throw Exception and inside the method
give throw Exception
D. In method declaration give throws Exception and inside the method give throws Exception
Ans:A

I don't really get it..why the answers is A not B?
+Pie Number of slices to send: Send
Please QuoteYourSources. And welcome to the ranch !
+Pie Number of slices to send: Send
 

Christophe Verré wrote:Please QuoteYourSources. And welcome to the ranch !



Sources are all here.

I think B is right answer,so...
+Pie Number of slices to send: Send
 

Jingxian Zhou wrote:Sources are all here


Give name of source
+Pie Number of slices to send: Send
 

Jingxian Zhou wrote:Sources are all here.


Jingxian you are supposed to tell us the name of the mock exam or book from where you took this question. Only then would we be able to help you with the question...
I've been selected to go to the moon! All thanks to this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 809 times.
Similar Threads
Difference between throw and throws
Throwing Exceptions
JavaCaps mock 1 Q:9
Checked and Unchecked Exceptions
difference B/w Throw and throws
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 07:52:15.