Saturday, July 14, 2018

Exception piece of code output ?

Problem statement: what will be the output of the below code?
import java.io.FileNotFoundException;
import java.io.IOException;
class A {
    public void run() throws FileNotFoundException {
        System.out.println("A");
    }
}
class B extends A {
    public void run() throws IOException {
        System.out.println("B");
    }
}
public class ExceptionFileNotFound {
    public static void main(String args[]) {
        B a = new B();
        a.run();
    }
}
Output:
compilation error
run() method in A class clashes with run() method in B class.
Overriden method does not throw Exception

No comments:

Post a Comment

How to run standalone mock server on local laptop

 Please download the standalone wiremock server from Direct download section at the bottom of the page.  Download and installation Feel fre...