Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Enum-doubt

 
joshua antony
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have some doubt on enum.
Are the points below correct?

1.. Enum cannot extend a class but can implement an interface.

2.. we cannot extend or implement enum

3.. Enum are implicitly final(i doubt but i read somewhere)

Any link regarding enum will be helpful
 
wise owen
Ranch Hand
Posts: 2023
 
Anupama Ponnapalli
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Here's a link to a tutorial on enums in pdf format:

http://www.oreilly.com/catalog/javaadn/chapter/index.html

In short:

1. Enum cannot extend a class but can implement an interface. true

2. we cannot extend or implement enum. true. Because enums are basically classes and when the byte code is generated, they are final. They are not interfaces, so they cannot be implemented.

3. Enums are implicitly final. true.

An interesting note on side: enums declared within class (enums that are not top level classes) are static by default whether use the keyword or not. But enums that are top level classes in their own files are not static, in fact, if you use the static keyword, a compile time error is raised.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic