Friday, February 5, 2010
Food for thought
Work for a Cause, not applause. Live to express, not to impress...
Life is short make it sweet.
Satish
The INTERNET now has a personality. YOURS! See your Yahoo! Homepage.
Sunday, December 20, 2009
A Motivational Story with Wisdom
So the Professor then picked up a box of pebbles and poured them into the jar. He shook the jar lightly. The pebbles rolled into the open areas between the golf balls. He then asked the students again if the jar was full. They agreed it was.
The Professor next picked up a box of sand and poured it into the jar. Of course, the sand filled up everything else. He asked once more if the jar was full. The students responded with an unanimous "yes."
The Professor then produced two cups of coffee from under the table and poured the entire contents into the jar, effectively filling the space between the grains of sand.
"Now," said the professor, as the laughter subsided, "I want you to recognize that this jar represents your life. The golf balls are the important things--your family, your children, your health, your friends, and your favorite passions - things that if everything else was lost and only they remained, your life would still be full.
The pebbles are the other things that matter like your job, your house, and your car. The sand is everything else -the small stuff.
"If you put the sand into the jar first," he continued, "there is no room for the pebbles or the golf balls. The same goes for life. If you spend all your time and energy on the small stuff, you will never have room for the things that are important to you. Pay attention to the things that are critical to your happiness. Play with your children. Take time to get medical checkups. Take your partner out to dinner. Play another 18.
There will always be time to clean the house and fix the disposal. "Take care of the golf balls first, the things that really matter. Set your priorities. The rest is just sand."
One of the students raised her hand and inquired what the coffee represented. The Professor smiled. "I'm glad you asked.
"It just goes to show you that no matter how full your life may seem, there's always room for a couple of cups of coffee with a friend."
Thursday, December 17, 2009
Customized Java scripts Alerts
Just we need to follow the below files and enjoy the customzied Javascript Alerts.
CSS Code :
just copy the below code in the "style type="text/css" " tag and "/style"
#alertBox {
position:relative;
width:300px;
min-height:100px;
margin-top:50px;
border:2px solid #000;
background-color:#F2F5F6;
background-image:url(alert.png);
background-repeat:no-repeat;
background-position:20px 30px;
}
#alertBox h1 {
margin:0;
font:bold 0.9em verdana,arial;
background-color:#78919B;
color:#FFF;
border-bottom:1px solid #000;
padding:2px 0 2px 5px;
}
#alertBox p {
font:0.7em verdana,arial;
height:50px;
padding-left:5px;
margin-left:55px;
}
#alertBox #closeBtn {
display:block;
position:relative;
margin:5px auto;
padding:3px;
border:2px solid #000;
width:70px;
font:0.7em verdana,arial;
text-transform:uppercase;
text-align:center;
color:#FFF;
background-color:#78919B;
text-decoration:none;
}
JavaScript Code :
just copy the below code in the javaScript code "
script type="text/javascript"" " tag and "/script"
var ALERT_TITLE = "Oops!";
var ALERT_BUTTON_TEXT = "Ok";
if(document.getElementById) {
window.alert = function(txt) {
createCustomAlert(txt);
}
}
function createCustomAlert(txt) {
d = document;
if(d.getElementById("modalContainer")) return;
mObj = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
mObj.id = "modalContainer";
mObj.style.height = d.documentElement.scrollHeight + "px";
alertObj = mObj.appendChild(d.createElement("div"));
alertObj.id = "alertBox";
if(d.all && !window.opera) alertObj.style.top = document.documentElement.scrollTop + "px";
alertObj.style.left = (d.documentElement.scrollWidth - alertObj.offsetWidth)/2 + "px";
alertObj.style.visiblity="visible";
h1 = alertObj.appendChild(d.createElement("h1"));
h1.appendChild(d.createTextNode(ALERT_TITLE));
msg = alertObj.appendChild(d.createElement("p"));
//msg.appendChild(d.createTextNode(txt));
msg.innerHTML = txt;
btn = alertObj.appendChild(d.createElement("a"));
btn.id = "closeBtn";
btn.appendChild(d.createTextNode(ALERT_BUTTON_TEXT));
btn.href = "#";
btn.focus();
btn.onclick = function() { removeCustomAlert();return false; }
alertObj.style.display = "block";
}
function removeCustomAlert() {
document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalContainer"));
}
HTML Code :
<input type="button" value = "Test the alert" onclick="alert('This is a custom alert dialog that was created by over-riding the window.alert method.');" />
Monday, November 30, 2009
Interactive Sites on Medical INFO - Very useful
Diseases and Conditions
Abdominal Aortic Aneurysm
Acne
AIDS
Allergies to Dust Mites
Alopecia
Amyotrophic Lateral Sclerosis (ALS)
Angina
Anthrax
Arrhythmias
Arthritis
Asthma
Atrial Fibrillation
Avian Influenza
Back Pain - How to Prevent
Bell's Palsy
Brain Cancer
Breast Cancer
Burns
Cataracts
Cerebral Palsy
Cold Sores (Herpes)
Colon Cancer
Congestive Heart Failure
COPD (Chronic Obstructive Pulmonary Disease)
Crohn's Disease
Cystic Fibrosis
Depression
Diabetes - Eye Complications
Diabetes - Foot Care
Diabetes - Introduction
Diabetes - Meal Planning
Diverticulosis
Endometriosis
Epstein Barr (Mononucleosis)
Erectile Dysfunction
Fibromyalgia
Flashes and Floaters
Fractures and Sprains
Ganglion Cysts
Gastroesophageal Reflux Disease (GERD)
Glaucoma
Gout
Hearing Loss
Heart Attack
Hepatitis B
Hepatitis C
Hypertension (High Blood Pressure)
Hypoglycemia
Incisional Hernia
Influenza
Inguinal Hernia
Irritable Bowel Syndrome
Kidney Failure
Kidney Stones
Leishmaniasis
Leukemia
Low Testosterone
Lung Cancer
Lupus
Lyme Disease
Macular Degeneration
Malaria
Melanoma
Meningitis
Menopause
Migraine Headache
Mitral Valve Prolapse
Multiple Myeloma
Multiple Sclerosis
Myasthenia Gravis
Osteoarthritis
Osteoporosis
Otitis Media
Ovarian Cancer
Ovarian Cysts
Pancreatitis
Parkinson's Disease
Pneumonia
Prostate Cancer - What is it?
Psoriasis
Retinal Tear and Detachment
Rheumatoid Arthritis
Rotator Cuff Injuries
Sarcoidosis
Scabies
Seizures and Epilepsy
Sexually Transmitted Diseases
Shingles
Skin Cancer
Sleep Disorders
Smallpox
Spinal Cord Injury
Temporomandibular Joint Disorders (TMJ)
Tennis Elbow
Tinnitus
Trigeminal Neuralgia
Tuberculosis
Ulcerative Colitis
Umbilical Hernia
Uterine Fibroids
Varicose Veins
Vasculitis
Warts
Tests and Diagnostic Procedures
Amniocentesis
Barium Enema
Bone Densitometry
Breast Lumps - Biopsy
Bronchoscopy
Colonoscopy
Colposcopy
Coronary Angiogram and Angioplasty
CT Scan (CAT Scan)
Cystoscopy - Female
Cystoscopy - Male
Echocardiogram
Echocardiography Stress Test
IVP (Intra Venous Pyelogram)
Knee Arthroscopy
Laparoscopy
Mammogram
MRI
Myelogram
Newborn Screening
Pap Smear
Shoulder Arthroscopy
Sigmoidoscopy
Ultrasound
Upper GI Endoscopy
Surgery and Treatment Procedures
Aorto-Bifemoral Bypass
Cardiac Rehabilitation
Carotid Endarterectomy
Carpal Tunnel Syndrome
Chemotherapy
Cholecystectomy - Open Laparoscopic (Gallbladder Removal Surgery)
Clinical Trials
Colon Cancer Surgery
Colostomy
Coronary Artery Bypass Graft (CABG)
C-Section
Dilation and Curettage (D & C)
General Anesthesia
Heart Valve Replacement
Hemorrhoid Surgery
Hip Replacement
Hip Replacement - Physical Therapy
Hysterectomy
Knee Replacement
LASIK
Massage Therapy
Neurosurgery - What is it?
Open Heart Surgery - What to Expect?
Pacemakers
Preparing for Surgery
Prostate Cancer - Radiation Therapy
Shoulder Replacement
Sinus Surgery
Stroke Rehabilitation
Thyroid Surgery
Tonsillectomy and Adenoidectomy
TURP (Prostate Surgery)
Vaginal Birth
Vasectomy
Prevention and Wellness
Back Exercises
Coumadin - Introduction
Exercising for a Healthy Heart
Managing Cholesterol
Muscles
Preventing Strokes
Smoking - The Facts
Saturday, November 28, 2009
Annotations
Annotation: From English Dictionary, it's the explanation/comments/Remarks/Observations/Notes/Clarifications.
Annotations in Java: Annotations are like meta-tags that you can add to your code and apply them to package declarations, type declarations, constructors, methods, fields, parameters, and variables. As a result, you will have helpful ways to indicate whether your methods are dependent on other methods, whether they are incomplete, whether your classes have references to other classes, and so on.
Pros & cons of Annotations:
Pros :1) Annotations are relatively simple to use and understand.2) Compilation time requires less for annotations when compared to the xml-configurations.3) Annotations are used for flexibility.4) Annotations can be used by the compiler to detect errors or suppress warnings.5) Software tools can process annotation information to generate code, XML files, and so forth.6) Annotations can be applied to a program's declarations of classes, fields, methods, and other program elements.
Cons: Annotations unnecessarily couple the metadata to the code. Thus, changes to metadata require changing the source code. (i.e. when we want to change some configuration , we need to change the source code, where as in the xml -configuration, just need to change the xml file & redeploy it ).
Two things in Annotations:
1) Annotation : An annotation is the meta-tag that you will use in your code to give it some life.
2) Annotation Type: It is used for defining an annotation. used when we need to create our own custom annotation.
Define an Annotation type: In order to define our own custom tag, the following syntax need to be followed. "@" symbol followed by "interface" followed by "Name of the annotations".
Example:
public @interface MyAnnotation {String doSomething();}
Annotate Your Code (Annotation)
We are just supposed to use the name of our annotations & assign some values to the annotation variables.
Example:
MyAnnotation (doSomething="What to do")public void mymethod() {....}
Annotation Types:
There are three annotation types:
Marker: Marker type annotations have no elements, except the annotation name itself. Example: public @interface MyAnnotation {}Usage: @MyAnnotationpublic void mymethod() {....}
Single-Element: Single-element, or single-value type, annotations provide a single piece of data only. This can be represented with a data=value pair or, simply with the value (a shortcut syntax) only, within parenthesis.Example: public @interface MyAnnotation {String doSomething();}Usage: @MyAnnotation ("What to do")public void mymethod() {....}
Full-value or multi-value: Full-value type annotations have multiple data members. Therefore, you must use a full data=value parameter syntax for each member.Example: public @interface MyAnnotation {String doSomething();int count; String date();}Usage: @MyAnnotation (doSomething="What to do", count=1,date="09-09-2005")public void mymethod() {....}
Rules to define an Annotation Type.
1) Annotation declaration should start with an 'at' sign like @, following with an interface keyword, following with the annotation name.2) Method declarations should not have any parameters.3) Method declarations should not have any throws clauses.4) Return types of the method should be one of the following:i) primitivesii) Stringiii) Classiv) enumv) array of the above types
Annotation :
Simple annotations : These are the basic types supplied with Tiger, which you can use to annotate your code only; you cannot use those to create a custom annotation type. There are only three types of simple annotations provided by JDK5.
They are:
Override : ( @Override ) throws an error when it some method is not overrided preoperly.
Deprecated: ( @Deprecated ) throws warnings when a method is used which is deprecated.
Suppress warnings: This annotation indicates that compiler warnings should be shielded in the annotated element and all of its sub-elements. @SuppressWarnings({"deprecation
Meta annotations : These are called the annotations-of-annotations
These are:i) Targetii) Retentioniii) Documentediv) Inherited.
The Target annotation : The target annotation indicates the targeted elements of a class in which the annotation type will be applicable. It contains the following enumerated types as its value:@Target(ElementType.TYPE)—can be applied to any element of a class@Target(ElementType.FIELD)—can be applied to a field or property@Target(ElementType.METHOD)—can be applied to a method level annotation@Target(ElementType.PARAMETER)—can be applied to the parameters of a method@Target(ElementType.CONSTRUCTOR)—can be applied to constructors@Target(ElementType.LOCAL_VARIABLE)—can be applied to local variables@Target(ElementType.ANNOTATION_TYPE)—indicates that the declared type itself is an annotation type
The Retention annotation:The retention annotation indicates where and how long annotations with this type are to be retained. There are three values:RetentionPolicy.SOURCE—Annotations with this type will be by retained only at the source level and will be ignored by the compilerRetentionPolicy.CLASS—Annotations with this type will be by retained by the compiler at compile time, but will be ignored by the VMRetentionPolicy.RUNTIME—Annotations with this type will be retained by the VM so they can be read only at run-time
The Documented annotation : The documented annotation indicates that an annotation with this type should be documented by the javadoc tool. . By default, annotations are not included in javadoc. But if @Documented is used, it then will be processed by javadoc-like tools and the annotation type information will also be included in the generated document
The Inherited annotation: Automatically all the methods are inherited in the child class.
Ex :@Inheritedpublic @interface myParentObject {boolean isInherited() default true;String doSomething() default "Do what?";}
Next, annotate a class with your annotation:
@myParentObjectpublic Class myChildObject {}
If there were no annotations , we should have written the class in the following way. i.e. we need to implement all the methods
public class myChildObject implements myParentObjectpublic boolean isInherited() {return false;}public String doSomething() {return "";}public boolean equals(Object obj) {return false;}public int hashCode() {return 0;}public String toString() {return "";}public Class annotationType() {return null;}}
Monday, November 23, 2009
Serialization
3 Modes of Serialization in Java:
1) Implement either Serializable or Externalizable interface.
2) XML serialization :
3) Implement our own serialzation process, i.e. suing objectObjectStream
Deserialization is the process of rebuilding those bytes into a live object.
Why Serialization ???
In Java everything is an object, & these object are supposed to transfer to one server/component/network to other server/component/network if we want to communicate each other.
One way to achieve this is to define our own protocol and transfer an object. This means that the receiving end must know the protocol used by the sender to re-create the object, which would make it very difficult to talk to third-party components. Hence, there needs to be a generic and efficient protocol to transfer the object between components. Serialization is defined for this purpose, and Java components use this protocol to transfer objects.
Steps to Serialize an Object.
1) The object which is to be serialized has to implement a maker interface called Serializable.
2) The marker interface is nothing but a mechanism which tells that the class/object can be serialized.
3) calling the methods writeObject() , & readObject() as per our requirement.
4) No argument constructer should be there for the object.
Java's serialization algorithm

