throws/throw
posted 25 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
please explain in detail
Given the following incomplete method.
1. public void method(){
2.
3. if (someTestFails()){
4.
5. }
6.
7.}
You want to make this method throw an IOException if, and only if, the method someTestFails() returns a value of true. Which changes achieve this?
A. Add at line 2: IOException e;
B. Add at line 4: throw e;
C. Add at line 4: throw new IOException();
D. Add at line 6: throw new IOException();
E. Modify the method declaration to indicate that an object of [type] Exception might be thrown.
ans given are d and e???I thought it was only c
Given the following incomplete method.
1. public void method(){
2.
3. if (someTestFails()){
4.
5. }
6.
7.}
You want to make this method throw an IOException if, and only if, the method someTestFails() returns a value of true. Which changes achieve this?
A. Add at line 2: IOException e;
B. Add at line 4: throw e;
C. Add at line 4: throw new IOException();
D. Add at line 6: throw new IOException();
E. Modify the method declaration to indicate that an object of [type] Exception might be thrown.
ans given are d and e???I thought it was only c
posted 25 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
to my point ans -> shud be C and E ...
if u r throwing any Checked exception, either u catch them or ur method shud declare in it's declaration signature.
Ashish
if u r throwing any Checked exception, either u catch them or ur method shud declare in it's declaration signature.
Ashish
posted 25 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
yes annswer c and e are right
[This message has been edited by amutha chellappan (edited September 22, 2000).]
[This message has been edited by amutha chellappan (edited September 22, 2000).]
posted 25 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hema,
The correct answers are C and E.
Here is a little program you can run to understand why:
Hope this helps.
Stephanie
The correct answers are C and E.
Here is a little program you can run to understand why:
Hope this helps.
Stephanie
| Get out of my mind! Look! A tiny ad! The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |






