Exceptions
Posted: Thu Dec 28, 2017 10:18 am
Hello, i have the following code:
why does compiler not complain that i dont treat the exception thrown in class Foo ? Why do i not have to wrap the call to new Bar().process() in a try/Catch block ?
Code: Select all
class Foo
{
void process() throws Exception{
System.out.println("Foo");
throw new Exception();
}
}
class Bar extends Foo{
void process(){
System.out.println("Bar");
}
public static void main(String[] args)
{
new Bar().process();
}
}