Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within I/O and Streams
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Ron McLeod
Paul Clapham
Tim Cooke
Devaka Cooray
Sheriffs:
Liutauras Vilda
paul wheaton
Rob Spoor
Saloon Keepers:
Tim Moores
Stephan van Hulst
Tim Holloway
Piet Souris
Mikalai Zaikin
Bartenders:
Carey Brown
Roland Mueller
Forum:
I/O and Streams
what is the flow of this program?
Radhakrishna Sharma Gorenta
Ranch Hand
Posts: 63
I like...
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
public class A { public A() { System.out.println("A"); } } public class B extends A implements Serializable { public B() { System.out.println("B"); } } public class Test { public static void main(String... args) throws Exception { B b = new B(); ObjectOutputStream save = new ObjectOutputStream(new FileOutputStream("datafile")); save.writeObject(b); save.flush(); ObjectInputStream restore = new ObjectInputStream(new FileInputStream("datafile")); B z = (B) restore.readObject(); } }
Regards,
Radhakrishna
Mohamed Sanaulla
Bartender
Posts: 3225
34
I like...
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Did you try executing it? May be you can use a debugger to find out the flow of the program, or may be add print statements to track the flow.
Mohamed Sanaulla |
My Blog
| Author of
Java 9 Cookbook
|
Java 11 Cookbook
Radhakrishna Sharma Gorenta
Ranch Hand
Posts: 63
I like...
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
the output of this program is:
A
B
A
but how ?
Regards,
Radhakrishna
Ulf Dittmer
Rancher
Posts: 43081
77
posted 13 years ago
1
Number of slices to send:
Optional 'thank-you' note:
Send
Here's a little hint: Replace
public class A {
by
public class A implements Serializable {
and see what happens. Can you conclude anything from that?
Radhakrishna Sharma Gorenta
Ranch Hand
Posts: 63
I like...
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
yes.we can get output if we do that. but i want to know flow for this
Regards,
Radhakrishna
Remember to always leap before you look. But always take the time to smell the tiny ads:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Serialization
Serialization and deserialization
Serialization Doubt
doubt in reading object file
serialization
More...