Why is there no output when otherMethod is called?

Given the code fragment:

Why is there no output when otherMethod is called?

Given the code fragment:

Why is there no output when otherMethod is called?

A.
An exception other than IOException is thrown.

B.
Standard error is not mapped to the console.

C.
There is a compilation error.

D.
The exception is suppressed.

Explanation:

C: wenn printStackTrace() ohne Referenz auf das Exception object aufgerufen
A : java.io.FileNotFoundException: wenn e.printStackTrace();
The code compiles fine
The line
FileInputStream fis = new FileInputStream(file))
will fail at runtime since file is an empty string.
Note:
public void printStackTrace()
Prints this throwable and its backtrace to the standard error stream.



Leave a Reply 6

Your email address will not be published. Required fields are marked *


Charles

Charles

Should be B

l0c

l0c

Nope, should be C. printStacktrace() is not a method. printStacktrace() is a method of Exception, so for it to work it should be e.printStacktrace().