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 ?    1 Yes 0 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 ?    1 Yes 0 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 ?    0 Yes 1 No
Akj504
[IT]
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
Instead of writing Home, Remote Interfaces if i directly extends EJBObject to bean class what happens? Flextronics1
How to make a class immutable? Bosch4
What is a native method?  2
Explain Event handling in AWT?  1
In what circumstances, compiler will supply a default constructor for a class?  3
How to access a variable if it is declared as private?  2
what is mean by method signature? Satyam4
what is the difference between ArrayList and Vector Wipro10
What is inheritance?  4
What is data abstraction? Elaborate with example? BMC1
What is an exception?  3
whats is the use of final,in which situation final can be used in the application? DNS2
Is Java is 100% pure OOPS? Explain?  11
How applets will communicate with each other?  1
Can an object?s finalize() method be invoked while it is reachable?  2
What is an Applet ?  2
What do u mean by wrapper Class? What do u mean by Jvm... How do u change JVM for other OS? Or No need to Change ...? its like tricky EDS5
Which class should you use to obtain design information about an object  2
Difference between ?System.out.println? and ?System.error.println?? Sai-Softech2
Can we add two byte variables and assign the result to a byte variable ? b=b1+b2 where b,b1,b2 are byte types TCS3
 
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