ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Core Java  >>  Java J2EE  >>  Java Related
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
Question
What is the need to implement Serializable interface (with
no methods) for objects which are to be serialized ?
We can write our own functionality which writes objects to
streams then why we need to implement and tell JVM that
which objects can be serialized.
 Question Submitted By :: Akj504
I also faced this Question!!     Rank Answer Posted By  
 
  Re: What is the need to implement Serializable interface (with no methods) for objects which are to be serialized ? We can write our own functionality which writes objects to streams then why we need to implement and tell JVM that which objects can be serialized.
Answer
# 1
Implementing Serializable interface signifies that the 
object can be persisted.  Otherwise, when you try to
use writeObject, it will throw 
java.io.NotSerializableException
 
Is This Answer Correct ?    4 Yes 1 No
Chellammal
 
  Re: What is the need to implement Serializable interface (with no methods) for objects which are to be serialized ? We can write our own functionality which writes objects to streams then why we need to implement and tell JVM that which objects can be serialized.
Answer
# 2
well if we dont use Serializable interface which is a 
marker interface, then the object which we want to 
serialize and use writeObject() method then compiler would 
throw exception as if other object which r related to that 
object if not serialized.
So. to overcome this we have to use Seializable interface.
 
Is This Answer Correct ?    2 Yes 2 No
Aman Kr Aggarwal
 
 
 
  Re: What is the need to implement Serializable interface (with no methods) for objects which are to be serialized ? We can write our own functionality which writes objects to streams then why we need to implement and tell JVM that which objects can be serialized.
Answer
# 3
Ya that answers are expected but...
If we open ObjectOutputStream.java (which is used for
serialization) then we see the following code :

............................
writeObject0(Object obj, boolean unshared){
.............
 } else if (cl.isArray()) {
		writeArray(obj, desc, unshared);
	    } else if (obj instanceof Serializable) {
		writeOrdinaryObject(obj, desc, unshared);
	    } else {
		throw new NotSerializableException(cl.getName());
	    }
................

If we remove the checking instanceof (& recompile)  or if we
override the writeObject0 method then 
Will it still check whethere the class has implemented
serilizable ?
 
Is This Answer Correct ?    1 Yes 1 No
Akj504
[IT]
 
  Re: What is the need to implement Serializable interface (with no methods) for objects which are to be serialized ? We can write our own functionality which writes objects to streams then why we need to implement and tell JVM that which objects can be serialized.
Answer
# 4
Serializable concept is related with the state persisitence 
of the object.
Example:---
When u send the some object on internet it needs to be 
serialized bcz before sending the object it first converted 
in to byte & desrerialization is the process is used to get 
it back in its original form
 
Is This Answer Correct ?    1 Yes 0 No
Rohit
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
What is Collections API?  1
what is filters and its use? Virtusa2
What is Interface? BMC5
Name the types of mouse event listeners ?  2
How to prevent a field from serialization ?  2
class{ ... ... interface myinterface{ ... ... } abstract class{ .. .. } ... .. .. } is this possible to write "Interface and/ or Abstract class inside a class ? if possible whcich one is possible is only interface? is only abstract? Logica-CMG2
Hi Friends, can u give me Real Time example for interface and abstract class.(With Banking Example)  1
Need 2+ yrs experienced java techinical question papaer for company Iflex  1
What are virtual functions?  2
strings in java are objects.why?  2
Which characters are allowed to use as the second character of an identifier, and which characters are not allowed?  2
How many methods does cloneable interface contains?  2
what is Remote Reference Layer ?  1
which class to use when concatenating strings in a loop. IBM2
What are the traverses in Binary Tree? Adobe2
what is the use/perpose of having a method antive?  2
What is casting? BMC3
Can we declare static variables in JSP page. TCS3
without using arthematic operation ,how can you write the logic for adding/substraction/multiplication? Wipro4
What is difference between hash mapping and hash table? NDS3
 
For more Core Java Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com