TCP and UDP are two transport layer protocols, which are extensively used in internet for transmitting data between one host to another. Good knowledge of how TCP and UDP works is essential for any programmer. That's why difference between TCP and UDP is one of the most popular programming interview question. I have seen this question many times on various Java interviews , especially for server side Java developer positions. Since FIX (Financial Information Exchange) protocol is also a TCP based protocol, several investment banks, hedge funds, and exchange solution provider looks for Java developer with good knowledge of TCP and UDP. Writing fix engines and server side components for high speed electronic trading platforms needs capable developers with solid understanding of fundamentals including data structure, algorithms and networking. By the way, use of TCP and UDP is not limited to one area, its at the heart of internet. The protocol which is core of internet, HTTP is based on TCP. One more reason, why Java developer should understand these two protocol in detail is that Java is extensively used to write multi-threaded, concurrent and scalable servers. Java also provides rich Socket programming API for both TCP and UDP based communication. In this article, we will learn key differences between TCP and UDP protocol, which is useful to every Java programmers. To start with, TCP stands for Transmission Control Protocol and UDP stands for User Datagram Protocol, and both are used extensively to build Internet applications.
Thursday, July 17, 2014
Monday, July 14, 2014
Thursday, July 10, 2014
An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 153 is an Armstrong number, since 1**3 + 5**3 + 3**3 = 153, 371 is an Armstrong number since 3**3 + 7**3 + 1**3 = 371. Along with usual beginner exercises e.g. calculating factorial, reversing string or calculating prime numbers, this is a good exercise to build programming logic. It teaches you basic programming technique of how to use operator for something which is not obvious, for example, to solve this programming challenge, we first need to check if a number is Armstrong or not, and to do this we need individual digits of the number. how do we do that? well there is a programming technique, which you might have learned while doing number palindrome exercise. If you modulo an integer number by 10, you will get last digit, for example 656%10 will give you 6, which is last digit of 656. Similarly to reduce the input after each iteration, you can use division operator, as 656/10 will return 65, which is without last digit. If you know this trick, it's very easy to solve any programming problem, which requires examination of individual digits. This Java program uses same technique and compute all Armstrong numbers in the range of 0 and 999. By the way this program has different variations as well e.g. how do you find Armstrong number of four digit, as this program only calculates three digit Armstrong number. Well, for that you need to remember general definition of Armstrong number which is, An Armstrong number is an n-digit number that is equal to the sum of the nth powers of its digits. So a four digit Armstrong number will be equal to sum of power four of individual digits of that number. Another interesting challenge is to write a program which uses recursion to find if number is Armstrong or not.