Win a copy of Murach's MySQL this week in the JDBC and Relational Databases forum!
  • 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java Rule Round-up

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The question 201 says "TRUE or FALSE: Member (instance) variables are always assigned a default value if not explicitly initialized. My answer was FALSE, Javaranch answer was TRUE.
I think that final variables are not assigned a dafault value, then member variables are not ALWAYS assigned a dafault value.
Maybe they are constants, and should not be called variables.
What do you think?
Bye
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From The JLS 4.5.3 Kinds of Variables

If a class T has a field a that is an instance variable, then a new instance variable a is created and initialized to a default value (�4.5.5) as part of each newly created object


If you declare a final variable and do not initialize it at that point it is refered to as a blank final. Of course the compiler will not allow you to leave it that way, but you can postpone the initialization until a constructor is executed for example.
[ October 01, 2002: Message edited by: Cindy Glass ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic