Java Quiz 2 : Data Types

    Welcome to your Java Quiz 2 : Data Types

    1. What is the order of variables in Enum?
    2. Can we create an instance of Enum outside of Enum itself?
    3. What will be the output of the following Java code?
    1.  enum Season 
    2.  {
    3.  WINTER, SPRING, SUMMER, FALL
    4.  };
    5.  System.out.println(Season.WINTER.ordinal());
    4. If we try to add Enum constants to a TreeSet, what sorting order will it use?
    5. What will be the output of the following Java code snippet?
    1. class A
    2. {
    3.  
    4. }
    5.  
    6. enum Enums extends A
    7. {
    8.  ABC, BCD, CDE, DEF;
    9. }
    6. What will be the output of the following Java code snippet?
    1.  enum Levels 
    2. {
    3.  private TOP,
    4.  
    5.  public MEDIUM,
    6.  
    7.  protected BOTTOM;
    8. }
    7. What will be the output of the following Java code snippet?
    1. enum Enums
    2. {
    3.  A, B, C;
    4.  
    5.  private Enums()
    6.  {
    7.  System.out.println(10);
    8.  }
    9. }
    10.  
    11. public class MainClass
    12. {
    13.  public static void main(String[] args)
    14.  {
    15.  Enum en = Enums.B;
    16.  }
    17. }
    8. Which method returns the elements of Enum class?
    9. Which class does all the Enums extend?
    10. Are enums are type-safe?
    11. Which of the following is the advantage of BigDecimal over double?
    12. Which of the below data type doesn’t support overloaded methods for +,-,* and /?
    13. What will be the output of the following Java code snippet?
    1.  double a = 0.02;
    2.  double b = 0.03;
    3.  double c = b - a;
    4.  System.out.println(c);
    5.  
    6.  BigDecimal _a = new BigDecimal("0.02");
    7.  BigDecimal _b = new BigDecimal("0.03");
    8.  BigDecimal _c = b.subtract(_a);
    9.  System.out.println(_c);
    14. What is the base of BigDecimal data type?Add description here!
    15. What is the limitation of toString() method of BigDecimal?