wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes how non-static enum can be accessed without object? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "how non-static enum can be accessed without object?" Watch "how non-static enum can be accessed without object?" New topic
Author

how non-static enum can be accessed without object?

Mahesh Murugaiyan
Greenhorn

Joined: Jun 25, 2009
Posts: 21
Hello,

This is Question #3 in practice exam 2 in Bates/Sierra's Practice Exam book.
Numinor is a stand alone class with the "Members" enum. How can this enum(which is a non-static member of Numinor) accessed without creating an object for Numinor class?

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Mahesh Murugaiyan wrote:How can this enum(which is a non-static member of Numinor) accessed without creating an object for Numinor class?


But that question is based on the incorrect assertion that the enum is a non-static member of the class in which it's declared. Once you drop that idea, there's no problem at all.
Ninad Kulkarni
Ranch Hand

Joined: Aug 31, 2007
Posts: 787

Enums are implicitly static in class.


SCJP 5.0 - JavaRanch FAQ - Java Beginners FAQ - SCJP FAQ - SCJP Mock Tests - Tutorial - JavaSE7 - JavaEE6 -Generics FAQ - JLS - JVM Spec - Java FAQs - Smart Questions
Mahesh Murugaiyan
Greenhorn

Joined: Jun 25, 2009
Posts: 21
Thanks Ninad. Thanks Paul, yes, thats makes total sense. Other than enum, interface(constants) are there any other entitiy that is implicitly static ? I will add this to my study notes.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how non-static enum can be accessed without object?
 
Similar Threads
question 7 of chapter 3
Static and non Static methods
Problem in code
Enum accessing PRoblem
Static variables and methods