5
Networking with java model1 part A 2marks 1.Distinguish host and node. Each machine on a network is called a node. Most nodes are computers, but printe rs, routers, bridges, gateways, dumb terminals, and Coca-Cola machines can also b e nodes .Every network node has an address, a series of bytes that uniquely iden tify it.The word host is a node that is a general-purpose computer. 2.Define ethernet addresses. Ethernet addresses are attached to the physical Ethernet hardware. Manufacturers of Ethernet hardware use pre-assigned manufacturer codes to make sure there are no conflicts between the addresses in their hardware and the addresses of other manufacturer s hardware. Each manufacturer is responsible for making sure it does n t ship two Ethernet cards with the same address 3. Give four layers of TCP/IP network. Hosts to network, Internet, transport, Application are four layers. 4. Distinguish between URN and URL. There are two types of URIs: Uniform Resource Locators (URLs) and Uniform Resour ce Names (URNs). A URL is a pointer to a particular resource on the Internet at a particular location. For example, http://www.oreilly.com/catalog/javanp3/ is o ne of several URLs for the book Java Network Programming. A URN is a name for a particular resource but without reference to a particular location. For instance , urn:isbn: 1565928709 is a URN referring to the same book. As this example show s, URNs,unlike URLs, are not limited to Internet resources. 5. What is relative URL? For example, suppose that while browsing http://www.ibiblio.org/javafaq/javatuto rial.html you click on this hyperlink: <a href="javafaq.html"> The browser cuts javatutorial.html off the end of http://www.ibiblio.org/javafaq /javatutorial.html to get http://www.ibiblio.org/javafaq/. Then it attaches java faq.html onto the end of http://www.ibiblio.org/javafaq/ to get http://www.ibib lio.org/javafaq/javafaq.html. Finally, it loads that document.If the relative li nk begins with a /, then it is relative to the document root instead of relative to the current file. Thus, if you click on the following link while browsing ht tp://www.ibiblio.org/javafaq/javatutorial.html:<a href="/boutell/faq/www_faq.htm l"> the browser would throw away /javafaq/javatutorial.html and attach /boutell/ faq/ www_faq.html to the end of http://www.ibiblio.org to get http://www.ibiblio .org/boutell/faq/www_faq.html. 6. What IS HTTP? HTTP is the standard protocol for communication between web browsers and web servers. HTTP specifies how a client and server establish a connection, how the client requests data from the server, how the server responds to that request, a nd finally, how the connection is closed. HTTP connections use the TCP/IP protoc ol for data transfer. For each request from client to server, there is a sequenc e of four steps: Making the connection :The client establishes a TCP conn ection to the server on port 80, by default; other ports may be specified in the URL. Making a request: The client sends a message to the server requesting the page at a specified URL.The format of this request is typically something like: GET /index.html HTTP/1.0 7. What is output stream? Output Streams Java s basic output class is java.io.OutputStream: public abstract class OutputStream This class provides the fundamental meth ods needed to write data. These are:

2marks

Embed Size (px)

DESCRIPTION

networking with java model questions and answers

Citation preview

Page 1: 2marks

