import java.io.FileNotFoundException; import java.io.IOException; public class O { public static void main(String[] args) { Father f = new son(); try { f.method1(); } catch(IOException e) { e.printStackTrace(); } } } class Father { public void method1() throws IOException { } public void method2() throws RuntimeException { } public Number method3() { return null; } } class son extends Father { public void method1() throws FileNotFoundException { } public void method2() { } public Integer method3() { return null; } }
import java.io.FileNotFoundException;
import java.io.IOException;public class O
{
public static void main(String[] args)
{
Father f = new son();
try
{
f.method1();
}
catch(IOException e)
{
e.printStackTrace();
}}
}class Father
{
public void method1() throws IOException
{}
public void method2() throws RuntimeException
{}
public Number method3()
{
return null;
}
}class son extends Father
{
public void method1() throws FileNotFoundException
{}
public void method2()
{}
public Integer method3()
{
return null;
}
}
JAVA异常与父子类继承的相关实验------JAVA
于 2023-05-03 13:27:24 首次发布