Aside from the good answers given by others about the compilability of your methods by themselves, there is the matter of implementing interfaces and overriding methods in super-classes.
The rule says that you can override/implement a method, but you cannot declare additional exception to those declared by the original method signature. To understand this, think of this example.
Let's say you're using some sort of data structure:
public abstract class AbstractBox {
public abstract void addItem(Item newItem);
public abstract void removeItem(Item oldItem);
}
You have your own implementation, but you decide to declare exceptions that do not appear in the original signature:
public class MyBox extends AbstractBox {
public void addItem(Item newItem) throws ItemAlreadyPresentException {...}
public void removeItem(Item oldItem) throws NoSuchItemException {...}
}
Now let's consider this generic code that handles Box objects, and receives an instance of MyBox:
public void boxHandler(AbstractBox box) {
Item item = new Item();
box.removeItem(item);
}
Whoever wrote this code wasn't expecting any exceptions, nor did she intend to handle implementor exceptions. To prevent this, the compiler will not allow you to declare additional exceptions to those in the original signature.
Of course, if you handle exceptions internally... well, the compiler will be more than happy to allow you to drop declared exceptions from your signature ;-)
Hope this helps...
Yuval =8-)