<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Java Interview Questions &#187; Java Important Notes</title>
	<atom:link href="http://www.bestjavainterviewquestions.com/category/java-important-notes/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bestjavainterviewquestions.com</link>
	<description>Java Interview Questions &#124; Core Java Interview Questions &#124; Advanced Java Interview Questions &#124; EJB Interview Questions &#124; J2EE Interview Questions &#124; Hibernate Interview Questions</description>
	<lastBuildDate>Fri, 03 Feb 2012 10:23:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to Make a Class Serializable</title>
		<link>http://www.bestjavainterviewquestions.com/how-to-make-a-class-serializable/</link>
		<comments>http://www.bestjavainterviewquestions.com/how-to-make-a-class-serializable/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 11:59:59 +0000</pubDate>
		<dc:creator>Ramakrishna</dc:creator>
				<category><![CDATA[Java Serialization]]></category>
		<category><![CDATA[deserialization]]></category>
		<category><![CDATA[marker interface]]></category>
		<category><![CDATA[serializable]]></category>
		<category><![CDATA[serialization]]></category>

		<guid isPermaLink="false">http://www.bestjavainterviewquestions.com/?p=613</guid>
		<description><![CDATA[So far, we&#8217;ve focused on the mechanics of serializing an object. We&#8217;ve assumed we have a serializable object and discussed, from the point of view of client code, how to serialize it. The next step is discussing how to make a class serializable. Serialization is also called as Marker Interface There are four basic things [...]]]></description>
			<content:encoded><![CDATA[<p>So far, we&#8217;ve focused on the mechanics of serializing an object. We&#8217;ve assumed we have a serializable object and discussed, from the point of view of client code, how to serialize it. The next step is discussing how to make a class serializable.</p>
<p>Serialization is also called as Marker Interface</p>
<p><strong><em>There are four basic things you must do when you are making a class serializable. They are:</em></strong></p>
<p>1. Implement the Serializable interface.</p>
<p>2. Make sure that instance-level, locally defined state is serialized properly.</p>
<p>3. Make sure that superclass state is serialized properly.</p>
<p>4. Override equals( ) and hashCode( ).</p>
<p>Let&#8217;s look at each of these steps in more detail.<br />
Implement the Serializable Interface</p>
<p>This is by far the easiest of the steps. The Serializable interface is an empty interface; it declares no methods at all. So implementing it amounts to adding &#8220;implements Serializable&#8221; to your class declaration.</p>
<p>Reasonable people may wonder about the utility of an empty interface. Rather than define an empty interface, and require class definitions to implement it, why not just simply make every object serializable? The main reason not to do this is that there are some classes that don&#8217;t have an obvious serialization. Consider, for example, an instance of File. An instance of File represents a file. Suppose, for example, it was created using the following line of code:</p>
<p>File file = new File(&#8220;c:\\New Floder\\Temp&#8221;);</p>
<p>It&#8217;s not at all clear what should be written out when this is serialized. The problem is that the file itself has a different lifecyle than the serialized data. The file might be edited, or deleted entirely, while the serialized information remains unchanged. Or the serialized information might be used to restart the application on another machine, where &#8220;C:\\New Floder\\Temp&#8221; is the name of an entirely different file.</p>
<p>Another example is provided by the Thread[4] class. A thread represents a flow of execution within a particular JVM. You would not only have to store the stack, and all the local variables, but also all the related locks and threads, and restart all the threads properly when the instance is deserialized.</p>
<p>TIP:   Things get worse when you consider platform dependencies. In general, any class that involves native code is not really a good candidate for serialization.</p>
<p>Make Sure That Instance-Level, Locally Defined State Is Serialized Properly</p>
<p>Class definitions contain variable declarations. The instance-level, locally defined variables (e.g., the nonstatic variables) are the ones that contain the state of a particular instance. For example, in our Money class, we declared one such field:</p>
<p>public class Money extends ValueObject {<br />
private int _cents;<br />
&#8230;.<br />
}</p>
<p>The serialization mechanism has a nice default behavior&#8211;if all the instance-level, locally defined variables have values that are either serializable objects or primitive datatypes, then the serialization mechanism will work without any further effort on our part. For example, our implementations of Account, such as Account_Impl, would present no problems for the default serialization mechanism:</p>
<p>public class Account_Impl extends UnicastRemoteObject implements Account {<br />
private Money _balance;<br />
&#8230;<br />
}</p>
<p>While _balance doesn&#8217;t have a primitive type, it does refer to an instance of Money, which is a serializable class.</p>
<p>If, however, some of the fields don&#8217;t have primitive types, and don&#8217;t refer to serializable classes, more work may be necessary. Consider, for example, the implementation of ArrayList from the java.util package. An ArrayList really has only two pieces of state:</p>
<p>public class ArrayList extends AbstractList implements List, Cloneable, java.io.<br />
Serializable {<br />
private Object elementData[];<br />
private int size;<br />
&#8230;<br />
}</p>
<p>But hidden in here is a huge problem: ArrayList is a generic container class whose state is stored as an array of objects. While arrays are first-class objects in Java, they aren&#8217;t serializable objects. This means that ArrayList can&#8217;t just implement the Serializable interface. It has to provide extra information to help the serialization mechanism handle its nonserializable fields. There are three basic solutions to this problem:<br />
<em><br />
<strong>* Fields can be declared to be transient.</strong></em></p>
<p><strong><em>* The writeObject( )/readObject( ) methods can be implemented.</em></strong></p>
<p><strong><em>* serialPersistentFields can be declared. </em></strong></p>
<p>&nbsp;</p>
<p><em><strong>You can find more information on serialization</strong></em> at <a title="Using Serialization" href="http://www.bestjavainterviewquestions.com/using-serialization/" target="_blank">1</a> and <a title="Brief information about serialization" href="http://www.bestjavainterviewquestions.com/explain-briefly-about-serialization/" target="_blank">2</a></p>
<h2  class="related_post_title">Related Post</h2><ul class="related_post"><li>July 21, 2010 -- <a href="http://www.bestjavainterviewquestions.com/explain-briefly-about-serialization/" title="Explain Briefly about Serialization">Explain Briefly about Serialization</a> (0)</li><li>July 21, 2010 -- <a href="http://www.bestjavainterviewquestions.com/using-serialization/" title="Using Serialization ">Using Serialization </a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.bestjavainterviewquestions.com/how-to-make-a-class-serializable/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using Serialization</title>
		<link>http://www.bestjavainterviewquestions.com/using-serialization/</link>
		<comments>http://www.bestjavainterviewquestions.com/using-serialization/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 11:53:11 +0000</pubDate>
		<dc:creator>Ramakrishna</dc:creator>
				<category><![CDATA[Java Serialization]]></category>
		<category><![CDATA[deserialization]]></category>
		<category><![CDATA[examples of deserialization]]></category>
		<category><![CDATA[examples of serialization]]></category>
		<category><![CDATA[serialization]]></category>
		<category><![CDATA[uses of serialization]]></category>

		<guid isPermaLink="false">http://www.bestjavainterviewquestions.com/?p=610</guid>
		<description><![CDATA[Serialization is a mechanism built into the core Java libraries for writing a graph of objects into a stream of data. This stream of data can then be programmatically manipulated, and a deep copy of the objects can be made by reversing the process. This reversal is often called deserialization. Note: When serializing an object [...]]]></description>
			<content:encoded><![CDATA[<p>Serialization is a mechanism built into the core Java libraries for writing a graph of objects into a stream of data. This stream of data can then be programmatically manipulated, and a deep copy of the objects can be made by reversing the process. This reversal is often called deserialization.</p>
<p><em><strong>Note: </strong>When serializing an object to a file, the standard convention in Java is to give the file a .ser extension.</em></p>
<p><strong><em>import java.io.*;</em></strong></p>
<p><strong><em>public class SerializeDemo<br />
{</em></strong></p>
<p><strong><em>public static void main(String [] args)<br />
{</em></strong></p>
<p><strong><em>Employee e = new Employee();<br />
e.name = &#8220;Ramakrishna&#8221;;<br />
e.address = &#8220;Hyderabad&#8221;;<br />
e.SSN = 11122333;<br />
e.number = 200113;</em></strong></p>
<p><strong><em>try<br />
{</em></strong></p>
<p><strong><em>FileOutputStream fileOut =<br />
new FileOutputStream(&#8220;employee.ser&#8221;);<br />
ObjectOutputStream out =<br />
new ObjectOutputStream(fileOut);<br />
out.writeObject(e);<br />
out.close();<br />
fileOut.close();</em></strong></p>
<p><strong><em>}catch(IOException i)<br />
{<br />
i.printStackTrace();<br />
}<br />
}<br />
}</em></strong></p>
<p><em>The following DeserializeDemo program deserializes the Employee object created in the SerializeDemo program. Study the program and try to determine its output:</em></p>
<p><strong><em>import java.io.*;</em></strong></p>
<p><strong><em>public class DeserializeDemo<br />
{</em></strong></p>
<p><strong><em>public static void main(String [] args)<br />
{</em></strong></p>
<p><strong><em>Employee e = null;</em></strong></p>
<p><strong><em>try<br />
{<br />
FileInputStream fileIn =<br />
new FileInputStream(&#8220;employee.ser&#8221;);<br />
ObjectInputStream in = new ObjectInputStream(fileIn);<br />
e = (Employee) in.readObject();<br />
in.close();<br />
fileIn.close();<br />
}catch(IOException i)<br />
{<br />
i.printStackTrace();<br />
return;</em></strong></p>
<p><strong><em>}catch(ClassNotFoundException c)<br />
{<br />
System.out.println(.Employee class not found.);<br />
c.printStackTrace();<br />
return;<br />
}</em></strong></p>
<p><strong><em>System.out.println(&#8220;Deserialized Employee&#8230;&#8221;);<br />
System.out.println(&#8220;Name: &#8221; + e.name);<br />
System.out.println(&#8220;Address: &#8221; + e.address);<br />
System.out.println(&#8220;SSN: &#8221; + e.SSN);<br />
System.out.println(&#8220;Number: &#8221; + e.number);<br />
}<br />
}</em></strong></p>
<p><em>This would produce following result:</em></p>
<p><em>Deserialized Employee&#8230;<br />
Name: Ramakrishna<br />
Address:Hyderabad<br />
SSN: 0<br />
Number:200113</em></p>
<p><strong><em><br />
</em></strong></p>
<p>In particular, there are three main uses of serialization:</p>
<p>As a persistence mechanism<br />
If the stream being used is FileOutputStream, then the data will automatically be written to a file.</p>
<p>As a copy mechanism<br />
If the stream being used is ByteArrayOutputStream, then the data will be written to a byte array in memory. This byte array can then be used to create duplicates of the original objects.</p>
<p>As a communication mechanism<br />
If the stream being used comes from a socket, then the data will automatically be sent over the wire to the receiving socket, at which point another program will decide what to do.</p>
<p>The important thing to note is that the use of serialization is independent of the serialization algorithm itself. If we have a serializable class, we can save it to a file or make a copy of it simply by changing the way we use the output of the serialization mechanism.</p>
<p>As you might expect, serialization is implemented using a pair of streams. Even though the code that underlies serialization is quite complex, the way you invoke it is designed to make serialization as transparent as possible to Java developers. To serialize an object, create an instance of ObjectOutputStream and call the writeObject( ) method; to read in a serialized object, create an instance of ObjectInputStream and call the readObject( ) object.</p>
<p><strong>TIP: </strong> <em>There are two versions of the serialization protocol currently defined: PROTOCOL_VERSION_1 and PROTOCOL_VERSION_2. If you send serialized data to a 1.1 (or earlier) JVM, you should probably use PROTOCOL_VERSION_1. The most common case of this involves applets. Most applets run in browsers over which the developer has no control. This means, in particular, that the JVM running the applet could be anything, from Java 1.0.2 through the latest JVM. Most servers, on the other hand, are written using JDK1.2.2 or later.[3] If you pass serialized objects between an applet and a server, you should specify the serialization protocol. </em></p>
<h2  class="related_post_title">Related Post</h2><ul class="related_post"><li>July 21, 2010 -- <a href="http://www.bestjavainterviewquestions.com/how-to-make-a-class-serializable/" title="How to Make a Class Serializable">How to Make a Class Serializable</a> (1)</li><li>July 21, 2010 -- <a href="http://www.bestjavainterviewquestions.com/explain-briefly-about-serialization/" title="Explain Briefly about Serialization">Explain Briefly about Serialization</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.bestjavainterviewquestions.com/using-serialization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Explain Briefly about Serialization</title>
		<link>http://www.bestjavainterviewquestions.com/explain-briefly-about-serialization/</link>
		<comments>http://www.bestjavainterviewquestions.com/explain-briefly-about-serialization/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 11:49:08 +0000</pubDate>
		<dc:creator>Ramakrishna</dc:creator>
				<category><![CDATA[Java Important Notes]]></category>
		<category><![CDATA[Java Serialization]]></category>
		<category><![CDATA[define serialization]]></category>
		<category><![CDATA[deserialization]]></category>
		<category><![CDATA[explain serialization]]></category>
		<category><![CDATA[marker interface]]></category>
		<category><![CDATA[serialization]]></category>

		<guid isPermaLink="false">http://www.bestjavainterviewquestions.com/?p=608</guid>
		<description><![CDATA[Serialization is the process of converting a set of object instances that contain references to each other into a linear stream of bytes, which can then be sent through a socket, stored to a file, or simply manipulated as a stream of data. Serialization is the mechanism used by RMI to pass objects between JVMs, [...]]]></description>
			<content:encoded><![CDATA[<p>Serialization is the process of converting a set of object instances that contain references to each other into a linear stream of bytes, which can then be sent through a socket, stored to a file, or simply manipulated as a stream of data. Serialization is the mechanism used by <a class="wp-caption" title="Frequently Asked Questions of RMI" href="http://www.bestjavainterviewquestions.com/java-rmi-interview-questions/" target="_blank">RMI </a>to pass objects between JVMs, either as arguments in a method invocation from a client to a server or as return values from a method invocation. In the first section of this book, I referred to this process several times but delayed a detailed discussion until now. In this chapter, we drill down on the serialization mechanism; by the end of it, you will understand exactly how serialization works and how to use it efficiently within your applications.</p>
<p>What does it mean for the client to pass an instance of Money to the server? At a minimum, it means that the server is able to call public methods on the instance of Money. One way to do this would be to implicitly make Money into a server as well.[1] For example, imagine that the client sends the following two pieces of information whenever it passes an instance as an argument:</p>
<ul>
<li><em> <strong>The type of the instance; in this case, Money.</strong></em></li>
<li><strong><em> A unique identifier for the object (i.e., a logical reference). For example, the address of the instance in memory.</em></strong></li>
</ul>
<p>The RMI runtime layer in the server can use this information to construct a stub for the instance of Money, so that whenever the Account server calls a method on what it thinks of as the instance of Money, the method call is relayed over the wire</p>
<p>Attempting to do things this way has three significant drawbacks:</p>
<ul>
<li><em> <strong>You can&#8217;t access fields on the objects that have been passed as arguments.</strong></em></li>
</ul>
<p>Stubs work by implementing an interface. They implement the methods in the interface by simply relaying the method invocation across the network. That is, the stub methods take all their arguments and simply marshall them for transport across the wire. Accessing a public field is really just dereferencing a pointer&#8211;there is no method invocation and hence, there isn&#8217;t a method call to forward over the wire.</p>
<ul>
<li><em> <strong>It can result in unacceptable performance due to network latency.</strong></em></li>
</ul>
<p>Even in our simple case, the instance of Account is going to need to call getCents( ) on the instance of Money. This means that a simple call to makeDeposit( ) really involves at least two distinct networked method calls: makeDeposit( ) from the client and getCents( ) from the server.</p>
<ul>
<li><em> <strong>It makes the application much more vulnerable to partial failure.</strong></em></li>
</ul>
<p>Let&#8217;s say that the server is busy and doesn&#8217;t get around to handling the request for 30 seconds. If the client crashes in the interim, or if the network goes down, the server cannot process the request at all. Until all data has been requested and sent, the application is particularly vulnerable to partial failures.</p>
<p>This last point is an interesting one. Any time you have an application that requires a long-lasting and durable connection between client and server, you build in a point of failure. The longer the connection needs to last, or the higher the communication bandwidth the connection requires, the more likely the application is to occasionally break down.<br />
TIP: The original design of the Web, with its stateless connections, serves as a good example of a distributed application that can tolerate almost any transient network failure. These three reasons imply that what is really needed is a way to copy objects and send them over the wire. That is, instead of turning arguments into implicit servers, arguments need to be completely copied so that no further network calls are needed to complete the remote method invocation. Put another way, we want the result of makeWithdrawal( ) to involve creating a copy of the instance of Money on the server side. The runtime structure should resemble</p>
<p>The desire to avoid unnecessary network dependencies has two significant consequences:</p>
<ul>
<li><strong><em>Once an object is duplicated, the two objects are completely independent of each other.</em></strong></li>
</ul>
<p>Any attempt to keep the copy and the original in sync would involve propagating changes over the network, entirely defeating the reason for making the copy in the first place.</p>
<ul>
<li><strong><em>The copying mechanism must create deep copies.</em></strong></li>
</ul>
<p>If the instance of Money references another instance, then copies must be made of both instances. Otherwise, when a method is called on the second object, the call must be relayed across the wire. Moreover, all the copies must be made immediately&#8211;we can&#8217;t wait until the second object is accessed to make the copy because the original might change in the meantime.</p>
<p>These two consequences have a very important third consequence:</p>
<ul>
<li><strong><em>If an object is sent twice, in separate method calls, two copies of the object will be created.</em></strong></li>
</ul>
<p>In addition to arguments to method calls, this holds for objects that are referenced by the arguments. If you pass object A, which has a reference to object C, and in another call you pass object B, which also has a reference to C, you will end up with two distinct copies of C on the receiving side.</p>
<h2  class="related_post_title">Related Post</h2><ul class="related_post"><li>July 21, 2010 -- <a href="http://www.bestjavainterviewquestions.com/how-to-make-a-class-serializable/" title="How to Make a Class Serializable">How to Make a Class Serializable</a> (1)</li><li>July 21, 2010 -- <a href="http://www.bestjavainterviewquestions.com/using-serialization/" title="Using Serialization ">Using Serialization </a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.bestjavainterviewquestions.com/explain-briefly-about-serialization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Delete the textbox using the Javascript</title>
		<link>http://www.bestjavainterviewquestions.com/how-to-delete-the-textbox-using-the-javascript/</link>
		<comments>http://www.bestjavainterviewquestions.com/how-to-delete-the-textbox-using-the-javascript/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 09:46:36 +0000</pubDate>
		<dc:creator>Ramakrishna</dc:creator>
				<category><![CDATA[Jsp Tutorial]]></category>
		<category><![CDATA[dhtml]]></category>
		<category><![CDATA[dynamic deleting textbox using javascript]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[removing the rows of form elements which are unwanted for storing in the database]]></category>

		<guid isPermaLink="false">http://www.bestjavainterviewquestions.com/?p=597</guid>
		<description><![CDATA[This topic is to delete the textbox/textarea/selectbox which will be created dynamically in the application using javascript if you need to delete the rows just u need to select that check box and go for the delete button . You can have this code for using in your application this must be related to the [...]]]></description>
			<content:encoded><![CDATA[<p>This topic is to delete the textbox/textarea/selectbox which will be created dynamically in the application using javascript</p>
<p>if you need to delete the rows just u need to select that check box and go for the delete button .</p>
<p>You can have this code for using in your application this must be related to the button which you will use in your application</p>
<p>the Code is<strong><em> </em></strong></p>
<p><strong><em><br />
</em></strong></p>
<p><strong><em>function deleteRow() {<br />
try {<br />
var table = document.getElementById(&#8216;myTable&#8217;);<br />
//alert(&#8216;table&#8217;+table);<br />
var rowCount = table.rows.length;</em></strong></p>
<p><strong><em>for(var i=0; i&lt;rowCount; i++) {<br />
var row = table.rows[i];<br />
var chkbox = row.cells[0].childNodes[0];<br />
if(null != chkbox &amp;&amp; false == chkbox.checked) {<br />
table.deleteRow(i);<br />
rowCount&#8211;;<br />
i&#8211;;<br />
}</em></strong></p>
<p><strong><em>}<br />
}catch(e) {<br />
alert(e);<br />
}<br />
}</em></strong></p>
<p><strong><em>&lt;INPUT type=&#8221;button&#8221; value=&#8221;Delete Row&#8221; onclick=&#8221;deleteRow()&#8221; /&gt;</em></strong></p>
<h2  class="related_post_title">Random Posts</h2><ul class="related_post"><li>September 2, 2008 -- <a href="http://www.bestjavainterviewquestions.com/define-session-tracking-in-httpservlet/" title="Define Session Tracking in HttpServlet">Define Session Tracking in HttpServlet</a> (0)</li><li>October 4, 2008 -- <a href="http://www.bestjavainterviewquestions.com/what-is-jtapi/" title="What is JTAPI">What is JTAPI</a> (0)</li><li>June 30, 2008 -- <a href="http://www.bestjavainterviewquestions.com/java-exception-handling-questions/" title="Java Exception Handling Questions">Java Exception Handling Questions</a> (0)</li><li>October 27, 2008 -- <a href="http://www.bestjavainterviewquestions.com/final-variables-and-methods/" title="Final Variables and Methods">Final Variables and Methods</a> (0)</li><li>September 22, 2008 -- <a href="http://www.bestjavainterviewquestions.com/what-are-command-line-arguments-in-java/" title="What are Command Line Arguments in Java">What are Command Line Arguments in Java</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.bestjavainterviewquestions.com/how-to-delete-the-textbox-using-the-javascript/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Define MultiTasking in Java</title>
		<link>http://www.bestjavainterviewquestions.com/define-multitasking-in-java/</link>
		<comments>http://www.bestjavainterviewquestions.com/define-multitasking-in-java/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 11:53:03 +0000</pubDate>
		<dc:creator>Ramakrishna</dc:creator>
				<category><![CDATA[Thread Tutorial]]></category>
		<category><![CDATA[MultiTasking]]></category>

		<guid isPermaLink="false">http://www.bestjavainterviewquestions.com/?p=505</guid>
		<description><![CDATA[MultiTasking : There are two types of executing the statements in MultiTasking. Executing several task at a time by the microprocessor is called MultiTasking. In MultiTasking the processor time is utilized in an optimum way The 2 type of MultiTasking are as follows. (i) Process Based MultiTasking : In this several programs are executed by [...]]]></description>
			<content:encoded><![CDATA[<p><strong>MultiTasking :</strong></p>
<p>There are two types of executing the statements in <em><strong>MultiTasking.</strong></em></p>
<p>Executing several task at a time by the microprocessor is called <em>MultiTasking.</em></p>
<p>In <em>MultiTasking </em>the processor time is utilized in an optimum way</p>
<p>The 2 type of MultiTasking are as follows.</p>
<p><strong>(i) Process Based MultiTasking : </strong></p>
<p>In this several programs are executed by the Microprocessor using RoundRobin Method.</p>
<p><strong>(ii) Thread Based MultiTasking :</strong></p>
<p>Executing different parts (methods ) of the same program at a time using thread is called<em> Thread Based MultiTasking.</em><strong><br />
</strong></p>
<h2  class="related_post_title">Random Posts</h2><ul class="related_post"><li>August 24, 2008 -- <a href="http://www.bestjavainterviewquestions.com/software-architecture-of-ejb/" title="Software  Architecture of EJB">Software  Architecture of EJB</a> (0)</li><li>September 2, 2008 -- <a href="http://www.bestjavainterviewquestions.com/difference-between-getcurrentsession-and-opensession/" title="Difference between getCurrentSession() and openSession()">Difference between getCurrentSession() and openSession()</a> (0)</li><li>September 2, 2008 -- <a href="http://www.bestjavainterviewquestions.com/advantage-of-cookies-over-url/" title="Advantage of Cookies over URL">Advantage of Cookies over URL</a> (0)</li><li>May 22, 2008 -- <a href="http://www.bestjavainterviewquestions.com/java-lang-package-interview-questions/" title="Java lang package interview questions">Java lang package interview questions</a> (2)</li><li>October 3, 2008 -- <a href="http://www.bestjavainterviewquestions.com/explain-jsp-directives/" title="Explain Jsp Directives">Explain Jsp Directives</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.bestjavainterviewquestions.com/define-multitasking-in-java/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>What is Port Number</title>
		<link>http://www.bestjavainterviewquestions.com/what-is-port-number/</link>
		<comments>http://www.bestjavainterviewquestions.com/what-is-port-number/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 11:38:33 +0000</pubDate>
		<dc:creator>Ramakrishna</dc:creator>
				<category><![CDATA[Java Important Notes]]></category>
		<category><![CDATA[core java]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[java.net]]></category>
		<category><![CDATA[net package]]></category>

		<guid isPermaLink="false">http://www.bestjavainterviewquestions.com/?p=506</guid>
		<description><![CDATA[The unique ID number alloted to a socket is called Port Number Related PostDecember 17, 2008 -- When the port number is changed (0)March 24, 2009 -- Define HashSet Class (0)December 17, 2008 -- Explain Stream Tokenizer (0)December 17, 2008 -- What is Abstract Class?Explan (0)December 12, 2008 -- URL Connection Class (0)]]></description>
			<content:encoded><![CDATA[<p>The unique ID number alloted to a socket is called <strong>Port Number</strong></p>
<h2  class="related_post_title">Related Post</h2><ul class="related_post"><li>December 17, 2008 -- <a href="http://www.bestjavainterviewquestions.com/when-the-port-number-is-changed/" title="When the port number is changed">When the port number is changed</a> (0)</li><li>March 24, 2009 -- <a href="http://www.bestjavainterviewquestions.com/define-hashset-class/" title="Define HashSet Class">Define HashSet Class</a> (0)</li><li>December 17, 2008 -- <a href="http://www.bestjavainterviewquestions.com/explain-stream-tokenizer/" title="Explain Stream Tokenizer">Explain Stream Tokenizer</a> (0)</li><li>December 17, 2008 -- <a href="http://www.bestjavainterviewquestions.com/what-is-abstract-classexplan/" title="What is Abstract Class?Explan">What is Abstract Class?Explan</a> (0)</li><li>December 12, 2008 -- <a href="http://www.bestjavainterviewquestions.com/url-connection-class/" title="URL Connection Class">URL Connection Class</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.bestjavainterviewquestions.com/what-is-port-number/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Servlet Summary</title>
		<link>http://www.bestjavainterviewquestions.com/servlet-summary/</link>
		<comments>http://www.bestjavainterviewquestions.com/servlet-summary/#comments</comments>
		<pubDate>Thu, 16 Oct 2008 16:18:45 +0000</pubDate>
		<dc:creator>Ramakrishna</dc:creator>
				<category><![CDATA[Servlet Summary]]></category>

		<guid isPermaLink="false">http://www.bestjavainterviewquestions.com/?p=485</guid>
		<description><![CDATA[&#8211;&#62; A servlet is a Java class that runs on a server, and a servlet for a web application extends the HttpServlet class. &#8211;&#62; When you write servlets , you override the doGet and doPost methods to provide the processing that’s required. These methods receive the request object and the  response object that are passed [...]]]></description>
			<content:encoded><![CDATA[<p><strong>&#8211;&gt; </strong>A servlet is a Java class that runs on a server, and a servlet for a web application extends the HttpServlet class.</p>
<p><strong>&#8211;&gt; </strong>When you write <strong>servlets </strong>, you override the <em>doGet </em>and <em>doPost </em>methods to provide the processing that’s required. These methods receive the request object and the  response object that are passed to them by the server.</p>
<p><strong>&#8211;&gt; </strong>After you use the <em>setContentType </em>method of the response object to set the content type of the response that’s returned to the browser, you use the <em>getWriter </em>method  to create a <em>PrintWriter </em>object. Then, you can use the <em>println </em>and print methods of  that object to send HTML back to the browser.</p>
<p><strong>&#8211;&gt; </strong>The class files for servlets must be stored in the <em>WEB-INF\classes</em> directory of an  application or in a subdirectory that corresponds to a package name.</p>
<p><strong>&#8211;&gt; </strong>To request a servlet from a URL, you include the word “servlet” after the document root directory in the path. This is followed by the package name, a dot, and the servlet name.</p>
<p><strong>&#8211;&gt; </strong>You can override the init method of a servlet to initialize its instance variables. These variables are then available to all of the threads that are spawned for the one instance of the servlet.</p>
<p><strong>&#8211;&gt; </strong>When you code a thread-safe servlet, you prevent two or more users from accessing  the same block of code at the same time.</p>
<p><strong>&#8211;&gt; </strong>To print debugging data to the server console, you can use the println method of  the System.out or System.err object. An alternative is to use the log methods of the  HttpServlet class to write debugging data to a log file.</p>
<h2  class="related_post_title">Random Posts</h2><ul class="related_post"><li>October 16, 2008 -- <a href="http://www.bestjavainterviewquestions.com/what-the-webxml-file-can-do/" title="What the web.xml file can do">What the web.xml file can do</a> (1)</li><li>July 12, 2008 -- <a href="http://www.bestjavainterviewquestions.com/hibernate-interview-questions-2/" title="Hibernate Interview Questions">Hibernate Interview Questions</a> (35)</li><li>August 10, 2008 -- <a href="http://www.bestjavainterviewquestions.com/can-we-call-destroy-method-on-servlets-from-service-method/" title="Can we call destroy() method on servlets from service method">Can we call destroy() method on servlets from service method</a> (0)</li><li>July 7, 2008 -- <a href="http://www.bestjavainterviewquestions.com/jms-interview-questions/" title="JMS INTERVIEW QUESTIONS">JMS INTERVIEW QUESTIONS</a> (1)</li><li>August 24, 2008 -- <a href="http://www.bestjavainterviewquestions.com/define-implicit-objects/" title="Define implicit objects">Define implicit objects</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.bestjavainterviewquestions.com/servlet-summary/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Explain the Instance Variables in Servlets</title>
		<link>http://www.bestjavainterviewquestions.com/explain-the-instance-variables-in-servlets/</link>
		<comments>http://www.bestjavainterviewquestions.com/explain-the-instance-variables-in-servlets/#comments</comments>
		<pubDate>Thu, 16 Oct 2008 16:08:18 +0000</pubDate>
		<dc:creator>Ramakrishna</dc:creator>
				<category><![CDATA[Java Important Notes]]></category>
		<category><![CDATA[instance variables in servlets]]></category>

		<guid isPermaLink="false">http://www.bestjavainterviewquestions.com/?p=477</guid>
		<description><![CDATA[instance variable &#8211;&#62; An instance variable of a servlet belongs to the one instance of the servlet and is shared by any threads that request the servlet. &#8211;&#62; You can initialize an instance variable in the init method. &#8211;&#62; If you don’t want two or more threads to modify an instance variable at the same [...]]]></description>
			<content:encoded><![CDATA[<p><span style="text-decoration: underline;"><strong>instance variable</strong></span></p>
<p><strong>&#8211;&gt; </strong> An instance variable of a servlet belongs to the one instance of the servlet and is shared by any threads that request the servlet.</p>
<p><strong>&#8211;&gt; </strong> You can initialize an instance variable in the init method.</p>
<p><strong>&#8211;&gt; </strong> If you don’t want two or more threads to modify an instance variable at the same time, you must synchronize the access to the instance variables.</p>
<p><strong>&#8211;&gt; </strong> To synchronize access to a block of code, you can use the synchronized keyword and the this keyword.</p>
<p>How to limit the use of code to a single thread at  three different levels. First, you can synchronize a block of code by using the synchronized and this keywords. Second, you can synchronize an entire method. Third, you can use the SingleThreadModel interface to limit the use of  an entire servlet to a single thread. That way, you don’t have to synchronize any  of the code within the servlet.</p>
<p>you must remember that one thread has to  wait while another thread is using a synchronized block of code, a synchronized method, or a single-thread servlet.</p>
<h2  class="related_post_title">Random Posts</h2><ul class="related_post"><li>September 30, 2008 -- <a href="http://www.bestjavainterviewquestions.com/define-implicit-variables-in-jsp/" title="Define Implicit Variables in JSP">Define Implicit Variables in JSP</a> (0)</li><li>October 16, 2008 -- <a href="http://www.bestjavainterviewquestions.com/define-jsp/" title="Define JSP">Define JSP</a> (2)</li><li>July 24, 2008 -- <a href="http://www.bestjavainterviewquestions.com/jsf-important-questions/" title="JSF Important Questions">JSF Important Questions</a> (2)</li><li>August 24, 2008 -- <a href="http://www.bestjavainterviewquestions.com/difference-between-string-and-stringbuffer/" title="Difference between String and StringBuffer">Difference between String and StringBuffer</a> (0)</li><li>October 16, 2008 -- <a href="http://www.bestjavainterviewquestions.com/479/" title="What is Thread Safe Servlet">What is Thread Safe Servlet</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.bestjavainterviewquestions.com/explain-the-instance-variables-in-servlets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Define JSP</title>
		<link>http://www.bestjavainterviewquestions.com/define-jsp/</link>
		<comments>http://www.bestjavainterviewquestions.com/define-jsp/#comments</comments>
		<pubDate>Thu, 16 Oct 2008 16:05:49 +0000</pubDate>
		<dc:creator>Ramakrishna</dc:creator>
				<category><![CDATA[Java Important Notes]]></category>
		<category><![CDATA[jsp content]]></category>

		<guid isPermaLink="false">http://www.bestjavainterviewquestions.com/?p=475</guid>
		<description><![CDATA[The instance variables and methods are initialized when the JSP is first requested. After that, each thread can access those instance variables and methods. The synchronized keyword prevents two threads from using the method or modifying the instance variable at the same time. This results in a thread-safe JSP. First, each JSP is translated into [...]]]></description>
			<content:encoded><![CDATA[<p>The instance variables and methods are initialized when the JSP is first requested. After that, each thread can access those instance variables and methods.</p>
<p>The synchronized keyword prevents two threads from using the method or modifying the instance variable at the same time. This results in a thread-safe JSP.</p>
<p>First, each JSP is translated into a servlet class.<br />
Second, the servlet class is compiled when the first user requests the JSP.<br />
Third, one instance of the servlet class is instantiated when the first user requests the JSP.<br />
Fourth, each user is treated as a thread by the servlet, and each thread gets its own copy of the local variables of the servlet methods.</p>
<p>When you use the Get method to pass parameters to a JSP, the parameters are displayed in the URL. When you use the Post method, they aren’t. Although the Get method transfers data faster than the Post method, you can’t use the Get method to transfer more than 4K of data.</p>
<p>You use a JSP directive known as a page directive to import classes for use in a JSP.</p>
<p>When you use JSP comments, the comments aren’t compiled or executed. In<br />
contrast, HTML comments are compiled and executed, but the browser doesn’t display them.</p>
<p>You use JSP declarations to declare instance variables and methods for a JSP. To code a thread-safe JSP, you must synchronize access to these instance variables and methods.</p>
<p>When a JSP is first requested, the JSP engine translates the page into a servlet and  compiles it. Then, one instance of the class is instantiated. For each subsequent  request, a new thread is created from this single instance of the servlet class. This means that each requestor gets its own copy of the local variables, but all requestors share the same instance variables.</p>
<p>Within the doGet method, the first two statements perform tasks that are<br />
common to most servlets that return an HTML document. Here, the first statement sets the content type that will be returned to the browser. In this case, the content type is set so that the servlet returns an HTML document, but it’s possible to return other content types. Then, the second statement returns a PrintWriter object that’s used to return data to the browser later on.</p>
<p>The doPost method calls the doGet method, an HTTP request that uses the Post method will actually execute the doGet method of the servlet.</p>
<h2  class="related_post_title">Random Posts</h2><ul class="related_post"><li>August 24, 2008 -- <a href="http://www.bestjavainterviewquestions.com/software-architecture-of-ejb/" title="Software  Architecture of EJB">Software  Architecture of EJB</a> (0)</li><li>August 24, 2008 -- <a href="http://www.bestjavainterviewquestions.com/define-business-logic-and-business-method/" title="Define business logic and business method">Define business logic and business method</a> (0)</li><li>January 26, 2009 -- <a href="http://www.bestjavainterviewquestions.com/uploading-file-name-of-image-to-database/" title="Uploading file name or image to DataBase">Uploading file name or image to DataBase</a> (0)</li><li>September 16, 2008 -- <a href="http://www.bestjavainterviewquestions.com/converting-hibernate-with-eclipse-integration/" title="Converting Hibernate with Eclipse Integration">Converting Hibernate with Eclipse Integration</a> (0)</li><li>July 7, 2008 -- <a href="http://www.bestjavainterviewquestions.com/java-rmi-interview-questions/" title="Java RMI Interview questions">Java RMI Interview questions</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.bestjavainterviewquestions.com/define-jsp/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Write a short notes on TOMCAT</title>
		<link>http://www.bestjavainterviewquestions.com/write-a-short-notes-on-tomcat/</link>
		<comments>http://www.bestjavainterviewquestions.com/write-a-short-notes-on-tomcat/#comments</comments>
		<pubDate>Thu, 16 Oct 2008 16:01:52 +0000</pubDate>
		<dc:creator>Ramakrishna</dc:creator>
				<category><![CDATA[Java Important Notes]]></category>
		<category><![CDATA[tomcat]]></category>

		<guid isPermaLink="false">http://www.bestjavainterviewquestions.com/?p=472</guid>
		<description><![CDATA[web.xml file that is known as the deployment descriptor. This file is used to configure a web application, and this figure should give you a general idea of what the web.xml file can do for an application. At the minimum, this file must contain the shaded code. This code defines the type of XML that’s [...]]]></description>
			<content:encoded><![CDATA[<p>web.xml file that is known as the deployment descriptor. This file is used to configure a web application, and this figure should give you a general idea of what the web.xml file can do for an application. At the minimum, this file must contain the shaded code. This code defines the type of XML that’s being used and the type of J2EE standards that the web.xml file follows.</p>
<h2  class="related_post_title">Random Posts</h2><ul class="related_post"><li>February 15, 2009 -- <a href="http://www.bestjavainterviewquestions.com/write-a-note-on-ejb-frame-work/" title="Write a note on EJB frame work">Write a note on EJB frame work</a> (0)</li><li>September 22, 2008 -- <a href="http://www.bestjavainterviewquestions.com/calling-a-method-in-java/" title="Calling a Method in Java">Calling a Method in Java</a> (1)</li><li>October 5, 2008 -- <a href="http://www.bestjavainterviewquestions.com/goto-statement-in-java/" title="GoTo statement in Java">GoTo statement in Java</a> (0)</li><li>January 14, 2009 -- <a href="http://www.bestjavainterviewquestions.com/sockets-programming-in-java-for-clientserver/" title="Sockets programming in Java for Client/Server">Sockets programming in Java for Client/Server</a> (0)</li><li>December 16, 2008 -- <a href="http://www.bestjavainterviewquestions.com/define-array-in-java/" title="Define Array in Java">Define Array in Java</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.bestjavainterviewquestions.com/write-a-short-notes-on-tomcat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

