Basic Datatypes


  1. Which class does all the Enums extend?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    All enums implicitly extend java.lang.Enum. Since Java does not support multiple inheritance, an enum cannot extend anything else.


  1. Are enums are type-safe?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Enums are type-safe as they have own name-space.



  1. Which of the following is the advantage of BigDecimal over double?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    BigDecimal has unnatural syntax, needs more memory and creates great amount of garbage. But it has high precision which is useful for some calculations like money.


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











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    int, float, double provide overloaded methods for +,-,* and /. BigDecimal does not provide these overloaded methods.



  1. What is the output of below code snippet?

    double d = 0.02;
    double e = 0.03;
    double f = e - d;
    System.out.println(c);

    BigDecimal _d = new BigDecimal("0.02");
    BigDecimal _e = new BigDecimal("0.03");
    BigDecimal _f = b.subtract(_d);
    System.out.println(_f);











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    BigDecimal provides more precision as compared to double. Double is faster in terms of performance as compared to BigDecimal.