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 Transient variables Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Transient variables" Watch "Transient variables" New topic
Author

Transient variables

sudha
Greenhorn

Joined: Oct 30, 2000
Posts: 4
Hi,
This is from deepak's mock.
Which one of the following statements is true ?
A.Transient variables are not serialized.
B.Transient methods may not be overridden.
C.Transient methods must be overridden.
D.Transient classes may not be serialized.
E.Transient variables must be static.
How to make sure about the declaration of transient variables and volatile?
Thanks and Regards
Sudha
Milind Mahajan
Ranch Hand

Joined: Oct 23, 2000
Posts: 77
Hi,
I think answer A is right. B, C and D are wrong because transient modofier can be applied only to variables. D is wrong because transient varibles should not static.
volatile modifer can be, again, applied only to variables. It tells the compiler not to do any optimisation for that variable ( in a loop ) because that variable can be modified asynchronously by some other thread ( this sentence is alomost straight out of some book :-)). There is an example of using volatile modifier in Threads chapter of Patrick/Schildt book.
Hope this helps.
Milind
Jonathan Jeban
Ranch Hand

Joined: Oct 08, 2000
Posts: 52
Hi Milind ,
Agree with ur answers except for the explanation for D.
Originally posted by Milind Mahajan:
D is wrong because transient varibles should not static.

Transient Variables can be static .
But D is wrong because ,it says transient variables must be static.
If u code like this ,it will work..

public class Test
{
static transient int maxElements = 100;
}

Hope this helps...
Jeban
[This message has been edited by Jonathan Jeban (edited October 31, 2000).]
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
PROPER NAMES ARE NOW REQUIRED!!
Read this post for more details. http://www.javaranch.com/ubb/Forum10/HTML/000180.html
Javaranch appreciates your cooperation to comply with the official naming policy.

I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
 
IntelliJ Java IDE
 
subject: Transient variables
 
Threads others viewed
method in interface?
Which of the Following is True?
method in interface?
transient variable?
static are kept away from the process of serialization
MyEclipse, The Clear Choice