Basic Datatypes


  1. What is the output of below code snippet?

    class Z
    {

    }

    enum Enums extends Z
    {
    DCB, FEG, HIJ, LMN;
    }












  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    Enum types cannot extend class.


  1. What is the output of below code snippet?

    enum Levels
    {
    private BOTTOM,

    public MEDIUM,

    protected TOP;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Enum cannot have any modifiers. They are public, static and final by default.



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