Enums Flashcards

1
Q

What are general enum methods?

A

valueOf, name, ordinal, values

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

How to check equality of enums?

A

==

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

Are enums extendable?

A

No

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

Can enums implement interfaces?

A

Yes

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

When do enums initialize?

A

When first time their values are called or evaluated. If there is static reference to it, then it is called then. Their constructor is called as many times as there are values.

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

How do we use enums in switch statements?

A

We use their reference, not actual name of the enum

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

How do simple enums look like?

A

They only contain values of enum.

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

How do complex enums look like?

A
  • They contain private constructor, or constructor where access modifier is omitted
  • Each enum value contains constructor call with defined literal. Also, each enum value can contain normal methods
  • Between each value there is comma. If enum contains constructor or methods, values end with “;”.
  • If values have methods, then those values must implement interface
  • If values don’t have methods, then enum implements interface
  • There cannot be combination of values with methods, and without
How well did you know this?
1
Not at all
2
3
4
5
Perfectly