Networking with java model1part A 2marks1.Distinguish host and node.Each machine on a network is called a node. Most nodes are computers, but printers, routers, bridges, gateways, dumb terminals, and Coca-Cola� machines can also be nodes .Every network node has an address, a series of bytes that uniquely identify it.The word host is a node that is a general-purpose computer. 2.Define ethernet addresses.Ethernet addresses are attached to the physical Ethernet hardware. Manufacturers of Ethernet hardware use pre-assigned manufacturer codes to make sure there are no conflicts between the addresses in their hardware and the addresses of other manufacturer�s hardware. Each manufacturer is responsible for making sure it doesn�t ship two Ethernet cards with the same address 3. Give four layers of TCP/IP network. Hosts to network, Internet, transport, Application are four layers. 4. Distinguish between URN and URL. There are two types of URIs: Uniform Resource Locators (URLs) and Uniform Resource Names (URNs). A URL is a pointer to a particular resource on the Internet at a particular location. For example, http://www.oreilly.com/catalog/javanp3/ is one of several URLs for the book Java Network Programming. A URN is a name for a particular resource but without reference to a particular location. For instance, urn:isbn: 1565928709 is a URN referring to the same book. As this example shows, URNs,unlike URLs, are not limited to Internet resources.5. What is relative URL? For example, suppose that while browsing http://www.ibiblio.org/javafaq/javatutorial.html you click on this hyperlink:<a href="javafaq.html">The browser cuts javatutorial.html off the end of http://www.ibiblio.org/javafaq/javatutorial.html to get http://www.ibiblio.org/javafaq/. Then it attaches javafaq.html onto the end of http://www.ibiblio.org/javafaq/ to get http://www.ibiblio.org/javafaq/javafaq.html. Finally, it loads that document.If the relative link begins with a /, then it is relative to the document root instead of relative to the current file. Thus, if you click on the following link while browsing http://www.ibiblio.org/javafaq/javatutorial.html:<a href="/boutell/faq/www_faq.html"> the browser would throw away /javafaq/javatutorial.html and attach /boutell/faq/ www_faq.html to the end of http://www.ibiblio.org to get http://www.ibiblio.org/boutell/faq/www_faq.html.6. What IS HTTP? HTTP is the standard protocol for communication between web browsers and web servers. HTTP specifies how a client and server establish a connection, how the client requests data from the server, how the server responds to that request, and finally, how the connection is closed. HTTP connections use the TCP/IP protocol for data transfer. For each request from client to server, there is a sequence of four steps: Making the connection :The client establishes a TCP connection to the server on port 80, by default; other ports may be specified in the URL. Making a request: The client sends a message to the server requesting the page at a specified URL.The format of this request is typically something like: GET /index.html HTTP/1.0 7. What is output stream? Output Streams Java�s basic output class is java.io.OutputStream: public abstract class OutputStream This class provides the fundamental methods needed to write data. These are:

Page 2: 2marks

public abstract void write(int b) throws IOExceptionpublic void write(byte[] data) throws IOExceptionpublic void write(byte[] data, int offset, int length) throws IOException public void flush( ) throws IOException public void close( ) throws IOException 8. What is input stream? Input Streams Java�s basic input class is java.io.InputStream: public abstract class InputStream This class provides the fundamental methods needed to read data as raw bytes. These are: public abstract int read( ) throws IOException public int read(byte[] input) throws IOException public int read(byte[] input, int offset, int length) throws IOException public long skip(long n) throws IOException public int available( ) throws IOException public void close( ) throws IOException 9. Give two methods of creating threads. To give a thread something to do, you either subclass the Thread class and override its run( ) method, or implement the Runnable interface and pass the Runnable object to the Thread constructor. 10. What is deadlock? Deadlock occurs when two threads need exclusive access to the same set of resources and each thread holds the lock on a different subset of those resources. Networking with java model22 marks1.Where Inet class is used?It is used by most of the other networking classes, including Socket, ServerSocket, URL, DatagramSocket, DatagramPacket, and more. Generally, it includes both a hostname and an IP address.2.What is Security issue? Untrusted host not allowed to do DNS lookup.3.What is testing reachability? Testing Reachability // Java 1.5 Java 1.5 adds two new methods to the InetAddress class that enable applications to test whether a particular node is reachable from the current host; that is, whether a network connection can be made. Connections can be blocked for many reasons, including firewalls, proxy servers, misbehaving routers, and broken cables, or simply because the remote host is not turned on when you try to connect. The isReachable( ) methods allow you to test the connection: public boolean isReachable(int timeout) throws IOExcep

Page 3: 2marks

