You should always catch the most specific exception type you expect, not a generic one:
try {
int num = Integer.parseInt(userInput);
} catch (NumberFormatException e) {
System.out.println("Enter a valid number");
}
Catching Exception or Throwable would also compile, but it hides bugs. If your code has a NullPointerException from a programming mistake, catching Exception silently swallows it. You would never know the bug exists.
Catch the specific type you expect. Let everything else propagate so it surfaces during testing. This makes your error handling precise and your bugs visible.