Answer to Question #20640 in Java | JSP | JSF for nohra

Question #20640
If you try to open a file that does not exist using Scanner constructor, what type of exception will be thrown?
A) ScannerException
B) FileNotFoundException
C) FileException
D) NotFoundException
1
Expert's answer
2012-12-18T09:25:41-0500
If you try to opena file that does not exist using Scanner constructor, FileNotFoundException is generated.
for example:

public class main {

publicstatic void main(String[] args) throws FileNotFoundException
{
Scanners=new Scanner(new File(""));
}
}

if you try to run this code, it will generateFileNotFoundException

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS