Source Code:
public class OddCheck {
public static void checkNumber(int n) {
if(n % 2 != 0) {
throw new IllegalArgumentException(“Number is odd”);
}
System.out.println(“Number is even”);
}
public static void main(String[] args) {
try {
checkNumber(5);
} catch(Exception e) {
System.out.println(e.getMessage());
}
}
}
Output:
