aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Serializable issues !! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply locked New topic
Author

Serializable issues !!

K Abhijit
Ranch Hand

Joined: Mar 03, 2008
Posts: 88
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?


“The difference between 'involvement' and 'commitment' is like an eggs-and-ham breakfast: the chicken was 'involved' - the pig was 'committed'.”
Graeme Jenkinson
Greenhorn

Joined: Sep 08, 2008
Posts: 27
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

Joined: Mar 03, 2008
Posts: 88
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

Joined: Oct 25, 2008
Posts: 2700

Serialization is no longer on the exam


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
K Abhijit
Ranch Hand

Joined: Mar 03, 2008
Posts: 88
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
 
subject: Serializable issues !!
 
Similar Threads
is Serialization Inherited
doubt in serialization
6 Qs
Technical Interview Questions
Serialization with inheritance