Examveda
Examveda

What will be the output of the following Java code snippet?
double a = 0.02;
double b = 0.03;
double c = b - a;
System.out.println(c);

BigDecimal _a = new BigDecimal("0.02");
BigDecimal _b = new BigDecimal("0.03");
BigDecimal _c = b.subtract(_a);
System.out.println(_c);

A. 0.009999999999999998
0.01

B. 0.01
0.009999999999999998

C. 0.01
0.01

D. 0.009999999999999998
0.009999999999999998

Answer: Option A


This Question Belongs to Java Program >> Data Types And Variables

Join The Discussion

Related Questions on Data Types and Variables