Basic Datatypes


  1. If we try to add Enum constants to a TreeSet, what sorting order will it use?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    Tree Set will sort the values in the order in which Enum constants are declared.


  1. What will ordinal() method provide?

    enum Season {
    WINTER, SPRING, SUMMER, FALL
    };
    System.out.println(Season.WINTER.ordinal());











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    ordinal() method provides number to the variables defined in Enum.



  1. Can we create instance of Enum outside of Enum itself?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    Enum does not have public constructor.


  1. What is the order of variables in Enum?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    The compareTo() method is implemented to order the variable in ascending order.



  1. What is the numerical range of a char data type in Java?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Char occupies 16-bit in memory, so it supports 2^16 i:e from 0 to 65535.