Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Enums

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 210
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ya ramesh is correct
 
author
Posts: 9034
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Proudly marching to the beat of a different kettle of fish... while reading this tiny ad
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic