32). Which of the following is the advantage of BigDecimal over double?

[A]Syntax
[B]Memory usage
[C]Garbage creation
[D]Precision

Show Answer

33). Which of the below data type doesn’t support overloaded methods for +,-,* and /?

[A]int
[B]float
[C]double
[D]BigDecimal

Show Answer

34). 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

Show Answer

35). What is the base of BigDecimal data type?
   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]Base 2
[B]Base 8
[C]Base 10
[D]Base e

Show Answer

36). What is the limitation of toString() method of BigDecimal?
   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]There is no limitation
[B]toString returns null
[C]toString returns the number in expanded form
[D]toString uses scientific notation

Show Answer

37). Which of the following is not provided by BigDecimal?
   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]scale manipulation
[B] + operator
[C]rounding
[D]hashing

Show Answer

38). BigDecimal is a part of which package?
   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]java.lang
[B]java.math
[C]java.util
[D]java.io

Show Answer

39). What is BigDecimal.ONE?
   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]wrong statement
[B]custom defined statement
[C]static variable with value 1 on scale 10
[D]static variable with value 1 on scale 0

Show Answer

40). Which class is a library of functions to perform arithmetic operations of BigInteger and BigDecimal?
   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]MathContext
[B]MathLib
[C]BigLib
[D]BigContext

Show Answer

41). What will be the output of the following Java code snippet?
public class AddDemo 
{
	public static void main(String args[]) 
        {
		BigDecimal b = new BigDecimal("23.43");
		BigDecimal br = new BigDecimal("24");
		BigDecimal bres = b.add(new BigDecimal("450.23"));
		System.out.println("Add: "+bres);
 
		MathContext mc = new MathContext(2, RoundingMode.DOWN);
		BigDecimal bdecMath = b.add(new BigDecimal("450.23"), mc);
		System.out.println("Add using MathContext: "+bdecMath);
	}
}

[A]Compilation failure
[B]Add: 473.66 Add using MathContext: 4.7E+2
[C]Add 4.7E+2 Add using MathContext: 473.66
[D] Runtime exception

Show Answer