![]() |
|
|
| Subject:
java try/catch question
Category: Computers > Programming Asked by: mike5-ga List Price: $3.00 |
Posted:
03 May 2004 08:29 PDT
Expires: 05 May 2004 08:58 PDT Question ID: 340293 |
Given the following
1. System.out.print("start ");
2. try {
3. System.out.print ("Hello World");
4. ?
5. throw new FileNotFoundException();
6. }
7. System.out.print(" Catch Here ");
8. Catch (EOFException e){
9. System.out.print("End of file exception");
10. }
11. catch(FileNotFoundException e){
12. System.out.print("File not found");
13. }
and assuming this block of code is placed into a class.
Will the code compile? If not, why? If yes, what is the output? |
|
| There is no answer at this time. |
|
| Subject:
Re: java try/catch question
From: manuvns-ga on 04 May 2004 12:09 PDT |
Remove the line number 7. it will throw following errors
'try' without 'catch' or 'finally'
try {
^
'catch' without 'try'
catch(EOFException e){
^
also there is error on line number 8 Catch (EOFException e){ make the
Catch to lowercase |
| Subject:
Re: java try/catch question
From: haddadi-ga on 05 May 2004 06:30 PDT |
try/catch works like a while loop, so make sure for every try there is a catch, use lowercase for all keywords, |
| Subject:
Re: java try/catch question
From: mike5-ga on 05 May 2004 08:58 PDT |
thanks for help |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
| Search Google Answers for |
| Google Home - Answers FAQ - Terms of Service - Privacy Policy |