This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
    Bookmark Topic Watch Topic
  • New Topic

Serializable issues !!

 
K Abhijit
Ranch Hand
Posts: 88
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
class A implements java.io.serilizable
{

int memeberA ;
}

class B extends class A
{

int memeberC ;

}

Q
1) can some one tell me if class B is serializable?
2) is ther any method to check if class B is serializable RUNTIME
3) Inacse i find an instance of some class (say any class say class C0 non serializable, can i make is serlializable on RUNTIME?
 
Graeme Jenkinson
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
This isn't really a serialization problem it's a failing in your understanding of a fundamental object orientation concept: inheritance (IS-A relationships). You really need to have a solid undersatnding of this concept in order to pass the certification exam. Therefore, I would strongly advise reading/re-reading Chapter 2 in S&B.

As a hint to help you on your way Question a) is asking if B IS-A java.io.serializable [sic], this could be tested by creating an instance of class B and using the instanceof operator.

thanks

Graeme
 
K Abhijit
Ranch Hand
Posts: 88
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
Thanks Jenkinson for the reply...

having class A serializable; we can not assume that Class B is also serializable ...

say class B extends class A and contains some attributes like Thread, OutputStream (which are not serializable objects), then class B would certainly not be serializable even if it extends A...

in the situation we were in, i was suppose to receive some derived object of class A (say class b/c/d) by external client which i was not having information of...
hence wanted to know if we have any runtime api to find out if object referred by the reference (base class reference to be more precise) is serializable or not...

anyway that situation is been handled in some other means...

thanks


 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
Serialization is no longer on the exam
 
K Abhijit
Ranch Hand
Posts: 88
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
was under wrong window of SCJP.
closing this; and opening a new thread @
http://www.coderanch.com/t/509136/java/java/Runtime-API-find-if-object#2301229
 
I agree. Here's the link: http://aspose.com/file-tools
    Bookmark Topic Watch Topic
  • New Topic