Google Search

Monday, May 3, 2010

DNS(Domain Name System )




  • Short for Domain Name System (or Service or Server), an Internet service that translates domain names into IP addresses. Because domain names are alphabetic, they're easier to remember. The Internet however, is really based on IP addresses. Every time you use a domain name, therefore, a DNS service must translate the name into the corresponding IP address. For example, the domain name www.example.com might translate to 198.105.232.4.
  • The DNS system is, in fact, its own network. If one DNS server doesn't know how to translate a      particular domain name, it asks another one, and so on, until the correct IP address is returned.


  • Short for digital nervous system, a term coined by Bill Gates to describe a network of personal computers that make it easier to obtain and understand information.

IP address



An identifier for a computer or device on a TCP/IP network. Networks using the TCP/IP protocol route messages based on the IP address of the destination. The format of an IP address is a 32-bit numeric address written as four numbers separated by periods. Each number can be zero to 255. For example, 1.160.10.110 could be an IP address.
Within an isolated network, you can assign IP addresses at random as long as each one is unique. However, connecting a private network to theInternet requires using registered IP addresses (called Internet addresses) to avoid duplicates.

The four numbers in an IP address are used in different ways to identify a particular network and a host on that network. Four regional Internetregistries -- ARIN, RIPE NCC, LACNIC and APNIC -- assign Internet addresses from the following three classes.
·  Class A - supports 16 million hosts on each of 126 networks
·  Class B - supports 65,000 hosts on each of 16,000 networks
·  Class C - supports 254 hosts on each of 2 million networks
The number of unassigned Internet addresses is running out, so a new classless scheme called CIDR is gradually replacing the system based on classes A, B, and C and is tied to adoption of IPv6.

UDP(Usenet Death Penalty)

Abbreviated UDP, a Usenet penalty enforced by system administrators of an ISP or NSP against other service providers. Usenet is by nature cooperative, and the UDP is one way that administrators can handle uncooperative members. UDPs are typically issued to ISP/NSPs that have users that are spamming and that have not stopped the users from doing so even after repeated requests for the administrators to deal with the spam. When a UDP is issued, any messages posted to Usenet from that site will be cancelled. UDPs are also issued to individual spammers

UDP(User Datagram Protocol)

Abbreviated UDP, a connectionless protocol that, like TCP, runs on top of IP networks. Unlike TCP/IP, UDP/IP provides very few error recovery services, offering instead a direct way to send and receive datagrams over an IP network. It's used primarily for broadcasting messages over a network.

TCP

Abbreviation of Transmission Control Protocol, and pronounced as separate letters. TCP is one of the main protocols in TCP/IPnetworks. Whereas the IP protocol deals only with packets, TCP enables two hosts to establish a connection and exchange streams of data. TCP guarantees delivery of data and also guarantees that packets will be delivered in the same order in which they were sent.

What is thread.Explain the concept of Multithreading Programing with an Example?



Definition: A thread is a single sequential flow of control within a program.
Introduction
So far you have learned about a single thread. Lets us know about the concept of multithreading and learn the implementation of it. But before that, lets be aware from the multitasking.
Multitasking :


Multitasking allow to execute more than one tasks at the same time, a task being a program. In multitasking only one CPU is involved but it can switches from one program to another program so quickly that's why it gives the appearance of executing all of the programs at the same time. Multitasking allow processes (i.e. programs) to run concurrently on the program. For Example running the spreadsheet program and you are working with word processor also.
Multitasking is running heavyweight processes by a single OS.
Multithreading :
Multithreading is a technique that allows a program or a process to execute many tasks concurrently (at the same time and parallel). It allows a process to run its tasks in parallel mode on a single processor system
In the multithreading concept, several multiple lightweight processes are run in a single process/task or program by a single processor. For Example, When you use a word processoryou perform a many different tasks such as printing, spell checking and so on. Multithreaded software treats each process as a separate program.
In Java, the Java Virtual Machine (JVM) allows an application to have multiple threads of execution running concurrently. It allows a program to be more responsible to the user. When a program contains multiple threads then the CPU can switch between the two threads to execute them at the same time.
For example, look at the diagram shown as:


