• 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

Compatibility between private and transient

 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Ranchers,

Well we say that if a variable is declared final than it cannot be declared as transient.Also private variable are implicitly final,which means a private variable should not be declared as transient,but doing Dan's mock exam i came across such a case and it's given -works fine.
Plz explain.
Regards
Akshay
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
final implies different things depending on the context:
  • A final class cannot be subclassed.
  • A final method cannot be overridden.
  • A final variable cannot have its assignment changed.
  • So a private method is implicitly final, because it is not accessible outside of its own class and therefore can't be overridden. But a private variable is not implicitly final, because it can have its assignment changed.

    A variable marked transient is simply not stored to an object's persistent state (for example, if it's Serializable). But I don't know of any conflict between transient and final, nor between transient and private.
    [ December 07, 2005: Message edited by: marc weber ]
     
    Don't get me started about those stupid light bulbs.
    reply
      Bookmark Topic Watch Topic
    • New Topic