Example: NumberFormatException

Single Choice
Views 31

Answer:


public class UncheckedExample4 {
    public static void main(String[] args) {
        try {
            String s = "abc";
            int num = Integer.parseInt(s); // Invalid conversion
        } catch (NumberFormatException e) {
            System.out.println("Invalid number format!");
        }
    }
}

Related Articles:

This section is dedicated exclusively to Questions & Answers. For an in-depth exploration of Java Programming Language, click the links and dive deeper into this subject.

Join Our telegram group to ask Questions

Click below button to join our groups.