Enumeration and Nested Class Flashcards

1
Q

Enumeration

A

A data type that contains a fixed set of constants

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

Using an enum

A

Period p;
p = Period.{enum data}

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

ordinal()

A

Returns an integers that represent constant’s position in the list of contants.

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

you can pass an invalid value and not find
out until runtime

A

numeric or String constants

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

With enums

A

it is impossible to create an invalid enum value
without introducing a compiler error

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

toString()

A

Returns the name of the calling constant object

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

static member class

A

has access to all static methods of the top-
level class

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

Non-static member class (inner class

A

requires an instance; it has
access to all data and methods of the top-level class.

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

Local class

A

defined within a method body Anonymous class – a special case of a local class that has not identifier

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

valueOf()

A

Accepts a string parameter and returns an enumeration constant

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

values()

A

Returns an array of the enumerated constants

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

equals()

A

Returns true if its argument is
equal to the calling object’s
value

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

compareTo()

A

the calling object’s ordinal value is less than that of the argument, 0 if they are the
same, and a positive integer if
the calling object’s ordinal value
is greater than that of the
argument

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