Enums Flashcards

1
Q

An enum is

A

A special class that represents a group of constants (unchangeable variables like ‘final’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Enums should be in

A

Uppercase letters

enum Level = {
LOW,
MEDIUM,
HIGH
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Enum is short for

A

Enumeration which means specifically listed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

You can access enums with

A

The dot notation

Eg Level mylar = Level.MEDIUM

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

The enum has a values() method which returns

A

An array of all enum constants

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

The enum method is useful when you

A

Want to loop through the constants of an enum

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

An enum can just like a class have attributes and methods. The only difference is that the enum constants are

A

Public, static and final

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

An enum cannot be used to

A

Create objects

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

An enum cannot be used to extend other classes but can

A

Implement interfaces

How well did you know this?
1
Not at all
2
3
4
5
Perfectly