aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Enums Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Enums" Watch "Enums" New topic
Author

Enums

Gustavo Villegas
Greenhorn

Joined: Aug 27, 2008
Posts: 11
I don't get why this is right
Chapter 1 Question 8 SCJP K&B 5.0



What is the Result

A Woof Burble
B Multiple Compilation Errors
C Compilation Fails line 2
D Compilation Fails line 3
E Compilation Fails line 4
F Compilation Fails line 9

I though the answer was F but the the Answer is A...

I don't understand why :S

I think that A should have some value before we can use it or something.

Accessing the Elements of an Enum is like Accessing Class Variables ??
I mean, doing something like this is similar?.


[ August 31, 2008: Message edited by: Gustavo Villegas ]
ramesh maredu
Ranch Hand

Joined: Mar 15, 2008
Posts: 210

Hi,
Compiler creates static final variables with enum variables, that is the reason we can access them with enum name, compiler generates code like below



SCJP 1.5 94%.
The greatest glory in living lies not in never falling, but in rising every time we fall.
ankit kumar
Ranch Hand

Joined: Apr 28, 2008
Posts: 108
ya ramesh is correct


Cleared SCJP 1.5 | Cleared SCWCD 5.0
SCDJWS 6 in progress.....
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8829
    
    5
As a general tip I have to recommend testing this sort of thing yourself!

We've listened to thousands of ranchers who studied for these Sun Java exams, and everyone who does really well writes LOTS and LOTS of code while they are studying. So this would be a case where you should type the code in, FROM THE COMMAND LINE and NOT an IDE, and test it. Then, once you've typed in what's in the book, play around with it - change stuff, try stuff out, and experiment. That's how you're really going to learn this stuff.

Finally, I can say that the teams that create these tests write and test LOTS of code (from the command line), while the questions are being created. And, Kathy and I write and test LOTS of code while we're writing our books.

Being a good programmer is like being a good tennis player. You can't just read about hitting tennis balls, you have to go out on the court and hit a lot of tennis balls.

hth,

Bert


Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Enums