Documente Academic
Documente Profesional
Documente Cultură
3. Java is an “ideal” language for network programming. Justify this statement in the
light of the following properties of the language:
a. The rich API that the language has.
b. The mechanism of data transfer it uses.
c. The platform-independence ability of the language.
d. The multi-threading support within the language.
Page 1 of 2
Semester I 2010/2011 Networked Computing
5. What are the TWO ways in which we can do multithreading in Java? Support your
answer with code snippets.
1. Write a simple code in Java to send an Employee object from a client to a server. The
server modifies the object’s attributes and sends it back to the client who then
displays it on the screen.
(Hint : You will need to create three classes :
i. Employee Class : Assume that it has only two attributes : employee
number and name. This class must be serializable.
ii. Client Class : Creates a new employee object, connects to the server using
socket and writes the object onto the socket. Later the client reads the object
as returned by the server and displays it.
iii. Server Class : Reads the object sent by a client, modifies it and resends back
to the client).
[10 marks]
2. Write simple code snippets in Java to know the IP address and port number of the
client who is accessing your server machine using:
(i) DatagramSocket (as in UDP).
(ii) ServerSocket (as in TCP).
[4 marks]
3. Write the server and the client code in Java to implement a simple Chat Application
that lets one client talk to another through the common server.
[6 marks]
Page 2 of 2
Semester I 2010/2011 Networked Computing