I came across a question :
import java.io.*;
public class TechnoSample
{
public static void main(
String[] args)
{
TechnoSampleSub myref = new TechnoSampleSub();
try
{
myref.test();
}
catch(IOException ioe){}
}
void
test() throws IOException
{
System.out.println("In TechnoSample");
throw new IOException();
}
}
class TechnoSampleSub extends TechnoSample
{
void test()
{
System.out.println("In TechnoSampleSub");
}
}
When I compiled this , it gave me a compile-time error, but after I changed all IOException in the three places to Exception, it compiled and ran.
I know that when there was a compile error, it is due to the test() method in the subclass never throws a IOException, but I think after changed to Exception, the problem was still in existence.
Thanks Yi