tion public boolean isReachable(NetworkInterface interface, int ttl, int timeout) throws IOException 4.How many protocols are in HotJava? 14 protocols are there (8 standard protocols, 3 custom protocols for various Java APIs, and 4 undocumented protocols used internally by HotJava). 5.What are 5 pieces of URL? URLs are composed of five pieces: � The scheme, also known as the protocol� The authority � The path � The query string For example, given the URL http://www.ibiblio.org/javafaq/books/jnp/index.html?isbn=1565922069#toc, the scheme is http, the authority is www.ibiblio.org, the path is /javafaq/books/jnp/index.html, the fragment identifier is toc, and the query string is isbn=1565922069. 6.What are the seven functions sockets can perform? A socket is a connection between two hosts. It can perform seven basic functions � Connect to a remote machine � Send data � Receive data � Close a connection � Bind to a port � Listen for incoming data � Accept connections from remote machines on the bound port7.What are the four options in the class of service?Class of service � 0x02: Low cost � 0x04: High reliability � 0x08: Maximum throughput � 0x10: Minimum delay8.Give the use of client tester program.Example 10-5 is a program called ClientTester that runs on a port specified on the command line, shows all data sent by the client, and allows you to send a response to the client by typing it on the command line. For example, you can use this program to see the commands that Internet Explorer sends to a server.9.What is secure socket?Java Secure Sockets Extension (JSSE). Although JSSE is now part of the standard distribution of the JDK, it is still hobbled by design decisions made to support earlier, less liberal export control regulations, and it is therefore less simp

Page 4: 2marks

le and easy to use than it could or should be. Nonetheless, JSSE can secure network communications using the Secure Sockets Layer (SSL) Version 3 and Transport Layer Security (TLS) protocols and their associated algorithms. SSL is a security protocol that enables web browsers to talk to web servers using various levels of confidentiality and authentication.10.What is the use of channel? Channels - Channels move blocks of data into and out of buffers to and from various I/O sources such as files, sockets, datagrams, and so forth.Networking with java model32marks questions1. What are the two clssses for sending UDP datagrams?DatagramPacket and DatagramSocket are the two classes. To send data, data is put in DatagramPocket and is sent using a DatagramSocket.2. What is the maximum IPV4 datagram packet size? What is the maximum IPV6 datagram packet size? Whjat makes datagram packet size limited to 8192 bytes?The theoretical limit for an IPv4 datagram is 65,507 bytes of data, and a DatagramPacket with a 65,507-byte buffer canreceive any possible IPv4 datagram without losing data. IPv6 datagrams raise the theoretical limit to 65,536 bytes.In fact, many operating systems don�t support UDP datagrams with more than 8K of data and either truncate, split, or discard larger datagrams.3.What is a Multicasting?Multicasting sends data from one host to many different hosts, but not to everyone; the data only goes to clients that have expressed an interest by joining a particular multicast group.(like public meeting - people who can hear hear.)4. What is the range of multicast address?Multicast addresses are IP addresses in the range 224.0.0.0 to 239.255.255.255. All addresses in this range have the binary digits 1110 as their first four bitsare called Class D addresses.5. What is URLConnection class?URLConnection is an abstract class that represents an active connection to a resource specified by a URL.You can use a URLConnection to download binary files. Finally, a URLConnection lets you send data back to a web server with POST or PUT and use other HTTP request methods.6. What protocols java does not support out of box?standard protocols such as finger, whois, or NTP Java doesn�t support out of the box7. What is the default port for DayTime protocol handler? What data it returns?DEFAULT_PORT = 13;The sample data it returns is Fri Oct 29 14:32:07 1999. 8. What is content handler?content handler is an instance of a subclass of java.net.ContentHandler:This class knows how to take a URLConnection and a MIME type and turn the data coming from the URLConnection into a Java object of an appropriate type. Thus, a content handler allows a program to understand new kinds of data. 9.What is remote method invocation?RMI lets Java objects on different hosts communicate with each other in a way that�s similar to how objects running in the same virtual machine communicate with eachother: by calling methods in objects. A remote object lives on a server. Each remote object implements a remote interface that specifies which of its methods can beinvoked by clients. Clients invoke the methods of the remote object almost exactly as they invoke local methods. 10. What is JavaMail API?The JavaMail API is a fairly high-level representation of the basicc omponents of any email system. The components are represented by abstract classes in the javax.mailpackage. For instance, the abstract class javax.mail.Message represents an email message. It declares abstract methods to get and set various kinds of envelope

Page 5: 2marks

information for the message, such as the sender and addressee, the date sent, and the subject of the message. The abstract class javax.mail.Folder represents a messagecontainer. It declares abstract methods to get messages from a folder, move messages between folders, and delete messages from a folder.These classes are all abstract because they don�t make many assumptions about how the email is stored or transferred between machines. For instance, they do not assume that messages are sent using SMTP or that they�re structured as specified in RFC 822.