Java - Interface Implementing and Exception

Introduction

You cannot add more exception when implementing interface methods

Adding constraints to an overridden method is never allowed.

class Exception1 extends Exception {
}

class Exception2 extends Exception {
}

class Exception3 extends Exception {
}

interface Banker {
  double withdraw(double amount) throws Exception3;

  void deposit(double amount) throws Exception2;
}

class MinimumBalanceBank implements Banker {
  public double withdraw(double amount) throws Exception3 {
    return 0.0;
  }

  public void deposit(double amount) throws Exception2 {
  }
}

class NoLimitBank implements Banker {
  public double withdraw(double amount) {
    return 0.0;
  }

  public void deposit(double amount) {
  }
}

// The following code will not compile
class UnstablePredictableBank implements Banker {
//withdraw() method adds a new exception, ArbitraryException, 
//which adds a new constraint to the overridden method. 
  public double withdraw(double amount) throws Exception3,
      Exception1 {
    return 0.0;
  }

  public void deposit(double amount) throws Exception2 {
    // Code for this method goes here
  }
}

public class Main {
  public static void main(String[] args) {
    Banker b = new MinimumBalanceBank();
    try {
      double amount = b.withdraw(1000.90);

    } catch (Exception3 e) {
    }

  }
}