TOTAL QS = 19Time [ 00 : 00 : 00 ]
00:00:00

Java Enum Basics Online Practice Test 1

Instructions

Total Questions: 19

Total Minutes: 19

This 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 SCORE

0 / 19

Take This Exam
1) Java Enum is also called ___.
2) Which is the keyword used to create an ENUM type in Java?
3) An ENUM type in Java is like a ____.
4) An ENUM class in Java can contain ______.
5) Which is true about enum constants in Java?
6) Java enums are introduced in which version?
7) An enum variable in java can take ___ as the assigned value in Java.
8) The name of an ENUM or the name of ENUM constant can be ____ in Java.
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);
  }
}
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);
  }
}
11) Can you define STATIC variables and STATIC methods inside an ENUM in Java?
12) An ENUM can be defined in the place ____ in Java?
13) An ordinal() method of an ENUM returns _____.
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
  }
}
15) Can you pass values to ENUM constructors in Java?
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();
  }
}
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;
  }
}
18) Which is the correct way of looping through all ENUM constants in Java below?
enum FRUIT
{
  ORANGE, PEARS, PLUMS;
}
19) An ENUM can implement an INTERFACE. State TRUE or FALSE.
Certification Group ID
0

Open Certification Helper Popup Reset Popup