Menu
Question Index
...

What will be the output of the following program?

public class Number {
    public static void main(String args[]) {
        String numbers[] = {"1", "two", "3", "four"};
        try {
            for (String number : numbers)
                System.out.print(Integer.parseInt(number) + " ");
        } catch (NumberFormatException e) {
            System.out.println("number format exception");
        }
    }
}


1 two 3 four
1 number format exception
1 3 number format exception
1 two 3 four number format exception
Compilation Error or Runtime Error for some other reason

Doubts

Problems

Topic: Converting Numbers to and from Strings In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App