*
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


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "example answer to Developer Watch "example answer to Developer New topic
Author

example answer to Developer's exam

Kathy Shkarlet
Ranch Hand

Joined: Dec 01, 2000
Posts: 43
Hi,
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,
Thanks,
Kathy
Jerry Pulley
Ranch Hand

Joined: Sep 19, 2000
Posts: 221
Kathy,
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.
Jerry
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: example answer to Developer's exam
 
Similar Threads
RMI Vs Sockets!
moving state vs. behavior
Passed with 145 points
Can we pass this object on wire?
RMI Advantages / Disadvantages