InstructionsTotal Questions: 19Total Minutes: 19This ExamTray Free Online Test or Quiz or Trivia tests your Programming Skills on the basics of Java Enum. This practice test displays answers after finishing the exam for review. You can easily clear Competitive Exams and Job Interview Questions. Students can learn Java basics. Go through Java Theory Notes on Enum / Enumeration before attempting this test. All the Best Challenge SCORE0 / 19Take This Exam 1*2*3*4*5*6*7*8*9*10*11*12*13*14*15*16*17*18*19*Q Buttons 1) Java Enum is also called ___. A) Enumeration B) Numeration C) Iteration D) None of the above 2) Which is the keyword used to create an ENUM type in Java? A) enum B) Enum C) enumeration D) Enumeration 3) An ENUM type in Java is like a ____. A) interface B) class C) abstract class D) None of the above 4) An ENUM class in Java can contain ______. A) constructors B) methods C) variables and constants D) All the above 5) Which is true about enum constants in Java? A) Enum constants have index. B) The index starts with zero (0). C) Enum constant can be accessed using a DOT (.) operator D) All the above 6) Java enums are introduced in which version? A) Java 1.4 B) Java 1.5 C) Java 6 D) Java 8 7) An enum variable in java can take ___ as the assigned value in Java. A) Any integer B) Any non null object C) Enum constant only D) None of the above Ad 8) The name of an ENUM or the name of ENUM constant can be ____ in Java. A) A string of characters that starts with an Underscore, Dollar or Alphabet B) A string of characters that can contain numbers at any position other than zero C) A string of characters that can be an existing keyword D) All the above 9) What is the output of the below Java program with Enums? enum Car { SEDAN, HATCHBACK, SUV } public class EnumTest1 { public static void main(String[] args) { Car c1 = Car.SEDAN; System.out.println(c1.name() + ", " + c1); } } A) SEDAN, 0 B) SEDAN, SEDAN C) SEDAN, D) None of the above 10) What is the output of the below Java program with Enums? enum Bus { DIESEL, ELECTRIC, HYBRID int mileage = 10; } public class EnumTest2 { public static void main(String[] args) { Bus bus = Bus.ELECTRIC; System.out.println(bus + ", " + bus.mileage); } } A) ELECTRIC, 0 B) ELECTRIC, 10 C) 1, 0 D) Compiler error 11) Can you define STATIC variables and STATIC methods inside an ENUM in Java? A) Yes B) No C) - D) - 12) An ENUM can be defined in the place ____ in Java? A) Inside a class but outside of methods B) Outside a class or interface C) Inside an Interface but outside methods (abstract if any) D) All the above 13) An ordinal() method of an ENUM returns _____. A) Hash value B) Enum constant length C) Enum constant index which is zero based D) None of the above 14) Which is the correct way of implementing ENUM constants inside SWITCH statement in Java below? enum Marks { AVERAGE, GOOD, EXCELLENT; } public class EnumTest3 { public static void main(String[] args) { Marks student2 = Marks.GOOD; //MISSING SWITCH STATEMENT } } A) switch(student2) { case AVERAGE: System.out.println("Marks: 60"); break; case GOOD: System.out.println("Marks: 80"); break; case EXCELLENT: System.out.println("Marks: 90"); } B) switch(student2) { case Marks.AVERAGE: System.out.println("Marks: 60"); break; case Marks.GOOD: System.out.println("Marks: 80"); break; case Marks.EXCELLENT: System.out.println("Marks: 90"); } C) switch(student2) { case Marks.AVERAGE: System.out.println("Marks: 60"); break; case GOOD: System.out.println("Marks: 80"); break; case Marks.EXCELLENT: System.out.println("Marks: 90"); } D) switch(student2) { case Marks[0]: System.out.println("Marks: 60"); break; case Marks[1]: System.out.println("Marks: 80"); break; case Marks[2]: System.out.println("Marks: 90"); } Ad 15) Can you pass values to ENUM constructors in Java? A) No B) Yes C) - D) - 16) What is the output of the below Java code with Enums and Constructors? enum Ship { BOAT(5), SHIP(10), VESSEL(100); int capacity; Ship(int i) { capacity = i; } Ship(){} void show() {System.out.println("Capacity: " + capacity);} } public class EnumTest4 { public static void main(String[] args) { Ship s1 = Ship.BOAT; s1.show(); } } A) Capacity: 5 B) Capacity: 0 C) Capacity: 10 D) Capacity: 100 17) What is the output of the below Java code with constructors? enum Human { KID(10), BOY(30), MAN(60); Human(int weight) { System.out.println("Weight: " + weight); } } public class EnumTest5 { public static void main(String[] args) { Human he = Human.KID; } } A) Weight: 10 Weight: 30 Weight: 60 B) Weight: 10 Weight: 10 Weight: 10 C) Weight: 0 Weight: 0 Weight: 0 D) No output 18) Which is the correct way of looping through all ENUM constants in Java below? enum FRUIT { ORANGE, PEARS, PLUMS; } A) for(FRUIT fr2: FRUIT.values()) System.out.println(fr2); B) //new ENUM array FRUIT ary[] = new FRUIT[3]; ary[0] = FRUIT.ORANGE; ary[1] = FRUIT.PEARS; ary[2] = FRUIT.PLUMS; for(FRUIT fr: ary) System.out.println(fr); C) Both A and B D) None of the above 19) An ENUM can implement an INTERFACE. State TRUE or FALSE. A) TRUE B) FALSE C) - D) - FINISH EXAM 1*2*3*4*5*6*7*8*9*10*11*12*13*14*15*16*17*18*19*PREV Java Autoboxing Online Test NEXT Certification Group ID 0