- Transient variables and Static Variables can't be serailized.
- Transient variables will have its default values when deserialize them.
- serialVersionUID is generated using the metadata of the class.
- you can use tool serialver to see serialVersionUID of a serialized object .
- java.io.InvalidClassException will be thrown if there is mismatch with the serialVersionUID
- if the base is not serializable and derived class is serilzable, then NotSerializableException is thrown.
Q1) What is Serialization?
Ans) Serializable is a marker interface. When an object has to be transferred over a network ( typically through rmi or EJB) or persist the state of an object to a file, the object Class needs to implement Serializable interface. Implementing this interface will allow the object converted into bytestream and transfer over a network.
Q2) What is use of serialVersionUID?
Ans) During object serialization, the default Java serialization mechanism writes the metadata about the object, which includes the class name, field names and types, and superclass. This class definition is stored as a part of the serialized object. This stored metadata enables the deserialization process to reconstitute the objects and map the stream data into the class attributes with the appropriate type
Everytime an object is serialized the java serialization mechanism automatically computes a hash value. ObjectStreamClass's computeSerialVersionUID() method passes the class name, sorted member names, modifiers, and interfaces to the secure hash algorithm (SHA), which returns a hash value.The serialVersionUID is also called suid.
So when the serilaize object is retrieved, the JVM first evaluates the suid of the serialized class and compares the suid value with the one of the object. If the suid values match then the object is said to be compatible with the class and hence it is de-serialized. If not InvalidClassException exception is thrown.
Changes to a serializable class can be compatible or incompatible. Following is the list of changes which are compatible:
• Add fields
• Change a field from static to non-static
• Change a field from transient to non-transient
• Add classes to the object tree
List of incompatible changes:
• Delete fields
• Change class hierarchy
• Change non-static to static
• Change non-transient to transient
• Change type of a primitive field
So, if no suid is present , inspite of making compatible changes, jvm generates new suid thus resulting in an exception if prior release version object is used .
The only way to get rid of the exception is to recompile and deploy the application again.
If we explicitly metion the suid using the statement:
private final static long serialVersionUID =
then if any of the metioned compatible changes are made the class need not to be recompiled. But for incompatible changes there is no other way than to compile again.
Q3) What is the need of Serialization?
Ans) The serialization is used :-
• To send state of one or more object’s state over the network through a socket.
• To save the state of an object in a file.
• An object’s state needs to be manipulated as a stream of bytes.
Q4) Other than Serialization what are the different approach to make object Serializable?
Ans) Besides the Serializable interface, at least three alternate approaches can serialize Java objects:
1)For object serialization, instead of implementing the Serializable interface, a developer can implement the Externalizable interface, which extends Serializable. By implementing Externalizable, a developer is responsible for implementing the writeExternal() and readExternal() methods. As a result, a developer has sole control over reading and writing the serialized objects.
2)XML serialization is an often-used approach for data interchange. This approach lags runtime performance when compared with Java serialization, both in terms of the size of the object and the processing time. With a speedier XML parser, the performance gap with respect to the processing time narrows. Nonetheless, XML serialization provides a more malleable solution when faced with changes in the serializable object.
3)Finally, consider a "roll-your-own" serialization approach. You can write an object's content directly via either the ObjectOutputStream or the DataOutputStream. While this approach is more involved in its initial implementation, it offers the greatest flexibility and extensibility. In addition, this approach provides a performance advantage over Java serialization.
Q5) Do we need to implement any method of Serializable interface to make an object serializable?
Ans) No. Serializable is a Marker Interface. It does not have any methods.
Q6) What happens if the object to be serialized includes the references to other serializable objects?
Ans) If the object to be serialized includes the references to other objects whose class implements serializable then all those object’s state also will be saved as the part of the serialized state of the object in question. The whole object graph of the object to be serialized will be saved during serialization automatically provided all the objects included in the object’s graph are serializable.
Q7) What happens if an object is serializable but it includes a reference to a non-serializable object?
Ans- If you try to serialize an object of a class which implements serializable, but the object includes a reference to an non-serializable class then a ‘NotSerializableException’ will be thrown at runtime.
e.g.
public class NonSerial {
//This is a non-serializable class
}
public class MyClass implements Serializable{
private static final long serialVersionUID = 1L;
private NonSerial nonSerial;
MyClass(NonSerial nonSerial){
this.nonSerial = nonSerial;
}
public static void main(String [] args) {
NonSerial nonSer = new NonSerial();
MyClass c = new MyClass(nonSer);
try {
FileOutputStream fs = new FileOutputStream("test1.ser");
ObjectOutputStream os = new ObjectOutputStream(fs);
os.writeObject(c);
os.close();
} catch (Exception e) { e.printStackTrace(); }
try {
FileInputStream fis = new FileInputStream("test1.ser");
ObjectInputStream ois = new ObjectInputStream(fis);
c = (MyClass) ois.readObject();
ois.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
On execution of above code following exception will be thrown –
java.io.NotSerializableException: NonSerial
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java)
Q8) Are the static variables saved as the part of serialization?
Ans) No. The static variables belong to the class and not to an object they are not the part of the state of the object so they are not saved as the part of serialized object.
Q9) What is a transient variable?
Ans) These variables are not included in the process of serialization and are not the part of the object’s serialized state.
Q10) What will be the value of transient variable after de-serialization?
Ans) It’s default value.
e.g. if the transient variable in question is an int, it’s value after deserialization will be zero.
public class TestTransientVal implements Serializable{
private static final long serialVersionUID = -22L;
private String name;
transient private int age;
TestTransientVal(int age, String name) {
this.age = age;
this.name = name;
}
public static void main(String [] args) {
TestTransientVal c = new TestTransientVal(1,"ONE");
System.out.println("Before serialization: - " + c.name + " "+ c.age);
try {
FileOutputStream fs = new FileOutputStream("testTransients.ser");
ObjectOutputStream os = new ObjectOutputStream(fs);
os.writeObject(c);
os.close();
} catch (Exception e) { e.printStackTrace(); }
try {
FileInputStream fis = new FileInputStream("testTransients.ser");
ObjectInputStream ois = new ObjectInputStream(fis);
c = (TestTransientVal) ois.readObject();
ois.close();
} catch (Exception e) { e.printStackTrace(); }
System.out.println("After de-serialization:- " + c.name + " "+ c.age);
}
}
Result of executing above piece of code –
Before serialization: - Value of non-transient variable ONE Value of transient variable 1
After de-serialization:- Value of non-transient variable ONE Value of transient variable 0
Explanation –
The transient variable is not saved as the part of the state of the serailized variable, it’s value after de-serialization is it’s default value.
Q11) Does the order in which the value of the transient variables and the state of the object using the defaultWriteObject() method are saved during serialization matter?
Ans) Yes. As while restoring the object’s state the transient variables and the serializable variables that are stored must be restored in the same order in which they were saved.
Q12) How can one customize the Serialization process? or What is the purpose of implementing the writeObject() and readObject() method?
Ans) When you want to store the transient variables state as a part of the serialized object at the time of serialization the class must implement the following methods –
private void wrtiteObject(ObjectOutputStream outStream)
{
//code to save the transient variables state as a part of serialized object
}
private void readObject(ObjectInputStream inStream)
{
//code to read the transient variables state and assign it to the de-serialized object
}
e.g.
public class TestCustomizedSerialization implements Serializable{
private static final long serialVersionUID =-22L;
private String noOfSerVar;
transient private int noOfTranVar;
TestCustomizedSerialization(int noOfTranVar, String noOfSerVar) {
this.noOfTranVar = noOfTranVar;
this.noOfSerVar = noOfSerVar;
}
private void writeObject(ObjectOutputStream os) {
try {
os.defaultWriteObject();
os.writeInt(noOfTranVar);
} catch (Exception e) { e.printStackTrace(); }
}
private void readObject(ObjectInputStream is) {
try {
is.defaultReadObject();
int noOfTransients = (is.readInt());
} catch (Exception e) {
e.printStackTrace(); }
}
public int getNoOfTranVar() {
return noOfTranVar;
}
}
The value of transient variable ‘noOfTranVar’ is saved as part of the serialized object manually by implementing writeObject() and restored by implementing readObject().
The normal serializable variables are saved and restored by calling defaultWriteObject() and defaultReadObject()respectively. These methods perform the normal serialization and de-sirialization process for the object to be saved or restored respectively.
Q13) If a class is serializable but its superclass in not , what will be the state of the instance variables inherited from super class after deserialization?
Ans) The values of the instance variables inherited from superclass will be reset to the values they were given during the original construction of the object as the non-serializable super-class constructor will run.
E.g.
public class ParentNonSerializable {
int noOfWheels;
ParentNonSerializable(){
this.noOfWheels = 4;
}
}
public class ChildSerializable extends ParentNonSerializable implements Serializable {
static final long serialVersionUID = 1L;
String color;
ChildSerializable() {
this.noOfWheels = 8;
this.color = "blue";
}
}
public class SubSerialSuperNotSerial {
public static void main(String [] args) {
ChildSerializable c = new ChildSerializable();
System.out.println("Before : - " + c.noOfWheels + " "+ c.color);
try {
FileOutputStream fs = new FileOutputStream("superNotSerail.ser");
ObjectOutputStream os = new ObjectOutputStream(fs);
os.writeObject(c);
os.close();
} catch (Exception e) { e.printStackTrace(); }
try {
FileInputStream fis = new FileInputStream("superNotSerail.ser");
ObjectInputStream ois = new ObjectInputStream(fis);
c = (ChildSerializable) ois.readObject();
ois.close();
} catch (Exception e) { e.printStackTrace(); }
System.out.println("After :- " + c.noOfWheels + " "+ c.color);
}
}
Result on executing above code –
Before : - 8 blue
After :- 4 blue
The instance variable ‘noOfWheels’ is inherited from superclass which is not serializable. Therefore while restoring it the non-serializable superclass constructor runs and its value is set to 8 and is not same as the value saved during serialization which is 4.
Q14) To serialize an array or a collection all the members of it must be serializable. True /False?
Ans) true.
15) What happens to the static fields of a class during serialization?
There are three exceptions in which serialization doesn’t necessarily read and write to the stream. These are
1. Serialization ignores static fields, because they are not part of any particular state.
2. Base class fields are only handled if the base class itself is serializable.
3. Transient fields.
16) What one should take care of while serializing the object?
One should make sure that all the included objects are also serializable. If any of the objects is not serializable then it throws a NotSerializableException.
17) What is serialVersionUID? What would happen if you don't define this?
SerialVersionUID is an ID which is stamped on object when it get serialized usually hashcode of object, you can use tool serialver to see serialVersionUID of a serialized object . serialVersionUID is used for version control of object. you can specify serialVersionUID in your class file also. Consequence of not specifying serialVersionUID is that when you add or modify any field in class then already serialized class will not be able to recover because serialVersionUID generated for new class and for old serialized object will be different. Java serialization process relies on correct serialVersionUID for recovering state of serialized object and throws java.io.InvalidClassException in case of serialVersionUID mismatch.
Thursday, November 19, 2009
Nov 14th 2009 - Celebrations with Children
Some of the BoA associates are waiting near 5A parking slot for one more associate whose name is "Madhu". Actually Madhu went to Reliance Mart to buy some snacks to children before time itself. He bought 100 chocolates, 100 Gems packets, some more chocolates & biscuits to the children, As he is the first person in the mart he thought the billing happen
s with in no time & he can reach the office on time, but the great Reliance Mart guy said that he doesn't option to enter the "quantity " in the billing tool & he has scan each & every item, so in turn he scanned 100 Chocolate, 100 Gems.. etc.. Finally, Madhu reached office along with long long bill along with snacks.With that long long bill all of us started to BJR school which is in Jubilee Hills. The place we went contains 2 different kinds of environments , one side slum area with no proper drainage , & one more side highly posed "Villas". By seeing that area we can easily get to kno
w all kinds of people & their standing of living. After watching the posh & slum environments , we entered into the school premises.As soon as we enter, we got sooo many wishes, so many greetings from school children & teachers. After the warm wishes children placed in their places to watch & enjoy the Magic show which is conducted by BoA. The magician is so clever that he carried full of smiles throughout the show. He made all the children to participate in the show. The magician made the show as Fun Learning movements to the children by conduction quiz after the show, where he presented some gifts also to the winners. He thought children about the greatness of non-violence, our culture, & why we are celebrating some festivals like HOLI etc.
After the magic show, Now the fun started with Dance & music which is hidden in children. We spent lot of time with non-stop sprit in the children in dance & songs. almost all children were willing to participate in the dance & songs... Mean while the associates made packing of the sna
cks to distribute to the children.After the dance & music the children are asked to take their seats in their respective class rooms. Associates disturbed the snacks ( chocolates, Biscuits , Gems.. ) to the children & sweets to the parent & teachers.
After all these things we have a photos section..
With lots of fun learning happiness in our faces, we returned to our work place.
Here are some glimpse of the cheerful movements ....
http://www.flickr.com/photos/44766037@N03/
http://picasaweb.google.co.in/neetha.jlg/NewFolder03?authkey=Gv1sRgCI_dieWw9JShbA&feat=email#