It's not a secret anymore!
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes example answer to Developer's exam Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "example answer to Developer Watch "example answer to Developer New topic

example answer to Developer's exam

Kathy Shkarlet
Ranch Hand

Joined: Dec 01, 2000
Posts: 43
I was browsing the sample questions / answers to the Developer's exam on Sun site and I'm not sure I agree with one of the answers.
In Question 3 (RMI vs sockets) one of the advantages they list is:
"RMI allows both state and behavior to be passed over the network".
But if I use serialization over socket connection - I'm sending an object over network. Object has both state and behaviour, so why are they listing it as the RMI advantage?!
Hope somebody enlighten me,
Jerry Pulley
Ranch Hand

Joined: Sep 19, 2000
Posts: 221
When you serialize an object yourself (via sockets), you're only passing the object's fields, not it's methods. You build a new object on the receiving end, using the fields passed over the socket connection. The class has to be on the client side as well as the server. The object's "behavior", from the point of view of the client, exists and runs on the client. Furthermore, all the connections to other objects that existed in the context of the server need to be recreated on the client side.
When you access an object via RMI, only the stub needs to be on the client side (it can, of course, be downloaded). The stub provides the interface to the object running on the server. The code implementing the object's behavior runs on the opposite (server) end of the connection, and the object continues to operate in its original context. The actual behavior is accessed remotely, which is not the case when you recreate the entire object on the client after serializing its state.
I agree. Here's the link:
subject: example answer to Developer's exam
It's not a secret anymore!