Cert Obj Use enumerated types
Quiz yourself by thinking what should be in
each of the black spaces below before clicking
on it to display the answer.
Help!
|
|
||||
---|---|---|---|---|---|
[2.5.1] enum stands for | list of constant values assigned to a type
🗑
|
||||
[2.5.2] enum type | enum constant's type is the enum type
🗑
|
||||
[2.5.3] where it cannot be declared | in a method or constructor!
🗑
|
||||
[2.5.4] what it cannot have as modifier when declared outside a class | protected-private-abstract-static-final
🗑
|
||||
[2.5.5] what it can have | constructors, methods, variables, and constant-specific
class bodies
🗑
|
||||
[2.5.6] constructor can have argument | enum constants can send arguments to the enum constructor, using the syntax BIG(8), where the int literal 8 is passed to the enum constructor.
🗑
|
||||
[2.5.7] constructor can be overloaded | enum constructors can have arguments and can be overloaded
🗑
|
||||
[2.5.8] constructor cannot be invoked by your code | called automatically when an enum is initialized.
🗑
|
||||
[2.5.9] have or not have | semicolon - both are legal
🗑
|
||||
[2.5.10] illegal for enum | Unlike a regular java class, you cannot access a non-final static field from an enum's constructor. ( JLS 8.9.2 )
🗑
|
||||
[2.5.11] Enum declaration rules | Enum constants (here, DOG, CAT, and FISH) must be declared before anything else. Can have an anonymous subclass of enum in constructor
🗑
|
||||
[2.5.12] enum constructor | cannot be public (either explicitly is implicitly private)
🗑
|
||||
[2.5.13] polymorphism | a) An enum is impliclty final, which means you cannot extend it. b). You cannot extend an enum from another enum or class because an enum implicitly extends java.lang.Enum. But an enum can implement interfaces.
🗑
|
||||
[2.5.14] clone() | Since enum maintains exactly one instance of its constants, you cannot clone it. You cannot even override the clone method in an enum because java.lang.Enum makes it final.
🗑
|
||||
[2.5.15]values() | 5. Compiler provides an enum with two public static methods automatically - values() and valueOf(String). The values method returns an array of its constants
🗑
|
||||
[2.5.16] valueOf(String) | valueOf(String) tries to match the String argument exactly (i.e. case sensitive) with an enum constant and returns that constant if successful otherwise it throws java.lang.IllegalArgumentException.
🗑
|
||||
[2.5.17] comparable() | It implements java.lang.Comparable (thus, an enum can be added to sorted collections such as SortedSet, TreeSet, and TreeMap).
🗑
|
||||
[2.5.18] ordinal() | It has a method ordinal(), which returns the index (starting with 0) of that constant i.e. the position of that constant in its enum declaration.
🗑
|
||||
[2.5.19] name() | It has a method name(), which returns the name of this enum constant, exactly as declared in its enum declaration.
🗑
|
Review the information in the table. When you are ready to quiz yourself you can hide individual columns or the entire table. Then you can click on the empty cells to reveal the answer. Try to recall what will be displayed before clicking the empty cell.
To hide a column, click on the column name.
To hide the entire table, click on the "Hide All" button.
You may also shuffle the rows of the table by clicking on the "Shuffle" button.
Or sort by any of the columns using the down arrow next to any column heading.
If you know all the data on any row, you can temporarily remove it by tapping the trash can to the right of the row.
To hide a column, click on the column name.
To hide the entire table, click on the "Hide All" button.
You may also shuffle the rows of the table by clicking on the "Shuffle" button.
Or sort by any of the columns using the down arrow next to any column heading.
If you know all the data on any row, you can temporarily remove it by tapping the trash can to the right of the row.
Embed Code - If you would like this activity on your web page, copy the script below and paste it into your web page.
Normal Size Small Size show me how
Normal Size Small Size show me how
Created by:
MVK2013
Popular Computers sets