File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Valid Variable modifiers ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Valid Variable modifiers ?" Watch "Valid Variable modifiers ?" New topic
Author

Valid Variable modifiers ?

Robbie kyodo
Ranch Hand

Joined: May 05, 2003
Posts: 97
transient - unserialized variable -- is it allowed in an interface ? why ?
strictfp - only for class and methods not for variables
volatile - what is it for ?
synchronized - methods only


SCJP 2 1.4
Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
transient is not allowed in interfaces. It only makes sense for instance fields. Fields in an interface are automatically public static and final.
___________________________________________________
"strictfp - only for class and methods not for variables"
True
____________________________________________
synchronized methods only
True
_____________________________________________
volatile is used to ensure that the changes to a primitive field, made by one thread, are always visible to others threads. It is like having synchronized the accessor and mutator methods of the field.
In the case the accesses to a variable occur through several threads, and they are not synchronized; declaring the variable as volatile --as an alternative to synchronizing the accesses-- might mean an advantage in performance.


SCJP2. Please Indent your code using UBB Code
Rajinder Yadav
Greenhorn

Joined: May 13, 2003
Posts: 27
Also you can have one or more synchronized blocks within a method.


When faced with an easy thing to do and a hard thing to do, always pick the right thing to do!<p><a href="http://yadav.shorturl.com" target="_blank" rel="nofollow">Rajinder Yadav</a>
Robbie kyodo
Ranch Hand

Joined: May 05, 2003
Posts: 97
thanks for some input. Do you allow transient and volatile in an interface or abstract ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Valid Variable modifiers ?
 
Similar Threads
Method call
serialization..
inheritance problem
Why no Polymorphism for instance variables
accessibility of stativ variable with in a constructor