Pl explain me
interface AnInterface
{
public void methodOne() throws Exception;
}
class AnInterfaceImpl implements AnInterface
{
public void methodOne()
{
System.out.println("I will never throw an exception");
}
}
public class ATest
{
public static void main(
String args[])
{
//AnInterface ai = new AnInterfaceImpl();
//AnInterfaceImpl ai = new AnInterfaceImpl();
ai.methodOne();
}
}
1. AnInterImpl class methodOne() does not throw any Exception. Is it proper to implement this way?
2. when u uncomment the 2nd line, it displays "I will never throw...exception", but when u uncomment first line, causes a compile time error. ( Exception must be caught or thrown by main(String))