Enumerations QuizS2C Home « Objects & Classes Quiz

The questions in this Java quiz are on the topics covered in the java - Objects & Classes section of the site. The table below lists the lesson used for each quiz, a description of the lesson content and the quiz number and questions associated with that lesson.

Lesson Summary

Click on a lesson in the table to go to that lesson for a refresher on the topics for that quiz.

Click on a quiz in the table to go straight to the quiz for a particular lesson.

Objects & Classes Lessons Description Quiz Info.
Lesson 1 - ArraysIn this lesson we look at arrays and how to use them in java.Quiz1
8 questions
Lesson 2 - Class Structure & SyntaxFor this lesson we looked at class structure and syntax within our Java programs.Quiz2
8 questions
Lesson 3 - Reference VariablesThis lesson is about reference variables and how to use them within our Java programs.Quiz3
7 questions
Lesson 4 - MethodsWe have used methods throughout the lessons so far so its time for a thorough investigation of what we can do with these members.Quiz4
10 questions
Lesson 5 - Instance Variables & ScopeThis lesson is about instance variables, how to use them and their scope.Quiz5
6 questions
Lesson 6 - ConstructorsIn this lesson we learn about constructors, which we can use to instantiate objects of our classes.Quiz6
7 questions
Lesson 7 - Static MembersFor this lesson we investigate what static means and how to apply it to our class members.Quiz7
6 questions
Lesson 8 - EnumerationsIn our final lesson of this section we go through enumerations which were introduced in java.This quiz.
8 questions

Java Objects & Classes Quiz 8

The quiz below tests your knowledge of the material learnt in Objects & Classes - Lesson 8 - Enumerations.

Question 1 : What are enumerations?
- Enumerations are lists of named constants
Question 2 : How do we declare an enumerated type?
- We use the <code>enum</code> keyword.
Question 3 : What are the identifiers TOMATO, CHICKEN and PRAWN in the code below known as?

- The identifiers TOMATO, CHICKEN and PRAWN are <em>enumeration constants</em>.
Question 4 : How do we create an enum singleton?
- We create an enum singleton using a single <em>enumeration constant</em> in our enum type.
Question 5 : Does the following switch statement use the enum below correctly?

Soup soup = Soup.PRAWN;
switch (soup) {
case Soup.CHICKEN:
System.out.println("Our " + soup + " soup has meat in it!");
case Soup.PRAWN:
System.out.println("Our " + soup + " soup has fish in it!");
- The <code>case</code> statements are incorrectly qualified with the enum type <code>Soup</code> and so the <code>switch</code> statement uses the enum incorrectly.
Question 6 : What does the predefined enum method values() return?
- the predefined enum method <code>values()</code> returns an array consisting of a list of enumeration constants.
Question 7 : How many objects are instantiated from the following enum declaration?

- An object is automatically instantiated for each <em>enumeration constant</em>, so in this case 3 objects.
Question 8 : What are enumeration constants implicitly declared as?
- All <em>enumeration constants</em> are implicitly declared as <code>public</code> and <code>static</code> members of their enum type.
Quiz Progress Bar Please select an answer

What's Next?

The next quizzes are on OO Concepts.