Q. 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
πŸ’¬ Discuss
βœ… Correct Answer: (A) 0.009999999999999998 0.01

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
98
Total Visits
πŸ“½οΈ
1 y ago
Published
πŸŽ–οΈ
Ritu Nagar
Publisher
πŸ“ˆ
89%
Success Rate