Java Quiz 2 : Data Types By Tejas Chaudhari - August 23, 2021 FacebookTwitterPinterestWhatsApp Welcome to your Java Quiz 2 : Data Types 1. What is the order of variables in Enum?a) Ascending orderb) Descending orderc) Random orderd) Depends on the order() method 2. Can we create an instance of Enum outside of Enum itself?a) Trueb) False 3. What will be the output of the following Java code? enum Season { WINTER, SPRING, SUMMER, FALL }; System.out.println(Season.WINTER.ordinal()); a) 0b)c) 2d) 3 4. If we try to add Enum constants to a TreeSet, what sorting order will it use?a) Sorted in the order of declaration of Enumsb) Sorted in alphabetical order of Enumsc) Sorted based on order() methodd) Sorted in descending order of names of Enums 5. What will be the output of the following Java code snippet? class A { } enum Enums extends A { ABC, BCD, CDE, DEF; } a) Runtime Errorb) Compilation Errorc) It runs successfullyd) EnumNotDefined Exception 6. What will be the output of the following Java code snippet? enum Levels { private TOP, public MEDIUM, protected BOTTOM; } a) Runtime Errorb) EnumNotDefined Exceptionc) It runs successfullyd) Compilation Error 7. What will be the output of the following Java code snippet? enum Enums { A, B, C; private Enums() { System.out.println(10); } } public class MainClass { public static void main(String[] args) { Enum en = Enums.B; } } a) 10 10 10b) Compilation Errorc) 10 10d) Runtime Exception 8. Which method returns the elements of Enum class?a) getEnums()b) getEnumConstants()) getEnumList()d) getEnum() 9. Which class does all the Enums extend?a) Objectb) Enumsc) Enumd) EnumClass 10. Are enums are type-safe?a) Trueb) False 11. Which of the following is the advantage of BigDecimal over double?a) Syntaxb) Memory usagec) Garbage creationd) Precision 12. Which of the below data type doesn’t support overloaded methods for +,-,* and /?a) intb) floatc) doubled) BigDecimal 13. 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.01b) 0.01 0.009999999999999998c) 0.01 0.01d) 0.009999999999999998 0.009999999999999998 14. What is the base of BigDecimal data type?Add description here!a) Base 2b) Base 8c) Base 10d) Base e 15. What is the limitation of toString() method of BigDecimal?a) There is no limitationb) toString returns nullc) toString returns the number in expanded formd) toString uses scientific notation Time is Up!