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

Expert's answer

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!

LATEST TUTORIALS
APPROVED BY CLIENTS