Core Java KB- Learning Journal



Aug 16 2006; Answers - last edit oct 15 2006


Diff between tcp and udp 
The 2 Transport layer protocols are, TCP and UDP. TCP provides connection-oriented, reliable, byte-stream packet delivery, while UDP provides connectionless, unreliable, byte-stream packet delivery. Also in both protocol forms,  the data payload are segmented into finite size fixed bytes packets.
What that means is connection-oriented protocol like TCP establish an end-to-end link along the intermediate nodes before any data moves. This ESTABLISHED link of nodes ( routers and switches) provides a secure and traceable pathway when data is moved in the form of electric signals along the wire over long distances.
A connectionless protocol [UDP] doesn't establish paths across the network before data can flow. Instead, the protocol routes connectionless packets or datagrams individually at each intermediate node.
  1. correct data corruption.
  2. packet arrive out of sequence at destination
  3. acknowledgements, retransmissions, wait timings
  4. duplicates
Reliable protocols safeguard against several forms of transmission mishaps/issues.

Transmission issue.1=data corruption
Solution.1=do checksum You can compare checksums included with a packet's data payload with a recalculation of the checksum algorithm at the destination to detect corrupted data. You must retransmit corrupted or lost data, so the protocol must provide methods for the destination to signal the source when retransmission is needed.

Transmission issue.2=packet arrive out of sequence at destination
Solution.2=buffer and order the packets correctly. Packetized data can arrive out of sequence, so the protocol must have a way to detect out-of-sequence packets, buffer them, and pass them to the Application layer in the correct order. 


Transmission issue.3=duplicates
solution.3=discard dups It must also detect and discard duplicate transmissions.


Transmission issue.4=acknowledgements, retransmissions, wait timings
solution.4=use timers. A collection of timers enables limiting the wait for various acknowledgements, so you can initiate retransmissions or link re-establishment. 

Byte-stream protocols don't specifically support data units other than bytes. TCP can't structure bytes of the data payload in a packet, nor can it cope with individual bits. As far as TCP is concerned, it's responsible for transporting an unstructured string of 8-bit bytes.

A connectionless protocol [UDP] doesn't establish paths across the network before data can flow. Instead, the protocol routes connectionless packets or datagrams individually at each intermediate node.


Without an end-to-end link, a connectionless protocol such as UDP isn't reliable. When a UDP packet moves into the network, the sending process can't know whether the packet arrives at its destination unless the Application layer acknowledges this fact. Nor can the protocol detect duplicate or out-of-sequence packets. The standard jargon describes UDP as "unreliable," though a more descriptive term might be "nonreliable." On modern networks, UDP traffic isn't prone to disruption, but you can't really call it "reliable," either. 



Aug 16 2006;
Questions and Answers

1. Explain in context of java  - final, finally, finalize
2. What is deadlock,cause of deadlock, steps to avoid to it.  
3. Diff between semaphore and mutex.
4. What is difference between object.wait() and thead.join()?
5. Diff between public static synchronized vs public synchronized
6. What is surrogate primary key? what is candidate key?
7. What is functional dependency? transitive dependency?
8. log4j vs java logging.
9. difference between
a.java.sql.statement
b. prepared statement
c. callable statement
10. a class does not marked as serializable participate in the ejb call as return object. caller fails with throwing exceptions. how to fix it?
a. java.rmi.remote interface.
11. what is difference between java.rmi.remote and java.lang.Serializable.
12. new string s;
a.  s.intern();
13. difference between java == and equals().
14. How do you make the software code you wrote is good?
a.      junit.
b.      basic smoke/functional testing testcases with inputs.
15.   what is your preferred OS development environment? what is your preferred editor vi or emacs?








No comments: