Menu
Question Index
...

What will be the output of the following program?

import java.text.*;

public class Number {
    public static void main(String str[]) {
        try {
            String num = "12one3456.789";
            NumberFormat form = NumberFormat.getInstance();
            System.out.println("Before parse the number is : " + form.parse(num));
            System.out.println("After parse the number is : " + form.parse(num));
        } catch (ParseException pe) {
            System.out.println("Parse Exception thrown");
        }
    }
}


Before parse the number is : 12
After parse the number is : 12
Before parse the number is : 3456.789
After parse the number is : 3456
Before parse the number is : 3456
After parse the number is : 3456.789
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Other Advanced Topics 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