Menu
Topics Index
...
`

Decimal


If you need explanation Read this topic

If you need Answer Take test on this topic

Decimal
What will be the exact output of the following program?
import java.math.*;

public class DecimalValue {
    public static void main(String args[]) {
        BigDecimal payment = new BigDecimal(2.00);
        BigDecimal cost = new BigDecimal(1.10);
        System.out.println(payment.subtract(cost));
    }
}

A. .9
B. .90
C. 0.899999
D. Some other output
E. Compilation Error or Runtime Error
Topic: Java Math Class - java.lang.Math

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

ans is D as for BigDecimal objects the no. of digits after decimal point are much more..

Posted by Pramod Jain    2013-12-03 04:38:53


D is the ANswer.. for BigDecimal class objects digits aftr decimal point are more than 6...

Posted by Krishna Chaitanya Siliveru    2013-12-03 06:18:07


Congratulations Krishna Chaitanya Siliveru. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2013-12-04 04:06:25


© meritcampus 2019

All Rights Reserved.

Open In App