Answer:
See explaination
Explanation:
//class extends Exception
class ParameterNotAllowedException extends Exception {
//Instance variable
private int input;
//Argumented constructor
public ParameterNotAllowedException(String message, int input) {
super(message);
this.input = input;
}
public int getInput() {
return input;
}
public void setInput(int input) {
this.input = input;
}
atOverride // Replace the "at" with at symbol ie shift 2
public String getMessage() {
//Returns the message
return input+" is invalid. "+super.getMessage();
}
}
class Main {
public static void main(String[] args) throws ParameterNotAllowedException {
int n = -1;
//Throw negative not allowed exception
if(n<0){
throw new ParameterNotAllowedException("negative number",n);
}
}
}