Advanced Enumerations QuizS2C Home « Advanced Enumerations

Java Objects & Classes Quiz 16

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

Question 1 : We can give enumeration constants a value?
- We CAN give <i>enumeration constants</i> a value
Question 2 : What are constant specific class bodies used for?
- We use <i>constant specific class bodies</i> to override enum methods.
Question 3 : Is the following code snippet valid?

enum Soup {
    TOMATO("vegetable"), CHICKEN("meat"), PRAWN("seafood");
    String type;
    String getType() {
        return this.type;
    }
}
- When giving <i>enumeration constants</i> a value we need to provide a constructor and the code snippet is missing one and so is invalid.
Question 4 : How do we create an enum singleton?
- We create an enum singleton using a single <i>enumeration constant</i> in our enum type.
Question 5 : Is an enum singleton immutable?
- An enum singleton is just a single enum type implicitly declared as a public static member of the enumerated class and so is therefore immutable.
Question 6 : If we give enumeration constants a value what else must be included in an enum class?
- If we give <i>enumeration constants</i> a value we must also include a constructor.
Quiz Progress Bar Please select an answer


What's Next?

The next quizzes are on OO Concepts.