Google Answers Logo
View Question
 
Q: java try/catch question ( No Answer,   3 Comments )
Question  
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?
Answer  
There is no answer at this time.

Comments  
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

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

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 Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy