• 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

transient volatile strictfp 's position in SCJP1.4!

 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
they are just mentioned as keyword or examed with concrete code???
 
Ranch Hand
Posts: 366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can expect a question like
volatile final int x = 5;
is this code valid?
or something like
interface I1 {
transient int x = 5;
}
is this code valid
Hope this helps
Sri
 
Mellihoney Michael
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can you explain the question above?
I don't know that yet
thanks.
Or can you offer a link which contains some resource on this?
Many thanks!
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Michael,
Here is what I have to say :
Volatile :
Only variables may be volatile. Declaring a variable volatile implies that they can be modified asynchronously.
Transient :
When a variable is declared as transient, it means that it will not get serialised with the object.
In the second example of Sri's post, a transient variable is declared in an interface.
This will not compile, and you will get an error, "modifier transient not allowed here".
This is because the member variables of an interface are always public, static and final by default. So it wont allow you to declare them as transient.
Hope this helps.
Regards
Mandar
 
Mellihoney Michael
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks
 
Cowgirl and Author
Posts: 1589
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy!
You do *not* need to know exactly how volatile, transient, and strictfp work. But you *do* need to know where / to what they can be applied. For example, you need to know:
* Only non-local variables can be volatile
(methods, classes, and local variables cannot be volatile)
* Only non-local variables can be transient (methods, classes, and local variables cannot be transient)
* Variables cannot be made strictfp, only classes and methods may be strictfp
* You cannot make abstract methods (including interface methods) strictfp
That's a start : )
My recommendation is to learn enough about what they do so that you'll be able to better remember where it makes sense to use them and where it does not. For example, knowing that marking a variable transient means, "skip this variable when saving the object's state during serialization", makes it easier to remember that 'transient' is about instance variables and not methods or classes. And if you remember that strictfp is about 'behavior' rather than state, it makes more sense that strictfp can be applied to methods but not variables. (Then you still have to remember that strictfp can be applied to classes, but that's just a way of saying, "make every method in the class strictfp")
cheers and good luck,
Kathy
 
Mellihoney Michael
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks to all guys
 
reply
    Bookmark Topic Watch Topic
  • New Topic