Consider the following interface:
package hf;
public interface BadInterface
{
void meth() throws Exception;
}
Which is implemented by the following class:
package hf;
public class apples implements BadInterface
{
public static void main(String[] args)
{
new apples().meth();
}
public void meth()
{
System.out.println("Ding dong meth.");
}
}
Although meth() is a method that throws an exception, the caller of the method meth() is not having to handle or declare the exception and yet the program runs successfully. Why is this the case? Does it not violate the rule that whenever you call a method that throws an exception, you need to catch the exception or declare that you throw the exception yourself?