In this diagram, two threads are being executed having more than one task. The task of each thread is switched to the task of another thread.
Advantages of multithreading over multitasking :
• Reduces the computation time.
• Improves performance of an application.
• Threads share the same address space so it saves the memory.
• Context switching between threads is usually less expensive than between processes.
• Cost of communication between threads is relatively low.
Different states implementing Multiple-Threads are:
As we have seen different states that may be occur with the single thread. A running thread can enter to any non-runnable state, depending on the circumstances. A thread cannot enters directly to the running state from non-runnable state, firstly it goes to runnable state. Now lets understand the some non-runnable states which may be occur handling the multithreads.
• Sleeping – On this state, the thread is still alive but it is not runnable, it might be return to runnable state later,                           If a particular event occurs. On this state a thread sleeps for a specified amount of time. You can use the  method sleep( ) to stop the running state of a thread.


static void sleep(long millisecond) throws InterruptedException
• Waiting for Notification – A thread waits for notification from another thread. The thread sends back to runnable state after sending notification from another thread.


final void wait(long timeout) throws InterruptedException
final void wait(long timeout, int nanos) throws InterruptedException
final void wait() throws InterruptedException


• Blocked on I/O – The thread waits for completion of blocking operation. A thread can enter on this state because of waiting I/O resource. In that case the thread sends back to runnable state after availability of resources.


• Blocked for joint completion – The thread can come on this state because of waiting the completion of another thread.


• Blocked for lock acquisition – The thread can come on this state because of waiting to acquire the lock of an object.

What is checked exeption and unchecked exeption . Explain some of these exeption with an Example?



In Java there are basically two types of exceptions: Checked exceptions and unchecked exceptions. C# only has unchecked exceptions. The differences between checked and unchecked exceptions are:
1. Checked exceptions must be explicitly caught or propagated as described in Basic try-catch-finally Exception Handling. Unchecked exceptions do not have this requirement. They don't have to be caught or declared thrown.
2. Checked exceptions in Java extend the java.lang.Exception class. Unchecked exceptions extend the java.lang.RuntimeException.
3. There are many arguments for and against both checked and unchecked, and whether to use checked exceptions at all. I will go through the most common arguments throughout this text. Before I do so, let me just make one thing clear:
4. Checked and unchecked exceptions are functionally equivalent. There is nothing you can do with checked exceptions that cannot also be done with unchecked exceptions, and vice versa.
5. Regardless of your choice between checked and unchecked exceptions it is a matter of personal or organisational style. None is functionally better than the other.
A Simple Example
Before discussing the advantages and disadvantages of checked and unchecked exceptions I will show you the difference in the code they make. Here is a method that throws a checked exception, and another method that calls it:
public void storeDataFromUrl(String url){
try {
String data = readDataFromUrl(url);
} catch (BadUrlException e) {
e.printStackTrace();
}
}
public String readDataFromUrl(String url)
throws BadUrlException{
if(isUrlBad(url)){
throw new BadUrlException("Bad URL: " + url);
}
String data = null;
//read lots of data over HTTP and return
//it as a String instance.
return data;
}
As you can see the readDataFromUrl() method throws a BadUrlException. I have created BadUrlException myself. BadUrlException is a checked exception because it extends java.lang.Exception:
public class BadUrlException extends Exception {
public BadUrlException(String s) {
super(s);
}
}
If storeDataFromUrl() wants to call readDataFromUrl() it has only two choices. Either it catches the BadUrlException or propagates it up the call stack. The storeDataFromUrl() listed above catches the exception. This storeDataFromUrl() implementation propagates the BadUrlException instead:
public void storeDataFromUrl(String url)
throws BadUrlException{
String data = readDataFromUrl(url);
}
Notice how the try catch block is gone and a "throws BadUrlException" declaration is added instead. Now, let's see how it looks with unchecked exceptions. First I change the BadUrlException to extend java.lang.RuntimeException instead:
public class BadUrlException extends RuntimeException {
public BadUrlException(String s) {
super(s);
}
}
Then I change the methods to use the now unchecked BadUrlException:
public void storeDataFromUrl(String url){
String data = readDataFromUrl(url);
}
public String readDataFromUrl(String url) {
if(isUrlBad(url)){
throw new BadUrlException("Bad URL: " + url);
}
String data = null;
//read lots of data over HTTP and
//return it as a String instance.
return data;
}
Notice how the readDataFromUrl() method no longer declares that it throws BadUrlException. The storeDataFromUrl() method doesn't have to catch the BadUrlException either. The storeDataFromUrl() method can still choose to catch the exception but it no longer has to, and it no longer has to declare that it propagates the exception.

referal link