Menu
Question Index
...

What will be the output of the following program?

import java.math.*;
import java.text.*;
import java.util.*;

public class Numbers
{
    public static String changeToDecimalFormat(Object number)
    {
        BigDecimal bdNumber = new BigDecimal(number.toString());
        bdNumber = bdNumber.stripTrailingZeros();
        String pattern = "###,##0.0###########";
        DecimalFormat newFormat = new DecimalFormat(pattern, new DecimalFormatSymbols(Locale.US));
        return newFormat.format(bdNumber);
    }
    public static void main(String args[])
    {
        int intVar = 25;
        System.out.println(Numbers.changeToDecimalFormat(new Integer(intVar)));
    }
}


10
25.0
25
0.0
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