• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

keywords

 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
keywords: volatile ,transient ,strictfp , native
please help me to understand these keywords

volatile variable
transient field
strictfp method
native method
 
author
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Fortunately, the only one of these that you need to know for the SCJP exam is transient.

A transient field is not serialized when, for example, an object is written to an ObjectOutputStream via the writeObject() method. Much much more on this in Chapter 9 of the 5.0 rev of "Complete Java Certification StudyGuide".

A volatile field has subtly different behavior from a non-volatile field in a multi-threaded environment. The exact behavior is WAY beyond our scope here.

The strictfp keyword takes care of an embarrassing situation. In certain really extreme numeric operation situations, the JVM produces results that aren't exactly what the IEEE floating point spec calls for. A strictfp method uses the "strict" IEEE algorithms, and always generates IEEE-compliant results. Similarly, when a strictfp variable appears as an operand in a floatinf-point operation, the IEEE algorithm is used.

A native method looks like an abstract method. After the declaration, where you would expect to see a method body, there's just a semicolon. A call to the method is delegated to a dynamic library on the local machine. As you'd expect, there's a certain amount of work that you need to do to glue the Java code to the native library. Native methods are how a Java program can interact with the mouse, keyboard, and other hardware resources of the underlying hardware.
 
samdeep aarzoo
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please explain transient field

what is transient field
what is meant by this statement
Prevent field from ever being serialized.
transient fields are skipped , when objects are serialized
 
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you "serialize" an Object instance, you prepare it to be written to a stream (whether its final destination is a file, another computer in the network, or whatever). When you declare a field to be transient, you are saying to the runtime, when this Object is sent to the stream, leave out the value of this field.

You may do this for security (if you don't want to write sensitive information) or to reduce size (for instance, large data structures which can be recalculated).

An example for the second reason, let's say you have a 1024x768 image in a jpg file. When you run your program, it loads this image from the jpg file anyway, so you would want your Image object to be transient, because when you load the serialized data, you can just load the Image from the file again.
 
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bikash,

if you are new to this concept, going through Object Serialization would be of help (not only for SCJP exam). Just try out the piece of code given in the example for understanding and remembering.

E.g.
 
Bartender
Posts: 3958
43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by bikash mittal:
please explain transient field

what is transient field
what is meant by this statement
Prevent field from ever being serialized.
transient fields are skipped , when objects are serialized



Howdy !

Develop code that serializes and/or de-serializes objects using the following APIs from java.io: DataInputStream, DataOutputStream, FileInputStream, FileOutputStream, ObjectInputStream, ObjectOutputStream and Serializable.

HTH,
MZ
 
reply
    Bookmark Topic Watch Topic
  • New Topic