6. What is a transient variable?
o The variable, which cannot be serialized, is known as transient variable.
7. What are wrapped classes?
o Wrapped classes are classes that allow primitive types to be accessed as objects.
8. What is an immutable object and what are its advantages?
· An immutable object is an object and any object it references that does not change after construction. The object is, therefore, immutable for its lifetime.
· Immutable classes are commonly used to represent strings, colors, and numeric values.
Advantage:
· They guarantee that their state cannot change after construction, they are inherently thread-safe.
9. What are basic rules, which govern creation of immutable classes?
· Declare the class final.
· Declare all data private.
· Provide only getter methods and no setter methods.
· Set all instance data in the constructor.
· Clone mutable objects for which a reference to them is returned.
· Clone mutable objects for which a reference to them is received.
· Implement a deep clone if the default shallow clone is not correct for a properly behaved immutable object.
10. What is a Java package and how is it used?
· A Java package is a naming context for classes and interfaces. A package is used to create a separate name space for groups of classes and interfaces. Packages are also used to organize related classes and interfaces into a single API unit and to control accessibility to these classes and interfaces
About Me
Sunday, March 30, 2008
CORE JAVA FAQS
Posted by Its For Techies at 12:48 AM
Labels: CORE JAVA faqs-2
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment