Menu
Question Index
...

What will be the output of following program?

public class Valid {
    public static void parse(String str) {
        int f = 5;
        try {
            int f1 = Integer.parseInt(str);
        } catch (NumberFormatException nfe) {
        } finally {
            f = 0;
            System.out.print(f + "-");
        }
    }
    public static void main(String[] args) {
        Valid.parse(args[0]);
        System.out.print("invalid");
    }
}


0-invalid
5-invalid
invalid
Some other output
Compilation Error or Runtime Error

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