About Question enthuware.ocpjp.v11.2.1255 :
Posted: Sun Jan 24, 2021 1:15 pm
If you try the code below, it would print "Exception" instead of "ClassNotFound", why the anwser is ClassNotFoundException?
Code: Select all
public void readData(String fileName) throws Exception {
try (FileReader fr1 = new FileReader(fileName)) {
Connection c = getConnection();
}
}
public static void main(String[] args) {
try {
new Test().readData("ss");
}
catch (ClassNotFoundException e) {
System.out.println("ClassNotFound");
} catch (Exception e) {
System.out.println("Exception");
}
}