<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3801399119963252615</id><updated>2011-11-27T15:20:29.636-08:00</updated><category term='Java Interview Qns-5'/><category term='STRUTS INTERVIEW-7'/><category term='J2ee Interview Questions'/><category term='CORE JAVA faqs-9'/><category term='CORE JAVA faqs-7'/><category term='Java is suitable for building large applications'/><category term='STRUTS INTERVIEW-5'/><category term='JVM FAQs-2'/><category term='Java&apos;s performance problems are temporary'/><category term='CORE JAVA faqs-4'/><category term='Java vs C'/><category term='Introduction-spring'/><category term='CORE JAVA faqs-1'/><category term='CORE JAVA faqs-6'/><category term='Java = Basic'/><category term='STRUTS INTERVIEW-2'/><category term='Interview Questions-1'/><category term='Java Interview Qns-3'/><category term='CORE JAVA faqs-3'/><category term='Java like HTML'/><category term='C++'/><category term='STRUTS INTERVIEW-3'/><category term='Java Interview Qns-1'/><category term='SRUTS INTERVIEW'/><category term='J2ee Interview Questions-1'/><category term='JVM FAQs'/><category term='CORE JAVA faqs-8'/><category term='JVM FAQs-1'/><category term='Java in a browser eliminates the need for CGI scripts and programs'/><category term='java solves Cross-Platform application Dev.'/><category term='Java will replace C++ as the language of choice'/><category term='Netscape&apos;s JavaScript is related to Java'/><category term='Java can be extended to do anything the machine'/><category term='CORE JAVA faqs-5'/><category term='Java Interview Qns-2'/><category term='Java easy unlike C'/><category term='STRUTS INTERVIEW-6'/><category term='CORE JAVA faqs-2'/><category term='STRUTS INTERVIEW-4'/><category term='Java Interview Qns-4'/><title type='text'>JAVA Realtime Questions</title><subtitle type='html'>CORE AND ADVANCED JAVA WITH Java Virtual Machine,Web Tier and the EJB Tier,Java Exceptions,Java Inheritance,rEALTIME sCENARIOS,cONCEPT WISE DISCUSSION, iNTERVIEW tIPS, AND so ON ...</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>39</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-4829623591695369838</id><published>2008-10-16T03:19:00.000-07:00</published><updated>2008-10-16T03:20:48.965-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java Interview Qns-1'/><title type='text'></title><content type='html'>&lt;strong&gt;&lt;strong&gt;JAVA INTERVIEW QUESTIONS and FAQs - Part 1 &lt;/strong&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;JAVA INTERVIEW QUESTIONS&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Question : When you declare a method as abstract method ? &lt;br /&gt;&lt;br /&gt;Answer : When i want child class to implement the behavior of the method.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Question : Can I call a abstract method from a non abstract method ? &lt;br /&gt;&lt;br /&gt;Answer : Yes, We can call a abstract method from a Non abstract method in a Java abstract class&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Question : What is the difference between an Abstract class and Interface in Java ? or can you explain when you use Abstract classes ? &lt;br /&gt;&lt;br /&gt;Answer : Abstract classes let you define some behaviors; they force your subclasses to provide others. These abstract classes will provide the basic funcationality of your applicatoin, child class which inherited this class will provide the funtionality of the abstract methods in abstract class. When base class calls this method, Java calls the method defined by the child class.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;An Interface can only declare constants and instance methods, but cannot implement default behavior.&lt;br /&gt;Interfaces provide a form of multiple inheritance. A class can extend only one other class.&lt;br /&gt;Interfaces are limited to public methods and constants with no implementation. Abstract classes can have a partial implementation, protected parts, static methods, etc.&lt;br /&gt;A Class may implement several interfaces. But in case of abstract class, a class may extend only one abstract class.&lt;br /&gt;Interfaces are slow as it requires extra indirection to find corresponding method in the actual class. Abstract classes are fast.&lt;br /&gt;Neither Abstract classes or Interface can be instantiated.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Question : What is user-defined exception in java ? &lt;br /&gt;&lt;br /&gt;Answer : User-defined expections are the exceptions defined by the application developer which are errors related to specific application. Application Developer can define the user defined exception by inherite the Exception class as shown below. Using this class we can throw new exceptions.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Java Example :&lt;br /&gt;&lt;br /&gt;public class noFundException extends Exception {&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Throw an exception using a throw statement:&lt;br /&gt;&lt;br /&gt;public class Fund {&lt;br /&gt;&lt;br /&gt;...&lt;br /&gt;public Object getFunds() throws noFundException {&lt;br /&gt;&lt;br /&gt;if (Empty()) throw new noFundException();&lt;br /&gt;...&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;User-defined exceptions should usually be checked.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Question : What is the difference between checked and Unchecked Exceptions in Java ? &lt;br /&gt;&lt;br /&gt;Answer : All predefined exceptions in Java are either a checked exception or an unchecked exception. Checked exceptions must be caught using try .. catch() block or we should throw the exception using throws clause. If you dont, compilation of program will fail.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Java Exception Hierarchy&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;+--------+&lt;br /&gt;Object&lt;br /&gt;+--------+&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;+-----------+&lt;br /&gt;Throwable&lt;br /&gt;+-----------+&lt;br /&gt;/ / +-------+ +-----------+&lt;br /&gt;Error Exception&lt;br /&gt;+-------+ +-----------+&lt;br /&gt;/ \ / \________/ \______/ +------------------+&lt;br /&gt;unchecked checked RuntimeException&lt;br /&gt;+------------------+&lt;br /&gt;/ \_________________/&lt;br /&gt;&lt;br /&gt;unchecked&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Question : Explain garbage collection ? &lt;br /&gt;&lt;br /&gt;Answer : Garbage collection is an important part of Java's security strategy. Garbage collection is also called automatic memory management as JVM automatically removes the unused variables/objects from the memory. The name "garbage collection" implies that objects that are no longer needed by the program are "garbage" and can be thrown away. A more accurate and up-to-date metaphor might be "memory recycling." When an object is no longer referenced by the program, the heap space it occupies must be recycled so that the space is available for subsequent new objects. The garbage collector must somehow determine which objects are no longer referenced by the program and make available the heap space occupied by such unreferenced objects. In the process of freeing unreferenced objects, the garbage collector must run any finalizers of objects being freed.&lt;br /&gt;&lt;br /&gt;In Java, it is good idea to explicitly assign null into a variable when no more in use.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-4829623591695369838?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/4829623591695369838/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=4829623591695369838' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/4829623591695369838'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/4829623591695369838'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/10/java-interview-questions-and-faqs-part.html' title=''/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-2591531178905142950</id><published>2008-10-16T03:17:00.000-07:00</published><updated>2008-10-16T03:18:36.042-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java Interview Qns-2'/><title type='text'></title><content type='html'>&lt;strong&gt;JAVA INTERVIEW QUESTIONS - Part 2 &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Question : Explain garbage collection ? &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Answer : Garbage collection is an important part of Java's security strategy. Garbage collection is also called automatic memory management as JVM automatically removes the unused variables/objects from the memory. The name "garbage collection" implies that objects that are no longer needed by the program are "garbage" and can be thrown away. A more accurate and up-to-date metaphor might be "memory recycling." When an object is no longer referenced by the program, the heap space it occupies must be recycled so that the space is available for subsequent new objects. The garbage collector must somehow determine which objects are no longer referenced by the program and make available the heap space occupied by such unreferenced objects. In the process of freeing unreferenced objects, the garbage collector must run any finalizers of objects being freed.&lt;br /&gt;&lt;br /&gt;In Java, it is good idea to explicitly assign null into a variable when no more in use.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Question : How you can force the garbage collection ? &lt;br /&gt;&lt;br /&gt;Answer : Garbage collection automatic process and can't be forced. We can call garbage collector in Java by calling System.gc() and Runtime.gc(), JVM tries to recycle the unused objects, but there is no guarantee when all the objects will garbage collected. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Question : What are the field/method access levels (specifiers) and class access levels ? &lt;br /&gt;&lt;br /&gt;Answer : Each field and method has an access level:&lt;br /&gt;private: accessible only in this class&lt;br /&gt;(package): accessible only in this package&lt;br /&gt;protected: accessible only in this package and in all subclasses of this class&lt;br /&gt;public: accessible everywhere this class is available&lt;br /&gt;Similarly, each class has one of two possible access levels:&lt;br /&gt;(package): class objects can only be declared and manipulated by code in this package&lt;br /&gt;public: class objects can be declared and manipulated by code in any package&lt;br /&gt;For both fields and classes, package access is the default, and is used when no access is specified&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Question : What are the static fields &amp; static Methods ? &lt;br /&gt;&lt;br /&gt;Answer : If a field or method defined as a static, there is only one copy for entire class, rather than one copy for each instance of class. static method cannot accecss non-static field or call non-static method&lt;br /&gt;&lt;br /&gt;Example Java Code&lt;br /&gt;&lt;br /&gt;static int counter = 0;&lt;br /&gt;&lt;br /&gt;A public static field or method can be accessed from outside the class using either the usual notation:&lt;br /&gt;&lt;br /&gt;Java-class-object.field-or-method-name&lt;br /&gt;&lt;br /&gt;or using the class name instead of the name of the class object:&lt;br /&gt;&lt;br /&gt;Java- class-name.field-or-method-name &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Question : What are the Final fields &amp; Final Methods ? &lt;br /&gt;&lt;br /&gt;Answer : Fields and methods can also be declared final. A final method cannot be overridden in a subclass. A final field is like a constant: once it has been given a value, it cannot be assigned to again.&lt;br /&gt;&lt;br /&gt;Java Code&lt;br /&gt;&lt;br /&gt;private static final int MAXATTEMPTS = 10;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-2591531178905142950?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/2591531178905142950/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=2591531178905142950' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/2591531178905142950'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/2591531178905142950'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/10/java-interview-questions-part-2.html' title=''/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-203116484965246332</id><published>2008-10-16T03:13:00.000-07:00</published><updated>2008-10-16T03:14:26.492-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java Interview Qns-3'/><title type='text'></title><content type='html'>&lt;strong&gt;JAVA INTERVIEW QUESTIONS - Part 3 &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Question : Describe the wrapper classes in Java ?  &lt;br /&gt;  &lt;br /&gt;Answer : Wrapper class is wrapper around a primitive data type. An instance of a wrapper class contains, or wraps, a primitive value of the corresponding type.&lt;br /&gt;&lt;br /&gt;Following table lists the primitive types and the corresponding wrapper classes:&lt;br /&gt;&lt;br /&gt;Primitive Wrapper  &lt;br /&gt;boolean java.lang.Boolean  &lt;br /&gt;byte java.lang.Byte  &lt;br /&gt;char java.lang.Character &lt;br /&gt;double java.lang.Double &lt;br /&gt;float java.lang.Float  &lt;br /&gt;int java.lang.Integer &lt;br /&gt;long java.lang.Long  &lt;br /&gt;short java.lang.Short &lt;br /&gt;void java.lang.Void  &lt;br /&gt;  &lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;Question : What are different types of inner classes ? &lt;br /&gt;  &lt;br /&gt;Answer : Inner classes nest within other classes. A normal class is a direct member of a package. Inner classes, which became available with Java 1.1, are four types &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Static member classes &lt;br /&gt;Member classes &lt;br /&gt;Local classes &lt;br /&gt;Anonymous classes &lt;br /&gt;Static member classes - a static member class is a static member of a class. Like any other static method, a static member class has access to all static methods of the parent, or top-level, class. &lt;br /&gt;&lt;br /&gt;Member Classes - a member class is also defined as a member of a class. Unlike the static variety, the member class is instance specific and has access to any and all methods and members, even the parent's this reference. &lt;br /&gt;&lt;br /&gt;Local Classes - Local Classes declared within a block of code and these classes are visible only within the block. &lt;br /&gt;&lt;br /&gt;Anonymous Classes - These type of classes does not have any name and its like a local class&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Java Anonymous Class Example&lt;br /&gt;&lt;br /&gt;public class SomeGUI extends JFrame&lt;br /&gt;{&lt;br /&gt;   ... button member declarations ...&lt;br /&gt;&lt;br /&gt;   protected void buildGUI()&lt;br /&gt;   {&lt;br /&gt;      button1 = new JButton();&lt;br /&gt;      button2 = new JButton();&lt;br /&gt;      ...&lt;br /&gt;&lt;br /&gt;      button1.addActionListener(&lt;br /&gt;         new java.awt.event.ActionListener()                               &lt;------ Anonymous Class&lt;br /&gt;         {&lt;br /&gt;            public void actionPerformed(java.awt.event.ActionEvent e)&lt;br /&gt;            {&lt;br /&gt;               // do something&lt;br /&gt;            }&lt;br /&gt;         }&lt;br /&gt;      );&lt;br /&gt;      &lt;br /&gt;           &lt;br /&gt;  &lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;Question : What are the uses of Serialization?  &lt;br /&gt;  &lt;br /&gt;Answer : In some types of applications you have to write the code to serialize objects, but in many cases serialization is performed behind the scenes by various server-side containers. &lt;br /&gt;&lt;br /&gt;These are some of the typical uses of serialization: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To persist data for future use. &lt;br /&gt;To send data to a remote computer using such client/server Java technologies as RMI or socket programming. &lt;br /&gt;To "flatten" an object into array of bytes in memory. &lt;br /&gt;To exchange data between applets and servlets. &lt;br /&gt;To store user session in Web applications. &lt;br /&gt;To activate/passivate enterprise java beans. &lt;br /&gt;To send objects between the servers in a cluster. &lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;Question : what is a collection ?  &lt;br /&gt;  &lt;br /&gt;Answer : Collection is a group of objects. java.util package provides important types of collections. There are two fundamental types of collections they are Collection and Map. Collection types hold a group of objects, Eg. Lists and Sets where as Map types hold group of objects as key, value pairs Eg. HashMap and Hashtable.   &lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;Question : For concatenation of strings, which method is good, StringBuffer or String ?  &lt;br /&gt;  &lt;br /&gt;Answer : StringBuffer is faster than String for concatenation.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-203116484965246332?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/203116484965246332/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=203116484965246332' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/203116484965246332'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/203116484965246332'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/10/java-interview-questions-part-3.html' title=''/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-7087457576363391670</id><published>2008-10-16T03:11:00.002-07:00</published><updated>2008-10-16T03:12:54.577-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java Interview Qns-4'/><title type='text'></title><content type='html'>&lt;strong&gt;JAVA INTERVIEW QUESTIONS - Part 4 &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Question : What is Runnable interface ? Are there any other ways to make a java program as multithred java program?  &lt;br /&gt;  &lt;br /&gt;Answer : There are two ways to create new kinds of threads:&lt;br /&gt;&lt;br /&gt;- Define a new class that extends the Thread class&lt;br /&gt;- Define a new class that implements the Runnable interface, and pass an object of that class to a Thread's constructor. &lt;br /&gt;- An advantage of the second approach is that the new class can be a subclass of any class, not just of the Thread class. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    Here is a very simple example just to illustrate how to use the second approach to creating threads: &lt;br /&gt;&lt;br /&gt;   class myThread implements Runnable {&lt;br /&gt;      public void run() {&lt;br /&gt;     System.out.println("I'm running!");&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public class tstRunnable {&lt;br /&gt;    public static void main(String[] args) {&lt;br /&gt;     myThread my1 = new myThread();&lt;br /&gt;     myThread my2 = new myThread();&lt;br /&gt;     new Thread(my1).start();&lt;br /&gt;     new Thread(my2).start();&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  The Runnable interface has only one method: &lt;br /&gt;public void run();&lt;br /&gt;Thus, every class (thread) implements the Runnable interface, has to provide logic for run() method  &lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;Question : How can i tell what state a thread is in ? &lt;br /&gt;  &lt;br /&gt;Answer : Prior to Java 5, isAlive() was commonly used to test a threads state. If isAlive() returned false the thread was either new or terminated but there was simply no way to differentiate between the two. &lt;br /&gt;&lt;br /&gt;Starting with the release of Tiger (Java 5) you can now get what state a thread is in by using the getState() method which returns an Enum of Thread.States. A thread can only be in one of the following states at a given point in time. &lt;br /&gt;&lt;br /&gt;NEW  A Fresh thread that has not yet started to execute. &lt;br /&gt;RUNNABLE A thread that is executing in the Java virtual machine. &lt;br /&gt;BLOCKED A thread that is blocked waiting for a monitor lock. &lt;br /&gt;WAITING A thread that is wating to be notified by another thread. &lt;br /&gt;TIMED_WAITING A thread that is wating to be notified by another thread for a specific amount of time &lt;br /&gt;TERMINATED A thread whos run method has ended. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The folowing code prints out all thread states. &lt;br /&gt;&lt;br /&gt;public class ThreadStates{&lt;br /&gt;public static void main(String[] args){&lt;br /&gt;  Thread t = new Thread();&lt;br /&gt;  Thread.State e = t.getState(); &lt;br /&gt;  Thread.State[] ts = e.values(); &lt;br /&gt;  for(int i = 0; i &lt; ts.length; i++){&lt;br /&gt;   System.out.println(ts[i]); &lt;br /&gt;  }   &lt;br /&gt;}&lt;br /&gt;}    &lt;br /&gt;  &lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;Question : What methods java providing for Thread communications ?  &lt;br /&gt;  &lt;br /&gt;Answer : Java provides three methods that threads can use to communicate with each other: wait, notify, and notifyAll. These methods are defined for all Objects (not just Threads). The idea is that a method called by a thread may need to wait for some condition to be satisfied by another thread; in that case, it can call the wait method, which causes its thread to wait until another thread calls notify or notifyAll.  &lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;Question : What is the difference between notify and notify All methods ?  &lt;br /&gt;  &lt;br /&gt;Answer : A call to notify causes at most one thread waiting on the same object to be notified (i.e., the object that calls notify must be the same as the object that called wait). A call to notifyAll causes all threads waiting on the same object to be notified. If more than one thread is waiting on that object, there is no way to control which of them is notified by a call to notify (so it is often better to use notifyAll than notify).   &lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;Question : What is synchronized keyword? In what situations you will Use it?  &lt;br /&gt;  &lt;br /&gt;Answer : Synchronization is the act of serializing access to critical sections of code. We will use this keyword when we expect multiple threads to access/modify the same data. To understand synchronization we need to look into thread execution manner.&lt;br /&gt;&lt;br /&gt;Threads may execute in a manner where their paths of execution are completely independent of each other. Neither thread depends upon the other for assistance. For example, one thread might execute a print job, while a second thread repaints a window. And then there are threads that require synchronization, the act of serializing access to critical sections of code, at various moments during their executions. For example, say that two threads need to send data packets over a single network connection. Each thread must be able to send its entire data packet before the other thread starts sending its data packet; otherwise, the data is scrambled. This scenario requires each thread to synchronize its access to the code that does the actual data-packet sending. &lt;br /&gt;&lt;br /&gt;If you feel a method is very critical for business that needs to be executed by only one thread at a time (to prevent data loss or corruption), then we need to use synchronized keyword. &lt;br /&gt;&lt;br /&gt;EXAMPLE &lt;br /&gt;&lt;br /&gt;Some real-world tasks are better modeled by a program that uses threads than by a normal, sequential program. For example, consider a bank whose accounts can be accessed and updated by any of a number of automatic teller machines (ATMs). Each ATM could be a separate thread, responding to deposit and withdrawal requests from different users simultaneously. Of course, it would be important to make sure that two users did not access the same account simultaneously. This is done in Java using synchronization, which can be applied to individual methods, or to sequences of statements. &lt;br /&gt;&lt;br /&gt;One or more methods of a class can be declared to be synchronized. When a thread calls an object's synchronized method, the whole object is locked. This means that if another thread tries to call any synchronized method of the same object, the call will block until the lock is released (which happens when the original call finishes). In general, if the value of a field of an object can be changed, then all methods that read or write that field should be synchronized to prevent two threads from trying to write the field at the same time, and to prevent one thread from reading the field while another thread is in the process of writing it. &lt;br /&gt;&lt;br /&gt;Here is an example of a BankAccount class that uses synchronized methods to ensure that deposits and withdrawals cannot be performed simultaneously, and to ensure that the account balance cannot be read while either a deposit or a withdrawal is in progress. (To keep the example simple, no check is done to ensure that a withdrawal does not lead to a negative balance.) &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public class BankAccount {&lt;br /&gt;    private double balance;&lt;br /&gt;&lt;br /&gt;    // constructor: set balance to given amount&lt;br /&gt;    public BankAccount( double initialDeposit ) {&lt;br /&gt;        balance = initialDeposit;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public synchronized double Balance( ) {&lt;br /&gt;        return balance;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public synchronized void Deposit( double deposit ) {&lt;br /&gt;        balance += deposit;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public synchronized void Withdraw( double withdrawal ) {&lt;br /&gt;        balance -= withdrawal;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Note: that the BankAccount's constructor is not declared to be synchronized. That is because it can only be executed when the object is being created, and no other method can be called until that creation is finished. &lt;br /&gt;&lt;br /&gt;There are cases where we need to synchronize a group of statements, we can do that using synchrozed statement. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Java Code Example&lt;br /&gt;&lt;br /&gt;synchronized ( B ) {&lt;br /&gt;    if ( D &gt; B.Balance() ) {&lt;br /&gt;        ReportInsuffucientFunds();&lt;br /&gt;    }&lt;br /&gt;    else {&lt;br /&gt;        B.Withdraw( D );&lt;br /&gt;    }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-7087457576363391670?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/7087457576363391670/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=7087457576363391670' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/7087457576363391670'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/7087457576363391670'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/10/java-interview-questions-part-4.html' title=''/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-8386399724085149640</id><published>2008-10-16T03:11:00.001-07:00</published><updated>2008-10-16T03:11:52.315-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java Interview Qns-5'/><title type='text'></title><content type='html'>JAVA INTERVIEW QUESTIONS - Part 5 &lt;br /&gt;&lt;br /&gt;Question : What is serialization ?  &lt;br /&gt;  &lt;br /&gt;Answer : Serialization is the process of writing complete state of java object into output stream, that stream can be file or byte array or stream associated with TCP/IP socket.   &lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;Question : What does the Serializable interface do ?  &lt;br /&gt;  &lt;br /&gt;Answer : Serializable is a tagging interface; it prescribes no methods. It serves to assign the Serializable data type to the tagged class and to identify the class as one which the developer has designed for persistence. ObjectOutputStream serializes only those objects which implement this interface.   &lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;Question : How do I serialize an object to a file ?  &lt;br /&gt;  &lt;br /&gt;Answer : To serialize an object into a stream perform the following actions: &lt;br /&gt;&lt;br /&gt;- Open one of the output streams, for exxample FileOutputStream &lt;br /&gt;- Chain it with the ObjectOutputStream &lt;&lt;br /&gt;- Call the method writeObject() providinng the instance of a Serializable object as an argument. &lt;br /&gt;- Close the streams &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    Java Code&lt;br /&gt;    ---------&lt;br /&gt;&lt;br /&gt;    try{&lt;br /&gt;                fOut= new FileOutputStream("c:\\emp.ser");&lt;br /&gt;        out = new ObjectOutputStream(fOut);&lt;br /&gt;        out.writeObject(employee);  //serializing &lt;br /&gt;        System.out.println("An employee is serialized into c:\\emp.ser");&lt;br /&gt;&lt;br /&gt;      }  catch(IOException e){&lt;br /&gt;           e.printStackTrace(); &lt;br /&gt;            } &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;Question : How do I deserilaize an Object?  &lt;br /&gt;  &lt;br /&gt;Answer : To deserialize an object, perform the following steps: &lt;br /&gt;&lt;br /&gt;- Open an input stream &lt;br /&gt;- Chain it with the ObjectInputStream - Call the method readObject() and cast the returned object to the class that is being deserialized. &lt;br /&gt;- Close the streams &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Java Code&lt;br /&gt;&lt;br /&gt;try{&lt;br /&gt;    fIn= new FileInputStream("c:\\emp.ser");&lt;br /&gt;     in = new ObjectInputStream(fIn);&lt;br /&gt;   &lt;br /&gt;    //de-serializing employee&lt;br /&gt;    Employee emp = (Employee) in.readObject();&lt;br /&gt;                     &lt;br /&gt;    System.out.println("Deserialized " + emp.fName + " " &lt;br /&gt;                 + emp.lName + " from emp.ser ");&lt;br /&gt;   }catch(IOException e){&lt;br /&gt;       e.printStackTrace(); &lt;br /&gt;   }catch(ClassNotFoundException e){&lt;br /&gt;        e.printStackTrace();  }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;           &lt;br /&gt;  &lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;Question : What is Externalizable Interface ? &lt;br /&gt;  &lt;br /&gt;Answer : Externalizable interface is a subclass of Serializable. Java provides Externalizable interface that gives you more control over what is being serialized and it can produce smaller object footprint. ( You can serialize whatever field values you want to serialize)&lt;br /&gt;&lt;br /&gt;This interface defines 2 methods: readExternal() and writeExternal() and you have to implement these methods in the class that will be serialized. In these methods you'll have to write code that reads/writes only the values of the attributes you are interested in. Programs that perform serialization and deserialization have to write and read these attributes in the same&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-8386399724085149640?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/8386399724085149640/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=8386399724085149640' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/8386399724085149640'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/8386399724085149640'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/10/java-interview-questions-part-5.html' title=''/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-8298009266058572935</id><published>2008-08-05T01:06:00.000-07:00</published><updated>2008-08-05T01:09:12.893-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java will replace C++ as the language of choice'/><title type='text'></title><content type='html'>&lt;span style="font-weight: bold; color: rgb(102, 0, 0);"&gt;Java will replace C++ as the language of choice&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I've been seeing this one a lot lately. Frequently the comment comes from a member of the original Java team. But other times it is voiced by someone whose fame and fortune is not tied directly to the belief that Java is the Second Coming. It is of course possible that everyone working in C++ today and all those who contemplate moving there will someday move all of their work to Java. But it's awfully unlikely.&lt;br /&gt;&lt;br /&gt;The question is a pretty silly one today. Java code is far slower than C++, it can't do most of the things C++ can do and its object model and architecture hasn't been tested on large projects. We need to assume that Java can be made fast enough for most applications and that it will be given interfaces to all those libraries we need. We also need to assume that Java's long startup time (the time it takes to resolve method and data member location) can be reduced or eliminated without losing the flexibility that it was intended to provide. We need to assume that Java's garbage collector won't introduce unreasonable overhead when the programs and their data space requirements grow. (Remember that the 640KB memory limit in DOS was based on the experience with CP/M. CP/M gave you 64KB of memory. Who could possibly need more than ten times that?)&lt;br /&gt;&lt;br /&gt;Even if Java were better than C++ at everything (a huge if), any claim to its replacing C++ ignores the inertia of the computer industry. Despite the success of C++, there are still more C developers in the world. The fact that PC-based development products include both C and C++ makes it difficult to know which language people use in what proportion. In the Unix world the answer is easier to see. And here C outsells C++ by a comfortable margin. This is in spite of the fact that C++ makes it easy to migrate existing C code with minimal modification in the code or in our development model. Java makes no such concession.&lt;br /&gt;&lt;br /&gt;Of course, all this ignores the fact that most of the programming world doesn't work in C or C++. There is still a lot of Fortran out there among all the people who care about the best possible performance. And there's more Cobol than anything.&lt;br /&gt;&lt;br /&gt;That the world is excited about Java is clear. That there is reason to be excited is clear as well. But I wouldn't start recycling those C++ books any time soon. Five years ago there was enormous hype about how C++ would change the world and usher in a new world for programmers. Ten years ago it was Lisp and Prolog and expert systems. Things have a way of not exactly turning out the way the press predicts. (Anybody remember how OS/2 was going to wipe Unix from the face of the planet?)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-8298009266058572935?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/8298009266058572935/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=8298009266058572935' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/8298009266058572935'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/8298009266058572935'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/08/java-will-replace-c-as-language-of.html' title=''/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-4367542768495535063</id><published>2008-08-05T01:02:00.000-07:00</published><updated>2008-08-05T01:05:11.862-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Netscape&apos;s JavaScript is related to Java'/><title type='text'></title><content type='html'>&lt;span style="font-weight: bold; color: rgb(102, 0, 0);"&gt;Netscape's JavaScript is related to Java&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;JavaScript and Java seem to have little in common other than their names. JavaScript is a scripting language that can be used within an HTML page. It is similar in concept (though clearly not in capabilities) to scripting languages like Perl and the shell languages of the Korn and Bourne shells. JavaScript commands appear as text within the HTML, as in this example from Netscape's site:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;function addChar(input, character)&lt;br /&gt;{&lt;br /&gt;   // auto-push the stack if the last value was computed&lt;br /&gt;   if(computed) {&lt;br /&gt;       pushStack(input.form)&lt;br /&gt;       computed = false&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   // make sure input.value is a string&lt;br /&gt;   if(input.value == null || input.value == "0")&lt;br /&gt;       input.value = character&lt;br /&gt;   else&lt;br /&gt;       input.value += character&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Java code does not appear as part of the HTML. Instead, the HTML contains a link to the compiled code module:&lt;br /&gt;&lt;br /&gt;&lt;applet code="Converter" height="160" width="275"&gt;&lt;/applet&gt;&lt;br /&gt;&lt;br /&gt;The syntax of Java and JavaScript are different as well. Java is more C++-like, where JavaScript looks more like ksh. (Notice the function keyword and the lack of semicolons at the end of each JavaScript statement.) It is even more class-oriented than C++: every Java function must be a method of some class. There are no global variables or functions in Java.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public class Clock extends java.applet.Applet implements Runnable {&lt;br /&gt;&lt;br /&gt;   Thread clockThread;&lt;br /&gt;&lt;br /&gt;   public void start() {&lt;br /&gt;       if (clockThread == null) {&lt;br /&gt;           clockThread = new Thread(this, "Clock");&lt;br /&gt;           clockThread.start();&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;It's possible that Netscape took a long, hard look at Java as they began work on LiveScript, which became JavaScript. But from a programmer's perspective, Java and JavaScript are about as similar as C and the C Shell.&lt;br /&gt;&lt;br /&gt;Here's the square root example as embedded JavaScript. You'll need Netscape 2.0 or later to see it:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;sqrt(1) = 1&lt;br /&gt;sqrt(2) = 1.4142135623730951&lt;br /&gt;sqrt(3) = 1.7320508075688772&lt;br /&gt;sqrt(4) = 2&lt;br /&gt;sqrt(5) = 2.23606797749979&lt;br /&gt;sqrt(6) = 2.449489742783178&lt;br /&gt;sqrt(7) = 2.6457513110645907&lt;br /&gt;sqrt(8) = 2.8284271247461903&lt;br /&gt;sqrt(9) = 3&lt;br /&gt;sqrt(10) = 3.1622776601683795&lt;br /&gt;&lt;br /&gt;View the document source to see the JavaScript code that built this table.&lt;br /&gt;&lt;br /&gt;Here's an example that uses JavaScript to access one of several search engines. There's a hidden form for each search. The form on the page invokes a JavaScript function which sets up the appropriate hidden form and submits the request. This technique will work with search engines that expect Get or Post requests:&lt;br /&gt;&lt;br /&gt;To do the same task in Java would require a lot more code. A Java applet would have to set up the user interface, as well as format and submit the various types of requests.&lt;br /&gt;&lt;br /&gt;In general, JavaScript is preferable when you want to manipulate the contents or behavior of an HTML page in simple ways. More dynamic or sophisticated behavior is better done within Java applets.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-4367542768495535063?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/4367542768495535063/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=4367542768495535063' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/4367542768495535063'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/4367542768495535063'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/08/netscapes-javascript-is-related-to-java.html' title=''/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-8244445413442815600</id><published>2008-08-05T00:53:00.001-07:00</published><updated>2008-08-05T00:58:52.134-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java in a browser eliminates the need for CGI scripts and programs'/><title type='text'></title><content type='html'>&lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;Java in a browser eliminates the need for CGI scripts and programs&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Java applets will replace some uses of the Common Gateway Interface. Prior to Java, the only way to create a web page whose contents are not static was through CGI scripts or programs running on the web server. In some cases, this server-side code can be replaced conveniently by Java applets running in the browser. In many situations, however, browser-side Java can't be used in place of CGI. The reasons may involve security (do we want password validation code running in the interpretive Java environment, where a clever user could disassemble them?) or performance constraints that Java's interpretive environment can't satisfy.&lt;br /&gt;&lt;br /&gt;In a lot of cases, Java will let us do things that CGI supported badly if at all. Client pull and server push are brute force, high overhead techniques for creating interactive pages. By eliminating the need to communicate with a server, we can create truly interactive pages. An example is this clock applet, which tells me that I have owned the disordered.org domain for an unknown number of  days (an unknown number of  weeks or an unknown number of  years). These three instances of a particular applet class share a thread, which updates their display every eight seconds. A CGI-based equivalent would require communication with the server on every update.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In the short term, we may have to use CGI mechanisms simply because Java doesn't give us access to the resources we need. To write a web browser-based database query application, we would set up a form to capture the input and ship it off to a CGI script on the server. This server-side program would validate the data, run a query against the database and generate a new HTML page with the result. A Java applet could be used to replace server-side data validation, thereby improving user response in cases where the input is invalid. (No wait for the browser to communicate with the server and the server to send the error back.) If we have a Java class interface to the database (and our concerns about security don't keep us from using it), we could implement the query and display in Java as well and eliminate the server-side code.&lt;br /&gt;&lt;br /&gt;This discussion ignores two other points: that JavaScript will sometimes be a preferable to Java for browser-side programming; and there are now opportunities to invoke server-side Java code in the form of servlets. Java on the server has many of the same advantages and disadvantages over other server-side languages that Java has as an application language. A large advantage of Java servlets is that it saves the process creation overhead inherent in CGI, particularly in situations where there will be multiple interactions between browser and server to satisfy a request; there are disadvantages as well in the increased complexity of the debugging environment for such code.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-8244445413442815600?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/8244445413442815600/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=8244445413442815600' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/8244445413442815600'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/8244445413442815600'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/08/java-in-browser-eliminates-need-for-cgi.html' title=''/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-1338687710284453326</id><published>2008-08-05T00:50:00.000-07:00</published><updated>2008-08-05T00:53:04.761-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java = Basic'/><title type='text'></title><content type='html'>&lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;Java is interpreted; Basic is interpreted; Java = Basic&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Although Java does use an interpreter, it actually has more in common with fully compiled languages like C and C++ than it does with fully interpreted languages like Basic or APL. A fully interpreted language has to have very simple syntax, so that code can be parsed very quickly. (The source must be parsed every time the application is loaded.) The tradeoff is that such code becomes harder to understand and maintain as projects get larger and more complex.&lt;br /&gt;&lt;br /&gt;Because Java is compiled, speed of compilation is less important than the quality and maintainability of the code. Its structure and object orientation make it suitable for large, sophisticated projects. It supports features that would be prohibitively expensive (in time, memory or both) in a fully interpretive language.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-1338687710284453326?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/1338687710284453326/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=1338687710284453326' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/1338687710284453326'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/1338687710284453326'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/08/java-is-interpreted-basic-is.html' title=''/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-6904491996253820644</id><published>2008-08-05T00:47:00.000-07:00</published><updated>2008-08-05T00:50:30.747-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java&apos;s performance problems are temporary'/><title type='text'></title><content type='html'>&lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;Java's performance problems are temporary; it'll soon be as fast as C++&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Right now Java is slow: slow to load, slow to start and slow to execute. Load time can be attributed in part to Java's insistence on storing each class in a separate file and using a separate HTTP request to retrieve it. Changing to an archive that stores a bunch of classes in a single file should help quite a bit. Start time is related to load time (classes are loaded the first time they're invoked, not at startup), but also includes late binding time. In essence, every time we run a Java applet we're paying a startup penalty so the developer doesn't have to do a link step. Since the Java classes don't change all that often, doing the link and placing the linked classes in an archive is generally preferable.&lt;br /&gt;&lt;br /&gt;This leaves execution performance as the biggest problem. And a problem it is, with Java code taking an average of twenty times longer than native C++ code. Of course, an average tells you nothing about how a specific program will behave: some Java applets run nearly as fast as C++ (likely because most of their work takes place in native code run time libraries), while others run more like fifty times slower.&lt;br /&gt;&lt;br /&gt;The best solution to this difference in performance is to translate Java source or byte code into native code. Most platforms have native code translators either already available or under development. Native translation can make a huge difference in performance for Java applications; when applied to applets in the form of just-in-time translators they provide similar gains at the expense of a small increase in startup overhead. Suddenly Java that runs twenty times as long as C++ can get a lot closer.&lt;br /&gt;&lt;br /&gt;So how close can Java get? Will it ever reach the point where it can replace other languages for performance-critical tasks? Does it make sense to write compute-intensive codes in Java and design the Java run time to take advantage of multiprocessor architectures?&lt;br /&gt;&lt;br /&gt;For a lot of reasons, Java is likely to always be slower than C++ and Fortran for the typical application. (A range of 50% to 300% slower than C++ has been suggested as the practical limit of Java performance improvements.) Some of these reasons are:&lt;br /&gt;&lt;br /&gt;Reliance on pointers for objects: Every Java object access means a pointer dereference; C++ programmers have the option of either linking objects with pointers or placing one object inside the other, thereby eliminating a level of indirection.&lt;br /&gt;Reliance on heap storage for objects: While basic types (int, float, etc.) can reside on the stack, objects in Java can only be allocated on the heap. This means more work for the memory manager and the garbage collector. Stack-based objects are much faster to reclaim, giving another advantage to C++.&lt;br /&gt;&lt;br /&gt;Garbage collection: While garbage collectors have their merits (they make programming a lot easier, they are a general solution to the memory reclamation problem. And for many application there is a specific solution to memory allocation and reclamation that will outperform the general one. Where performance is critical, the programmer can probably do a better job of handling this task than even the most cleverly written garbage collector (which the GC in today's Java most definitely is not).&lt;br /&gt;Run time method selection: C++ gives the programmer the choice of using virtual or nonvirtual methods. Nonvirtual methods are implemented at functions, while virtual methods require an extra level of indirection through a method table. All Java methods are virtual, which means more overhead on every method invocation. This does make life a lot easier for the programmer, who doesn't have to worry about which methods are resolved when. But there is a small price to pay.&lt;br /&gt;&lt;br /&gt;Insistence on object orientation: Although arguably better from a design, development and maintenance standpoint, object oriented programs tend to be written as a large number of small procedures. This means more frequent method invocations, which can mean slower code. C++ can be written in a more procedural fashion. In addition, C++ programmers can use inline declarations to eliminate function calling overhead. Java does not provide such programmer control.&lt;br /&gt;&lt;br /&gt;Thread-safety: Java was designed as a multithreaded language. Thread-aware languages need thread-safe libraries, in which each procedure allows for the possibility that it will be invoked simultaneously from multiple threads. To avoid problems should this happen, the procedure must set up access locks around critical sections of code. This extra work makes thread-safe libraries slower than their unsafe equivalents, which is why most thread-safe C and C++ libraries are also supplied in unsafe versions. Since Java's run time libraries are of necessity thread-safe, they are another source of overhead in comparison to C++.&lt;br /&gt;&lt;br /&gt;JIT translation has to be fast: Most compilers have optimization modules that perform highly sophisticated analysis on the code they generate to make it more efficient. One problem with optimization is that it increases compilation time, sometimes by quite a lot. But for performance critical applications that take a long time to run or are run regularly, the extra compilation time is more than compensated by the improved run time performance. Now apply this analysis to Java applets and just-in-time translation: instead of incurring the overhead once at compilation time, we would see it every time the byte code applet loads and is converted to native code. Clearly we don't want to wait any longer than necessary for our applet to start. This places severe limits on the kinds of optimizations that Java JIT compilers can do. Note that this constraint does not apply to Java applications, which can be compiled to native code just like C++ programs and can have a similar degree of optimization applied to them.&lt;br /&gt;&lt;br /&gt;Java doesn't need to be as fast as C++; just fast enough: Here's where economics come into play: once Java is fast enough for most tasks, the emphasis vendors place on performance is likely to move onto some other area where they can offer differentiation. Improving performance takes a lot of work for each small gain. So once the perception of Java as a poor performer dissipates, the marketing advantage of improving performance does the same. It's is much like the situation with C++ compilers: although C++ has features like variable references that would permit it to run faster than the equivalent C using pointers, compilers don't take advantage of that opportunity to produce faster code. In at least this regard, Marketing and customer demand drive technology.&lt;br /&gt;&lt;br /&gt;The upshot of all this is that Java will get a lot faster, but that there are likely limits on its performance. Java won't be as fast as C++; and C++ won't be as fast as Fortran. There will still likely be a need for at least a few different languages for different requirements.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-6904491996253820644?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/6904491996253820644/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=6904491996253820644' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/6904491996253820644'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/6904491996253820644'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/08/javas-performance-problems-are.html' title=''/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-3083767338599913014</id><published>2008-08-05T00:35:00.000-07:00</published><updated>2008-08-05T00:42:06.741-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java is suitable for building large applications'/><title type='text'></title><content type='html'>&lt;span style="font-weight: bold; color: rgb(102, 0, 0);"&gt;Java is suitable for building large applications&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;For this point, we need to distinguish between Java the programming language (the description of syntax and semantics) and Java as it is implemented today. As a language, Java may be perfectly suitable for big projects. Its object orientation supports integration of large numbers of object classes. By eliminating explicit pointers, it allows programmers to write more maintainable code. So Java as a language is likely to be a better choice than C and probably better than C++ for large applications. Of course, we won't know until someone actually tries it! We are now seeing descriptions of a few large Java development projects, most of which seem sketchy or self-serving enough to make one want to wait for further documentation before accepting their claims.&lt;br /&gt;&lt;br /&gt;But while the Java language may be appropriate for big programs, Java as it is implemented in web browsers is not. With a fully compiled language like C, all of the compiled code is combined into an executable program as part of a link process. References to symbols in one module are resolved to their definitions in another.&lt;br /&gt;&lt;br /&gt;Java may also turn out to be unsuitable for big applications, rather than just applets. Part of the problem is likely in the way Java deals with memory; none of the Java environments handle large memory spaces at all well. (A speaker at the 1997 Java Internet Business Expo made an interesting comment on his attempts to benchmark Java: that in taking his C++ benchmarks to Java he had to reduce the data size by a factor of ten before any of the Java environments could run the programs to completion.)&lt;br /&gt;&lt;br /&gt;But there's another potential problem that is inherent in the dynamic rapid prototyping style of development Java and its advocates encourage. Good prototypes tend to become very bad applications. As we learned (or at least should have learned) from our brush with Lisp and Expert Systems in the 80's, there's a world of difference between prototyping an application and producing a piece of production quality code. It's far more than a matter of fixing bugs and smoothing out the rough edges. The very process of designing as we code leads to applications that don't meet the requirements of stability, reliability, maintainability and extensibility we demand of professional software.&lt;br /&gt;&lt;br /&gt;Java resolves all symbols when an applet is loaded into the browser. Each class mentioned in the applet class is loaded to the browser and all the symbolic references are resolved. Inheritance relationships among classes are also resolved at this time; where C++ decides the location of each class member at compile time, Java defers this decision until you attempt to load and run the class.&lt;br /&gt;&lt;br /&gt;The upshot of all this is that the equivalent of program linking occurs when you run the code in a class. The larger the class, the larger the number of classes and the more complex the inheritance tree, the longer all this will take.&lt;br /&gt;&lt;br /&gt;In addition to dynamic linking, Java performs one other important task before it can begin running a class: validating the code to prevent it from doing anything dangerous. This requires a scan of all of the loaded code to look for funny operations and attempts to break out of the restrictions placed on untrusted applets. Again, the more code you have the longer it will take to process the code before it can begin to run.&lt;br /&gt;&lt;br /&gt;Another concern with using Java for large applications is its reliance on stop-and-copy garbage collection. Whenever the application begins running low on memory, everything stops while the GC determines what objects are available for reclamation. Objects still in use are copied to a new area of memory to allow a large contiguous area of free space. Once the GC finishes, the program is free to continue execution.&lt;br /&gt;&lt;br /&gt;Right now garbage collection is quick, taking perhaps one or two tenths of a second. But imagine what happens when the size of the Java code and its storage requirements increase by a factor of ten or one hundred. Suddenly we will see our program stop for seconds or even minutes while the garbage collector goes about its work. To solve this problem (as Lisp and Smalltalk systems have had to do) will require a much more sophisticated approach to garbage collection, using a generational scheme or a reference counting model. Either technique will add complexity and overhead to the Java run time environment.&lt;br /&gt;&lt;br /&gt;Note that the first commercial Java applets don't use Java for everything. Applix's Java-based spreadsheet, for example, uses Java for the user interface. All the real processing, including loading and saving spreadsheets, is done in CGI code on the server. This is probably the best model for using Java in sophisticated applications. Once there are fully compiled Java implementations, of course, all the rules change.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-3083767338599913014?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/3083767338599913014/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=3083767338599913014' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/3083767338599913014'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/3083767338599913014'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/08/java-is-suitable-for-building-large.html' title=''/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-8029846960559230400</id><published>2008-08-05T00:28:00.000-07:00</published><updated>2008-08-05T00:35:13.571-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java can be extended to do anything the machine'/><title type='text'></title><content type='html'>&lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;Java can be extended to do anything the machine can do&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In theory a Java applet can do anything: manipulate 3D VRML models, play movies, make sounds, you name it. In practice it's a lot more limited. We've already seen one important limitation: an applet has control of its region of the page but no ability to operate elsewhere on the page. But here's a more serious one: an applet can do only what the run time environment allows. Today that's limited to some low level graphics, user interfaces (buttons, menus, text fields and the like), reading and writing files (under strict security guidelines), playing a sound file and some network capabilities.&lt;br /&gt;&lt;br /&gt;What's missing? There is no way today to control a VRML model. And what if we want to do more to a sound file than just play it? What if we want to change the volume? Or do a fade in? Or add a reverb? None of these effects exist today in Java's official bag of tricks. (Some are available through undocumented classes that Sun ships with the JDK. Anything undocumented is risky, since there's no support, no guarantee of compatible behavior across platforms and no guarantee that these interfaces won't change. Caveat Emptor.) Anything that Java doesn't support would need to be written in a fully compiled language like C and then made available to the Java run time environment.&lt;br /&gt;&lt;br /&gt;And therein lies the real limitation. To do more than Java can do today requires that we do two things: write new libraries that can be used by the Java interpreter; and then make each of those libraries available on every single system that might try to use these new capabilities. An applet is only usable if the capabilities on which it depends are available wherever we want to run them. Because although we can download applets at the moment we want to run them, we can't do the same with the underlying libraries. Java's built-in security makes downloading an applet low in risk; the same can't be said for arbitrary code libraries which do the low level work.&lt;br /&gt;&lt;br /&gt;So Java is limited by the pervasiveness of support libraries. We need general 2D and 3D graphics, sound and video manipulation and other multimedia capabilities on every system with a Java-enabled browser. Then we won't be quite so limited. This is the plan for SGI's Cosmo 3D and Sun's Java Media, cross-platform libraries that will extend Java into 3D graphics, sound, video and animation.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-8029846960559230400?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/8029846960559230400/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=8029846960559230400' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/8029846960559230400'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/8029846960559230400'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/08/java-can-be-extended-to-do-anything.html' title=''/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-3184906200977662641</id><published>2008-08-05T00:23:00.000-07:00</published><updated>2008-08-05T00:27:03.338-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java solves Cross-Platform application Dev.'/><title type='text'></title><content type='html'>&lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;&lt;br /&gt;Java solves the problem of cross-platform application development&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Thanks to its portable byte code, the same Java applet will run anywhere the Java Virtual Machine runs. This leads to the logical conclusion that Java is the perfect language for writing applications that need to run across multiple platforms, especially the kind of lightweight enterprise-level applications that IS departments spend much of their time developing.&lt;br /&gt;&lt;br /&gt;Java, coupled with a database connectivity package like JDBC, is a good language for things like database front ends and other lightweight applications. It's far more cross-platform than current solutions like PowerBuilder, Delphi or Visual Basic, easier to manage (no installation; just point at a web page) and potentially much higher performance than all but Delphi (which is based on compiled Pascal). But it doesn't solve all the problems of cross-platform development, as a few days reading any of the the Java newsgroups will show. There are three major limitations to Java's ability to do clean cross-platform execution:&lt;br /&gt;&lt;br /&gt;Java applets don't inherit the browser properties specified by the user. You can do all you want to make the fonts in an applet match those of the surrounding page. But a viewer on a different kind of system with different defaults will still get a font appearance or size difference between text rendered by the applet and the HTML-specified text that surrounds it. The text of the applet on page two was designed to match the rest of the text on the page. On my browser it does; what about on yours?&lt;br /&gt;&lt;br /&gt;Java's window toolkit relies on the native window system to implement all its UI elements: on Unix it uses X/Motif, on the Macintosh it uses the Toolbox, on Windows it uses Windows and so on. Since each window system has its own idea about the size and shape of its components, they are likely to look a little different (a major inconvenience to the documentation people) and to take up different amounts of space. &lt;br /&gt;&lt;br /&gt;Which means that the HEIGHT= and WIDTH= specifications in the&lt;br /&gt;&lt;br /&gt;-applet- tag need to allow for the largest size required across all platforms, not the size necessary on the development platform. A more serious issue concerns incompatibilities users have found in the behavior on different platforms. Because of the way AWT relies on the underlying window system, programmers have had to make minor code changes (modify the order of API calls; insert an additional call) to make things work on every platform.&lt;br /&gt;&lt;br /&gt;For a Java applet to be cross-platform, everything it needs must also be cross-platform. I can write database clients in Java thanks to Sun's JDBC package. But JDBC doesn't do me any good if it hasn't been ported to every platform I need to support. And even if it's available, I need to install it on every system that might need my applet. So my cross-platform environment is really limited by the interfaces accessible to the Java environment in my browser. &lt;br /&gt;&lt;br /&gt;This point is discussed elsewhere.&lt;br /&gt;The best cross-platform development and delivery environment I have ever seen was the ParcPlace Smalltalk environment. Every implementation on every supported platform was identical from the programmer's and the program's perspective. Every program behaved identically and looked identical no matter where it ran. &lt;br /&gt;&lt;br /&gt;Of course, there was a cost associated with this uniformity: although every Smalltalk program looked like every other Smalltalk program, they didn't look at all like any other application running on the same machine. Smalltalk programs on the Macintosh looked like Smalltalk programs; they didn't look like Macintosh programs.&lt;br /&gt;&lt;br /&gt;Until and unless we reach a point where every system looks and behaves like every other (a point Microsoft appears to be praying for with great devotion), it will not be possible to write applications that look and feel like others on our development platform and on every other platform on which they run. Not, at least, without some serious work on the part of the developer.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-3184906200977662641?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/3184906200977662641/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=3184906200977662641' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/3184906200977662641'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/3184906200977662641'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/08/java-solves-problem-of-cross-platform.html' title=''/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-5478655187447163963</id><published>2008-08-05T00:20:00.000-07:00</published><updated>2008-08-05T00:22:12.208-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java vs C'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'></title><content type='html'>&lt;span style="font-weight: bold; color: rgb(102, 0, 0);"&gt;Java code is portable, where C and C++ are not&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Java source code is a little more portable than C-based languages. In C and C++, each implementation decides the precision and storage requirements for basic data types (short, int, float, double, etc.). This is a major source of porting problems when moving from one kind of system to another, since changes in numeric precision can affect calculations and assumptions about the size of structs can be violated. Java defines the size of basic types for all implementations; an int on one system is the same size (and can represent the same range of values) as on every other system. It does not permit the use of arbitrary pointer arithmetic, so assumptions about struct packing and sizes can't lead to non-portable coding practices.&lt;br /&gt;&lt;br /&gt;(One reader of this page points out that while storage requirements for float and double are defined by Java, precision during calculation is not. This means that a program that uses floating point arithmetic can produce different answers on different systems, with the degree of difference increasing with the number of calculations a particular value goes through. This is true of floating point in general, not just in Java, and explains why the Cobol world continues to rely on bizarre data types like COMPUTATIONAL-3 (binary coded decimal) for calculations where accuracy matters.)&lt;br /&gt;&lt;br /&gt;Where Java is more portable than other languages is in its object code. Most language compilers generate the native code for the target computer, which then runs at the best speed of which the system is capable. Java compiles to an object code for a theoretical machine; the Java interpreter emulates that machine. This means that Java code compiled on one kind of computer will run on every other kind of computer with a Java interpreter. The tradeoff is in performance: the interpreter adds a significant level of overhead to the program.&lt;br /&gt;&lt;br /&gt;Note that this extra overhead can be reduced considerably by just-in-time compilation techniques. When the Java interpreter receives a chunk of code to execute, it could convert it from Java object code into the native code of the machine and then execute the real code. This adds some overhead during the translation process but permits the resulting code to run at close to native speeds. Java is still likely to be slower than C or C++, due to some features of the language intended to ease development. It's hard to know how close well-optimized native Java code can get to the best C or C++. But a range of 50% to 200% slower (1.5x to 3x the execution time) seems a reasonable guess.&lt;br /&gt;&lt;br /&gt;But it's important that an application written in Java is still not 100% portable. An application written on one kind of system will still need to be tested on every platform before one can say with certainty that there are no problems. Even if the Java code itself was 100% portable (and it isn't; just compare the peculiarities of the Sun implementation of threads with Netscape's), every time the code goes out to native runtime code it encounters incompatibilities: the window toolkit and networking support are riddled with such problems.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-5478655187447163963?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/5478655187447163963/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=5478655187447163963' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/5478655187447163963'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/5478655187447163963'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/08/java-code-is-portable-where-c-and-c-are.html' title=''/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-7980236000895165228</id><published>2008-08-05T00:15:00.000-07:00</published><updated>2008-08-05T00:17:39.916-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java easy unlike C'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'></title><content type='html'>&lt;span style="font-weight: bold; color: rgb(153, 0, 0);"&gt;&lt;br /&gt;Java is easy to learn and use, unlike C, C++ and other programming languages&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Make no mistake about it: Java is a programming language. If you find Pascal hard, you won't care for Java. Writing in Java may be different in degree from C or C++, but it is not different in kind.&lt;br /&gt;&lt;br /&gt;Is Java easy to learn? It may be somewhat easier than C or C++. Not because its syntax is any simpler, but more because there are fewer surprises. (Try explaining the difference between a C pointer and its array implementation some time. And C++ adds lots of its own peculiarities, like temporary variables that hang around long after the function that created them has terminated.)&lt;br /&gt;&lt;br /&gt;Is Java easier to use? Again the answer is a firm maybe, possibly, perhaps. It eliminates explicit pointer dereferences and memory allocation/reclamation. These two features are the source of many of the hardest-to-find bugs C programmers have to deal with. And Java does add array bounds checking, so out-of-range subscripts are easy to find. It's too soon to tell whether Java is really easier or just seems that way because no one is writing anything truly complex with it.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-7980236000895165228?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/7980236000895165228/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=7980236000895165228' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/7980236000895165228'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/7980236000895165228'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/08/java-is-easy-to-learn-and-use-unlike-c.html' title=''/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-488492598062400439</id><published>2008-08-04T23:24:00.000-07:00</published><updated>2008-08-05T00:08:29.144-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java like HTML'/><title type='text'></title><content type='html'>&lt;br /&gt;&lt;h3 style="color: rgb(102, 0, 0);"&gt;&lt;a name="Java-1"&gt;Java is a language for writing web pages; it's like HTML and  VRML&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;Java isn't a page description language like HTML. It's a programming  language. Description languages specify content and placement; programming  languages describe a &lt;em&gt;process&lt;/em&gt; for generating a result. Where there is  generally a direct mapping between an HTML description of a document and the  result, the relationship between a Java program&lt;br /&gt;and its result is likely to be  more complex. It's a little like the difference between a list of square roots  of numbers from zero to 10 and a program to calculate the list.&lt;br /&gt;&lt;br /&gt;Here's an HTML table of square roots:&lt;/p&gt; &lt;dl&gt;&lt;dd&gt;sqrt(1) = 1  &lt;/dd&gt;&lt;dd&gt;sqrt(2) = 1.41421  &lt;/dd&gt;&lt;dd&gt;sqrt(3) = 1.73205  &lt;/dd&gt;&lt;dd&gt;sqrt(4) = 2  &lt;/dd&gt;&lt;dd&gt;sqrt(5) = 2.23607  &lt;/dd&gt;&lt;dd&gt;sqrt(6) = 2.44949  &lt;/dd&gt;&lt;dd&gt;sqrt(7) = 2.64575  &lt;/dd&gt;&lt;dd&gt;sqrt(8) = 2.82843  &lt;/dd&gt;&lt;dd&gt;sqrt(9) = 3  &lt;/dd&gt;&lt;dd&gt;sqrt(10) = 3.16228&lt;/dd&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;And here's the result of a Java applet:&lt;br /&gt;&lt;br /&gt;import java.awt.*;&lt;br /&gt;&lt;br /&gt;public class SqrtList extends java.applet.Applet {&lt;br /&gt;public void paint(Graphics g) {&lt;br /&gt;	g.setFont(new Font("TimesRoman", Font.PLAIN, 12));&lt;br /&gt;	for (float i = 1; i &lt;= 10; i++) 	    g.drawString("sqrt(" + i + ") = " + Math.sqrt(i), 0, 		(int)i * 16 - 3);   } }         &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;textarea rows="14" cols="30"&gt;&lt;br /&gt;&lt;br /&gt;This is the code that specifies the Java code to run:&lt;br /&gt;&lt;br /&gt;&lt;applet codebase="java" code="SqrtList" width="160" height="162"&gt; &lt;br /&gt;&lt;br /&gt;You need a Java-aware browser&lt;br /&gt;&lt;br /&gt;&lt;/applet&gt;&lt;br /&gt;&lt;br /&gt;The &lt;applet&gt; tag specifies the class to load (the CODE= field), URL information (the CODEBASE= field) and the size of the region the applet will own. Notice that Java doesn't exactly integrate with the rest of the page. Within that region of the page Java is king: it decides background color and fonts and does all the mouse and keyboard handling. Contrast this behavior with the JavaScript example later in this document.&lt;br /&gt;&lt;br /&gt;Parameters to the applet are placed in &lt;param&gt; tags between the &lt;applet&gt; and &lt;/applet&gt; tags. Anything else between these tags is ignored. It's common to include some information here for display by browsers that don't know about Java, since they'll ignore the &lt;applet&gt; and &lt;param&gt; tags and display whatever else they find there.&lt;br /&gt;&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-488492598062400439?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/488492598062400439/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=488492598062400439' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/488492598062400439'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/488492598062400439'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/08/java-is-language-for-writing-web-pages.html' title=''/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-1744325712747640734</id><published>2008-06-18T08:22:00.000-07:00</published><updated>2008-06-30T00:38:14.290-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Introduction-spring'/><title type='text'>Spring Framework</title><content type='html'>&lt;div align="center"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;a href="http://javanetinfo.blogspot.com/"&gt;&lt;strong&gt;&lt;span style="font-size:130%;color:#000099;"&gt;Previous&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#660000;"&gt;Introduction:&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;The content of this document is not a detailed description on Spring or Hibernate. This document contains how we have used Spring and Hibernate in our project.&lt;br /&gt;&lt;br /&gt;I have shared most of the learning experiences I have gathered during execution of the project here.&lt;br /&gt;&lt;br /&gt;Those who have some prior knowledge on J2EE framework would be able to understand these. Our project got executed using JBoss-3.2 server and Hibernate as back end.&lt;br /&gt;&lt;br /&gt;We have developed our codes in Eclipse-3 platform using Spring framework. Finally the war file was deployed in Linux and it was platform independent.&lt;br /&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;strong&gt;&lt;span style="font-size:130%;color:#000099;"&gt;&lt;a href="http://javanetinfo.blogspot.com/"&gt;Next&lt;/a&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-1744325712747640734?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/1744325712747640734/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=1744325712747640734' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/1744325712747640734'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/1744325712747640734'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/06/spring-framework.html' title='Spring Framework'/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-445150604322134193</id><published>2008-03-31T23:36:00.000-07:00</published><updated>2008-03-31T23:41:19.844-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='STRUTS INTERVIEW-7'/><title type='text'>STRUTS INTERVIEW QUESTIONS</title><content type='html'>&lt;strong&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;&lt;span style="color: rgb(204, 102, 0);"&gt;Q.In struts  why we use jsp as presentation layer? can we use servlet as presentation  layer?&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;  &lt;p&gt;&lt;add&gt;&lt;strong&gt;&lt;/strong&gt;We can seperate the business logic from  presentation logic2.It facilitates to write the java code inside a html  environment if we use servlets then we need to write the html tags inside  out.write() number of times. it is not possible in all cases and it combines the  businesslogic and presentation logic which reduces security&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong style="color: rgb(204, 102, 0);"&gt;Q. Explain about token feature in  Struts?&lt;/strong&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/add&gt;&lt;/p&gt;  &lt;p&gt;&lt;add&gt;&lt;strong&gt;&lt;/strong&gt;&lt;b&gt;Use the Action Token methods to prevent  duplicate submits&lt;/b&gt;:&lt;br /&gt;&lt;/add&gt;&lt;/p&gt;   &lt;p&gt;There are methods built into the Struts action to generate one-use tokens. A  token is placed in the session when a form is populated and also into the HTML  form as a hidden property. When the form is returned, the token is validated. If  validation fails, then the form has already been submitted, and the user can be  apprised.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;textarea rows="5" cols="45"&gt;&lt;br /&gt;ul&gt;&lt;li&gt; saveToken(request)&lt;li&gt; on the return trip,&lt;li&gt; isTokenValid(request)&lt;li&gt; resetToken(request) &lt;/textarea&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong style="color: rgb(204, 102, 0);"&gt;&lt;/strong&gt;&lt;/p&gt;   &lt;p&gt;&lt;strong style="color: rgb(204, 102, 0);"&gt;Q.What is the difference between  ActionForm and DynaActionForm&lt;/strong&gt;&lt;strong&gt;?&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;# The DynaActionForm  bloats up the Struts config file with the xml based definition. This gets  annoying as the Struts Config file grow larger.&lt;/p&gt;&lt;p&gt;# The DynaActionForm is not  strongly typed as the ActionForm. This means there is no compile time checking  for the form fields. Detecting them at runtime is painful and makes you go  through redeployment.&lt;/p&gt;&lt;p&gt;# ActionForm can be cleanly organized in packages as  against the flat organization in the Struts Config file.&lt;/p&gt;&lt;p&gt;# ActionForm were  designed to act as a Firewall between HTTP and the Action classes, i.e. isolate  and encapsulate the HTTP request parameters from direct use in Actions. With  DynaActionForm, the property access is no different than using  request.getParameter( .. ).&lt;/p&gt;&lt;p&gt;# DynaActionForm construction at runtime requires a  lot of Java Reflection (Introspection) machinery that can be avoided.&lt;/p&gt;&lt;p&gt;# Time  savings from DynaActionForm is insignificant. It doesn t take long for today s  IDEs to generate getters and setters for the ActionForm attributes. (Let us say  that you made a silly typo in accessing the DynaActionForm properties in the  Action instance. It takes less time to generate the getters and setters in the  IDE than fixing your Action code and redeploying your web application) &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong style="color: rgb(204, 102, 0);"&gt;&lt;/strong&gt;&lt;/p&gt;   &lt;p&gt;&lt;strong style="color: rgb(204, 102, 0);"&gt;Q.Explain Struts navigation  flow?&lt;/strong&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;Struts Navigation flow.1) A request is made  from previously displayed view.2) The request reaches the ActionServlet which  acts as the controller .The ActionServlet Looksup the requested URI in an XML  file (Struts-Config.xml) and determines the name of the Action class that has to  perform the requested business logic.3)The Action Class performs its logic on  the Model Components associated with the Application.4) Once The Action has been  completed its processing it returns the control to the Action Servlet.As part of  its return the Action Class provides a key to determine where the results should  be forwarded for presentation.5)The request is complete when the Action Servlet  responds by forwarding the request to the view, and this view represents the  result of the action.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-445150604322134193?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/445150604322134193/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=445150604322134193' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/445150604322134193'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/445150604322134193'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/03/struts-interview-questions_7675.html' title='STRUTS INTERVIEW QUESTIONS'/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-8516466235311285382</id><published>2008-03-31T23:32:00.000-07:00</published><updated>2008-03-31T23:34:47.264-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='STRUTS INTERVIEW-6'/><title type='text'>STRUTS INTERVIEW QUESTIONS</title><content type='html'>&lt;strong style="color: rgb(204, 102, 0);"&gt;Q.What is Action Class. What are the methods in  Action class&lt;/strong&gt;? &lt;p&gt;&lt;add&gt;&lt;br /&gt;An Action is an adapter between the contents of an  incoming HTTP request and the corresponding business logic that should be  executed to process this request. The controller (RequestProcessor) will select  an appropriate Action for each request, create an instance (if necessary), and  call the execute method. Actions must be programmed in a thread-safe manner,  because the controller will share the same instance for multiple simultaneous  requests. This means you should design with the following items in mind:  Instance and static variables MUST NOT be used to store information related to  the state of a particular request. They MAY be used to share global resources  across requests for the same action.&lt;br /&gt;&lt;/add&gt;&lt;/p&gt; &lt;p&gt;&lt;add&gt;Access to other resources (JavaBeans,  session variables, etc.) MUST be synchronized if those resources require  protection. (Generally, however, resource classes should be designed to provide  their own protection where necessary. When an Action instance is first created,  the controller will call setServlet with a non-null argument to identify the  servlet instance to which this Action is attached. When the servlet is to be  shut down (or restarted), the setServlet method will be called with a null  argument, which can be used to clean up any allocated resources in use by this  Action.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(204, 102, 0);"&gt;&lt;strong&gt;Q.What is Action  Class? What are the methods in Action class?&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;/add&gt;&lt;/p&gt; &lt;p&gt;&lt;add&gt;An Action class  is some thing like an adapter between the contents of an incoming HTTP request  and the corresponding business logic that should be executed to process this  request. The controller (RequestProcessor) will select an appropriate Action for  each request, create an instance (if necessary), and call the execute method.  Struts Action class is a unit of logic. It is where a call to business function  is made. In short the Action class acts like a bridge between client side(user  action) and business operation(on server. Some of the impotant methods of Action  class are, execute()generateToken() resetToken() getServlet() &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong style="color: rgb(204, 102, 0);"&gt;Q.What is the use of  ActionForm class, Describe it's Life Cycle&lt;/strong&gt;?&lt;/add&gt;&lt;/p&gt; &lt;p&gt;&lt;add&gt;&lt;br /&gt;ActionForm class is used  to capture user-input data from an HTML form and transfer it to the Action  Class. ActionForm plays the role of Transport Vehicle between the presentation  Tire &amp;amp; Business Tier.Life Cycle :1. Request received by Controller2. Create  or recycle ActionForm3. Call reset()4. store ActionForm in proper scope5.  populate ActionForm from Request6. Validate the ActionForm7. If errors found  then forward back to input attribute page(configured in Action mapping in  struts-config.xml) with ActionForm in scope. If no errors found then call  execute() with the ActionForm.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;&lt;span style="color: rgb(204, 102, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/add&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-8516466235311285382?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/8516466235311285382/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=8516466235311285382' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/8516466235311285382'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/8516466235311285382'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/03/struts-interview-questions_4561.html' title='STRUTS INTERVIEW QUESTIONS'/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-1022125279116093983</id><published>2008-03-31T23:27:00.000-07:00</published><updated>2008-03-31T23:31:36.078-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='STRUTS INTERVIEW-5'/><title type='text'>STRUTS INTERVIEW QUESTIONS</title><content type='html'>&lt;p&gt;&lt;strong style="color: rgb(204, 102, 0);"&gt;Q.Does Struts provide support for  Validator &amp;amp; Tiles by default ?&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;NO.Struts does not provide  default support for Validator and Tiles.Additional plugins are required for the  purpose&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong style="color: rgb(204, 102, 0);"&gt;Q.&lt;/strong&gt;&lt;strong style="color: rgb(204, 102, 0);"&gt;Is there any way to put my custom name to LIB  folder which i am going to place in WEB-INF folder of struts &lt;/strong&gt;&lt;span style="color: rgb(204, 102, 0); font-weight: bold;"&gt;application?&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;No,not possible beacause web  servers are strictly denoting the directory structure and names .so that it will  recognise that lib is a directory having library files&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong style="color: rgb(204, 102, 0);"&gt;Q.Can i use bc4j with spring framework&lt;/strong&gt; &lt;br /&gt;no it is not possible&lt;br /&gt;&lt;br /&gt;&lt;strong style="color: rgb(204, 102, 0);"&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;strong style="color: rgb(204, 102, 0);"&gt;Q.In struts, if any changes are made to  before the request reaches to actionservlet, where you do the changes?&lt;/strong&gt; &lt;br /&gt;&lt;/p&gt; &lt;p&gt;In struts the first to recieve the request is Actionservlet. So, there is no  chance for you to make changes before&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(204, 102, 0);"&gt;&lt;strong&gt;Q.What are the drawbacks of  Struts&lt;/strong&gt;&lt;/span&gt;?&lt;/p&gt;&lt;p&gt;&lt;br /&gt;In struts , their is no facility of backward  flow.Suppose we are in page 1 and when we submit it calls action mapping  page2.Their may be lot of variable stored in session , which is available to  page2.Now we wish to go page1 from page 2, for this we have to call the action  mapping of page1. But struts flow is always in forward direction. So when we  call page 1, values stored in session never get reversed.So it reduces the  performance.To resolve this problem of struts, Their is a framework called Web  Flow Nevigation Manager(WFNM) of Sourgeforge.net.This framework can be  integrated with struts.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong style="color: rgb(204, 102, 0);"&gt;Q.How can we work struts on Eclipse? What is the  best plugin for this?&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong style="color: rgb(204, 102, 0);"&gt;&lt;/strong&gt;&lt;br /&gt;Ecclipse work bench provides &lt;add&gt;option to  any web project.building struts application becomes very easy with the GUI  provided and drag drop feature of struts-config file. The best plug-in available  is My-ecllipse .&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong style="color: rgb(204, 102, 0);"&gt;Q.What is the  difference between a normal servlet and action servlet?&lt;/strong&gt;&lt;br /&gt;&lt;/add&gt;&lt;/p&gt;&lt;p&gt;&lt;add&gt;Both a  normal servlet and action sevlet are same, which extend HttpServlet and  implement the servlet lifecycle methods..&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong style="color: rgb(204, 102, 0);"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/add&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-1022125279116093983?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/1022125279116093983/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=1022125279116093983' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/1022125279116093983'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/1022125279116093983'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/03/struts-interview-questions_3313.html' title='STRUTS INTERVIEW QUESTIONS'/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-2373600451537411543</id><published>2008-03-31T23:25:00.000-07:00</published><updated>2008-03-31T23:27:38.515-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='STRUTS INTERVIEW-4'/><title type='text'>STRUTS INTERVIEW QUESTIONS</title><content type='html'>&lt;strong style="color: rgb(204, 102, 0);"&gt;&lt;br /&gt;Q.In struts what happens if made any changes in  actionservlet?&lt;/strong&gt;&lt;br /&gt;    &lt;p&gt;The ActionServlet plays the role of controller wich  is responsible for handling the request and selecting the correct Application  Module and storing ApplicationConfig and MessageResource bundle in the request  object. If we modify the ActionServlet the Controller may or may not work what  happens that depends on your modification, You have not specify whether you want  to create your own custom ActionServlet by extending ActionServlet and  overriding the methods in it or what exactly you want to modify. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong style="color: rgb(204, 102, 0);"&gt;Q.What part of MVC does Struts  represent ?&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;    &lt;p&gt;&lt;strong style="color: rgb(204, 102, 0);"&gt;&lt;/strong&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;Struts is mainly famous for its Action  Controller - which is nothing but the CONTROLLER part of MVC Pattern. To add up,  Struts is the framework which started mainly using the MVC-2 Pattern where in  the Business logic is STRICTLY SEPARATED from the Presentation logic &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong style="color: rgb(204, 102, 0);"&gt;Q.What is  Struts?&lt;/strong&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;    &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;Struts is a java framework based on Model  2 architecture of JSP or popularly called Model-View-Controller architecture.It  provides a controller for this architecture.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong style="color: rgb(204, 102, 0);"&gt;Q.How you will handle errors and exceptions using  Struts?&lt;/strong&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;    &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;Struts exception handling can be done by  two ways:1. Declarative (using struts features via struts-config.xml) This  makes coding in the Action class very simpleSince the execute method declares  throws Exception we don't need a try-catch block.Struts saves the exception  using one of its global constants. You may use the field G lobals.EXCEPTION_KEY  to retrieve it from the request object.2. Programmatic (using the usual  try-catch exception handling in Action Class).&lt;/p&gt;    &lt;p&gt;&lt;br /&gt; &lt;/p&gt;    &lt;p&gt;&lt;textarea rows="15" cols="45"&gt;&lt;global-exceptions&gt;&lt;exceptiontype="hansen.playground.myexception2"key path="/error.jsp"&gt;&lt;/global-exceptions&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong style="color: rgb(204, 102, 0);"&gt;Q.What are the Important Components of  Struts?&lt;/strong&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;    &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;Struts Configuration File&lt;br /&gt;&lt;/p&gt;    &lt;p&gt;ActionServlet &lt;br /&gt;RequestProcessor&lt;br /&gt;ActionForm&lt;br /&gt;Action&lt;br /&gt;ActionFroward &lt;br /&gt;ActionMapping&lt;br /&gt;ActionErrors&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong style="color: rgb(204, 102, 0);"&gt;Q.How you will save the data across different  pages for a particular client request usingStruts&lt;/strong&gt;&lt;span style="font-weight: bold;"&gt; ?&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;    &lt;p&gt;Several ways. The  similar to the ways session tracking is enabled. Using cookies, URL-rewriting,  SSLSession, and possibilty threw in the database.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong style="color: rgb(204, 102, 0);"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-2373600451537411543?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/2373600451537411543/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=2373600451537411543' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/2373600451537411543'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/2373600451537411543'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/03/struts-interview-questions_792.html' title='STRUTS INTERVIEW QUESTIONS'/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-75355601539202874</id><published>2008-03-31T23:23:00.000-07:00</published><updated>2008-03-31T23:25:05.680-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='STRUTS INTERVIEW-3'/><title type='text'>STRUTS iNTERVIEW QUESTIONS</title><content type='html'>&lt;strong style="color: rgb(204, 102, 0);"&gt;Q.What is the difference  between ActionErrors and ActionMessages?&lt;/strong&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;There is  no differnece between these two classes.All the behavior of ActionErrors was  copied into ActionMessages and vice versa. This was done in the attempt to  clearly signal that these classes can be used to pass any kind of messages from  the controller to the view -- where as errors being only one kind of message.The  difference between saveErrors(...) and saveMessages(...) is simply the attribute  name under which the ActionMessages object is stored, providing two convenient  default locations for storing controller messages for use by the view. If you  look more closely at the html:errors and html:messages tags, you can actually  use them to get an ActionMessages object from any arbitrary attribute name in  any scope.&lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;br /&gt;&lt;strong style="color: rgb(204, 102, 0);"&gt;Q.What are the various  Struts tag libraries?&lt;/strong&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;The Struts distribution  includes four tag libraries for the JSP framework (in struts-config.xml) :* Bean  tag library [ struts-bean.tld ] : Contains tags for accessing JavaBeans and  their properties. Developers can also define new beans and set properties* HTML  tag library [ struts-html.tld ] : Contains tags to output standard HTML,  including forms, textfields, checkboxes, radio buttons* Logic tag library [  struts-logic.tld ] : Contains tags for generating conditional output, iteration  capabilities and flow management* Tiles or Template tag library [  struts-tiles.tld / struts-template.tld ] : For tiles implementation* Nested tag  library [ struts-nested.tld ] : allows the use of nested beans.&lt;/p&gt;  &lt;p&gt;The libraries are  designed to:* Facilitate the separation of presentation and business logic.*  Dynamically generate Web pages.* Implement the flow of control to and from the  ActionServlet.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong style="color: rgb(204, 102, 0);"&gt;Q.What is the  difference between Struts 1.0 and Struts 1.1?&lt;/strong&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;The  new features added to Struts 1.1 are 1. RequestProcessor class 2. Method  perform() replaced by execute() in Struts base Action Class 3. Changes to  web.xml and struts-config.xml4.Declarative exception handling5.Dynamic  ActionForms6.Plug-ins7.Multiple Application Modules8.Nested Tags9.The Struts  Validator10.Change to the ORO package11.Change to Commons logging12.Removal of  Admin actions13. Deprecation of the GenericDataSource.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong style="color: rgb(204, 102, 0);"&gt;Q.What are the core classes of  struts?&lt;/strong&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;The core classes of struts are ActionForm,  Action, ActionMapping, ActionForward etc.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong style="color: rgb(204, 102, 0);"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-75355601539202874?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/75355601539202874/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=75355601539202874' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/75355601539202874'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/75355601539202874'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/03/struts-interview-questions_31.html' title='STRUTS iNTERVIEW QUESTIONS'/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-1429283351190025292</id><published>2008-03-31T23:20:00.000-07:00</published><updated>2008-03-31T23:23:17.999-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='STRUTS INTERVIEW-2'/><title type='text'>STRUTS Interview Questions</title><content type='html'>&lt;span style="color: rgb(153, 51, 0);"&gt;&lt;strong&gt;Q.What is DispatchAction? &lt;br /&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;DispatchAction is specialized child of Struts Action  class. It combines or group the methods that can further access the bussiness  logic at a single place. The method can be anyone from CRUD  [Create,Retrieve,Update or Delete] or it can be security check one like  authenticate user etc.This class apart from having thread-safe execute method  also can have user-defined methods.&lt;br /&gt;&lt;br /&gt;In struts-config.xml files  following changes are required for Dispatch action to work:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;textarea rows="15" cols="45"&gt;&lt;action-mappings&gt;&lt;action path="/login" type ="com.....LoginAction" name ="loginForm" parameter ="task" scope = "request" validate = "false" input = "/index.jsp"&gt;&lt;forward name="success" path="/jsp/common/index.jsp"&gt;&lt;forward name="loginagain" path="/index.jsp"&gt;&lt;/action&gt;&lt;/action-mappings&gt;&lt;/textarea&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If above is your struts-config.xml file structure and LoginAction extends DispatchAction instead of normal Action class. And assuming [keep assuming] your LoginAction class have method named authenticateUser, then in your login.jsp add any hidden parameter called task with value as your method name and on submit of that page following will be the url:http://localhost:8080/yourproject/jsp/login.jsp?login.do&amp;amp;task=authenticateUserThus if we try to combine the last part of this puzzle we get the climax at struts-config.xml file's action-mapping tag described above.&lt;br /&gt;&lt;br /&gt;The parameter property of &lt;action&gt;tag have the task as it's value pointing to task variable in  the request having it's value as authenticateUserhence the framework search in  the LoginAction a method called authenticateUser through reflection and forwards  the execution flow to it.This is all folks, the briallancy of Struts framework.  Note DispatchAction class is included in 1.1 version.&lt;br /&gt;&lt;br /&gt;&lt;/action&gt;&lt;strong style="color: rgb(204, 102, 0);"&gt;&lt;br /&gt;Q.How to call ejb from Struts? &lt;br /&gt;&lt;br /&gt;&lt;/strong&gt;We can call EJB from struts by using the service locator design  patteren or by Using initial context with create home object and getting return  remote referenc object.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong style="color: rgb(204, 102, 0);"&gt;Q.In  struts how can i validate the values filled into the text boxes or else using  DynaValidatorForm,without using javascript.Actually with javascript it is  working perfect but not without javascript, and i want without  javascript?&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Using the validate() method of the ActionForm class, the values filled in the  form will be validated in the case there is no JavaScript for validating the  form.&lt;br /&gt;&lt;/p&gt; &lt;p&gt;&lt;br /&gt;&lt;strong style="color: rgb(204, 102, 0);"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;&gt;&gt;Next&gt;&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-1429283351190025292?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/1429283351190025292/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=1429283351190025292' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/1429283351190025292'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/1429283351190025292'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/03/struts-interview-questions.html' title='STRUTS Interview Questions'/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-5392783800580375651</id><published>2008-03-31T23:14:00.000-07:00</published><updated>2008-03-31T23:20:37.448-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SRUTS INTERVIEW'/><title type='text'>SRUTS INTERVIEW QUESTIONS</title><content type='html'>&lt;div&gt;&lt;strong style="color: rgb(204, 102, 0);"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Q.What is Tiles-def.xml n validation.xml in  Struts?&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;tiles-def.xmltiles-def.xml is used as a configuration file  for an appliction during tiles development You can define the layout / header /  footer / body content for your View.Eg:&lt;br /&gt;&lt;br /&gt; &lt;textarea rows="15" cols="45"&gt;&lt;tiles-definitions&gt;&lt;definition name="siteLayoutDef" path="/layout/thbiSiteLayout.jsp"&gt;&lt;put name="title" value="Title of the page"&gt;&lt;put name="header" value="/include/thbiheader.jsp"&gt; &lt;put name="footer" value="/include/thbifooter.jsp"&gt;&lt;put name="content" type="string"&gt;Content goes here&lt;/put&gt;&lt;/definition&gt;&lt;/tiles-definitions&gt; &lt;tiles-definitions&gt;&lt;definition name="userlogin" extends="siteLayoutDef"&gt;&lt;put name="content" value="/dir/login.jsp"&gt;&lt;/definition&gt; &lt;/tiles-definitions&gt;&lt;br /&gt;&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;2.  validation.&lt;/span&gt;xmlThe validation.xml file is used to declare sets of validations  that should be applied to Form Beans.Each Form Bean you want to validate has its  own definition in this fileInside that definition, you specify the validations  you want to apply to the Form Bean's&lt;br /&gt;fields.Eg:&lt;br /&gt;&lt;br /&gt; &lt;textarea rows="15" cols="45"&gt;&lt;&lt;a href="http://not-a-real-namespace/http://www.coolinterview.com/interview/1529/" target="_top"&gt;form-validation&lt;/a&gt;&gt;&lt;formset&gt;&lt;form name="logonForm"&gt;&lt;field property="username" depends="required"&gt;&lt;arg0 key=" prompt.username"&gt;&lt;/field&gt;&lt;field property="password" depends="required"&gt;&lt;arg0 key="prompt.password"&gt;&lt;/field&gt; &lt;/form&gt;&lt;/formset&gt;&lt;/form-validation&gt;&lt;/textarea&gt; &lt;br /&gt;&lt;br /&gt;3. Resourcebundle.propertiesInstead of having hard-coded error messages  in the framework, Struts Validator allows you to specify a key to a message in  the ApplicationResources.properties (or resourcebundle.properties) file that  should be returned if a validation fails. Eg:In &lt;br /&gt;ApplicationResources.propertieserrors.registrationForm.name={0} Is an  invalid name.In the&lt;br /&gt;registrationForm.jsp&lt;br /&gt;&lt;br /&gt; &lt;textarea rows="5" cols="45"&gt;&lt;html:messages id="messages" property="name"&gt;&lt;span&gt;&lt;bean:write name="messages"&gt;&lt;/html:messages&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;Output(in  red color) : abc Is an invalid name ________________1. Purpose of tiles-def.xml  file is used to in the design face of the webpage. For example in the webpage  "top or bottom or left is fixed" center might be dynamically chaged.It is used  for the easy design of the web sites. Reusability2. resourcebundle.properties  file is used for lot of purpose. One of its purpose is internationalization. We  can make our page to view on any language. It is independent of it. Just based  on the browser setting it selects the language and it displayed as you mentioned  in the resourcebundle.properties file.3. Validation rule.xml is used to put all  the validation of the front-end in the validationrule.xml. So it verifies. If  the same rule is applied in more than one page. No need to write the code once  again in each page.&lt;br /&gt;&lt;br /&gt;Use validation to chek the errors in  forms.________tiles-def.xml - is required if your application incorporates the  tiles framework in the "View" part of MVC. Generally we used to have a  traditional JSP's (Which contgains HTML &amp;amp; java scriplets) are used in view.  But Tiles is an advanced (mode or less ) implementation of frames used in HTML.  We used to define the frames in HTML to seperate the header html, footer html,  menu or left tree and body.html to reuse the contents. Hence in the same way,  Tiles are defined to reuse the jsp's in struts like architectures, and we can  define the jsp's which all are to be display at runtime, by providing the jsp  names at runtime. To incorporate this we need tile-def.xml and the Class  generally which extends RequestProcessor should extend  TilesRequestProcessor.resourcebundle.properties -- It is to incorporate i18n  (internationalization) in View part of MVC.validation.xml - This file is  responsible for business validations carried at server side before processing  the request actually. It reduces the complexity in writing _JavaScript  validations, and in this way, we can hide the validations from the user, in View  of MVC.&lt;br /&gt;&lt;br /&gt;1.The Tiles Framework is an advanced version of that comes  bundled with the Struts Webapp framework. Its purpose is reduce the duplication  between jsp pages as well as make layouts flexible and easy to maintain. It  integrates with Struts using the concept of named views or definitions. &lt;br /&gt;&lt;br /&gt;2.Resourcebundle.properties is used to maintian all the strings that are  used in the application and their corresponding equalents in different  desiredlanguages. All the strings/labels in the application using Struts will  get it labels from this file only depending on locale. This is an i18n  implementation of struts&lt;br /&gt;&lt;br /&gt;3. This validation.xml configuration file  defines which validation routines that is used to validate Form Beans. You can  define validation logic for anynumber of Form Beans in this configuration file.  Inside that definition, you specify the validationsyou want to apply to the Form  Bean's fields. The definitions in this file use the logical names of Form Beans  from the struts-config.xml file along with the logical names of validation  routines from the validator-rules.xml file to tie the two together. &lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 0);"&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div style="text-align: center;"&gt;&lt;span style="color: rgb(153, 51, 0);"&gt;&lt;strong&gt;&lt;span style="font-weight: bold;"&gt;&gt;&gt;Next&gt;&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;span style="color: rgb(153, 51, 0);"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-5392783800580375651?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/5392783800580375651/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=5392783800580375651' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/5392783800580375651'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/5392783800580375651'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/03/sruts-interview-questions.html' title='SRUTS INTERVIEW QUESTIONS'/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-5542822024224207936</id><published>2008-03-31T23:08:00.000-07:00</published><updated>2008-03-31T23:11:30.866-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Interview Questions-1'/><title type='text'>Interview Questions</title><content type='html'>&lt;p&gt;&lt;b&gt;&lt;span style="font-family: Arial;"&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;&lt;span style="font-size: 85%;"&gt;&lt;span style="font-size: 180%;"&gt;Introduction to Java  Programming&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt; &lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Arial;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;1) The  Java interpreter is used for the execution of the source code.&lt;/span&gt;&lt;/span&gt;  &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;a) True&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;b) False&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;Ans: a.&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Arial;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;2) On  successful compilation a file with the class extension is created.&lt;/span&gt;&lt;/span&gt;  &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;a) True&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;b) False&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;Ans: a.&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Arial;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;3) The  Java source code can be created in a Notepad editor.&lt;/span&gt;&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;a) True&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;b) False&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;Ans: a.&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Arial;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;4) The  Java Program is enclosed in a class definition.&lt;/span&gt;&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;a) True&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;b) False&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;Ans: a.&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Arial;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;5) What  declarations are required for every Java application?&lt;/span&gt;&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;Ans: A class and the main( ) method  declarations.&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Arial;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;6) What  are the two parts in executing a Java program and their purposes?&lt;/span&gt;&lt;/span&gt;  &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;Ans: Two parts in executing a Java program  are:&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;Java Compiler and Java Interpreter.&lt;/span&gt;  &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;The Java Compiler is used for compilation  and the Java Interpreter is used for execution of the application.&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Arial;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;7) What  are the three OOPs principles and define them?&lt;/span&gt;&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;Ans : Encapsulation, Inheritance and  Polymorphism are the three OOPs&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;Principles.&lt;/span&gt; &lt;/p&gt; &lt;p style="color: rgb(255, 102, 0);"&gt;&lt;u&gt;&lt;span style="font-family: Arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/u&gt;&lt;/p&gt;&lt;p style="color: rgb(255, 102, 0);"&gt;&lt;u&gt;&lt;span style="font-family: Arial;"&gt;Encapsulation:&lt;/span&gt;&lt;/u&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;Is the Mechanism that binds together code  and the data it manipulates, and keeps both safe from outside interference and  misuse.&lt;/span&gt; &lt;/p&gt; &lt;p style="color: rgb(255, 102, 0);"&gt;&lt;u&gt;&lt;span style="font-family: Arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/u&gt;&lt;/p&gt;&lt;p style="color: rgb(255, 102, 0);"&gt;&lt;u&gt;&lt;span style="font-family: Arial;"&gt;Inheritance:&lt;/span&gt;&lt;/u&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;Is the process by which one object acquires  the properties of another object.&lt;/span&gt; &lt;/p&gt; &lt;p style="color: rgb(255, 102, 0);"&gt;&lt;u&gt;&lt;span style="font-family: Arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/u&gt;&lt;/p&gt;&lt;p style="color: rgb(255, 102, 0);"&gt;&lt;u&gt;&lt;span style="font-family: Arial;"&gt;Polymorphism:&lt;/span&gt;&lt;/u&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;Is a feature that allows one interface to be  used for a general class of actions.&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Arial;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;8) What is  a compilation unit?&lt;/span&gt;&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;Ans : Java source code file.&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Arial;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;9) What  output is displayed as the result of executing the following  statement?&lt;/span&gt;&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;System.out.println("// Looks like a  comment.");&lt;/span&gt;&lt;/span&gt; &lt;/p&gt; &lt;ol type="a"&gt;&lt;li&gt;&lt;span style="font-family: Arial;"&gt;// Looks like a comment&lt;/span&gt;  &lt;/li&gt;&lt;li&gt;&lt;span style="font-family: Arial;"&gt;The statement results in a compilation  error&lt;/span&gt;  &lt;/li&gt;&lt;li&gt;&lt;span style="font-family: Arial;"&gt;Looks like a comment&lt;/span&gt;  &lt;/li&gt;&lt;li&gt;&lt;span style="font-family: Arial;"&gt;No output is displayed&lt;/span&gt;  &lt;/li&gt;&lt;/ol&gt;&lt;span style="font-family: Arial;"&gt;Ans : a.&lt;/span&gt;  &lt;p&gt;&lt;span style="font-family: Arial;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Arial;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;10) In  order for a source code file, containing the public class Test, to successfully  compile, which of the following must be true?&lt;/span&gt;&lt;/span&gt; &lt;/p&gt; &lt;ol type="a"&gt;&lt;li&gt;&lt;span style="font-family: Arial;"&gt;It must have a package statement&lt;/span&gt;  &lt;/li&gt;&lt;li&gt;&lt;span style="font-family: Arial;"&gt;It must be named Test.java&lt;/span&gt;  &lt;/li&gt;&lt;li&gt;&lt;span style="font-family: Arial;"&gt;It must import java.lang&lt;/span&gt;  &lt;/li&gt;&lt;li&gt;&lt;span style="font-family: Arial;"&gt;It must declare a public class named  Test&lt;/span&gt; &lt;/li&gt;&lt;/ol&gt;&lt;span style="font-family: Arial;"&gt;Ans : b&lt;/span&gt;  &lt;p&gt;&lt;span style="font-family: Arial;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Arial;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;11) What  are identifiers and what is naming convention?&lt;/span&gt;&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;Ans : Identifiers are used for class names,  method names and variable names. An identifier may be any descriptive sequence  of upper case &amp;amp; lower case letters,numbers or underscore or dollar sign and  must not begin with numbers.&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Arial;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;12) What  is the return type of program’s main( ) method?&lt;/span&gt;&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;Ans : void&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Arial;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;13) What  is the argument type of program’s main( ) method?&lt;/span&gt;&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;Ans : string array.&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Arial;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;14) Which  characters are as first characters of an identifier?&lt;/span&gt;&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;Ans : A – Z, a – z, _ ,$&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Arial;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;15) What  are different comments?&lt;/span&gt;&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;Ans :&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Arial;"&gt;1) // -- single line comment&lt;/span&gt;  &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;2)&lt;br /&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;/* --*/ multiple line comment&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;3)&lt;br /&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;/** --*/ documentation&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-family: Arial;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Arial;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;16) What  is the difference between constructor method and method?&lt;/span&gt;&lt;/span&gt; &lt;span style="font-family: Arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Arial;"&gt;Ans : Constructor will be automatically  invoked when an object is created. Whereas method has to be call  explicitly.&lt;/span&gt;&lt;/p&gt; &lt;span style="font-family: Arial;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;17) What is the use of bin and lib in  JDK?&lt;/span&gt;&lt;/span&gt;   &lt;p&gt;&lt;span style="font-family: Arial;"&gt;Ans : Bin contains all tools such as javac,  applet viewer, awt tool etc., whereas Lib&lt;br /&gt;contains all packages and  variables&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;&gt;&gt;Next&gt;&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-5542822024224207936?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/5542822024224207936/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=5542822024224207936' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/5542822024224207936'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/5542822024224207936'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/03/interview-questions.html' title='Interview Questions'/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-620210819298798550</id><published>2008-03-31T22:56:00.000-07:00</published><updated>2008-03-31T22:58:26.392-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='J2ee Interview Questions-1'/><title type='text'>J2ee Interview Questions</title><content type='html'>&lt;span style="font-weight: bold;"&gt;Differentiate between .ear, .jar and .war files&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;These files are simply zipped file using java jar tool. These files are created for different purposes.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Here is the description of these files: &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(204, 102, 0);"&gt;.jar files:&lt;/span&gt; These files are with the .jar extenstion. The .jar files contains the libraries, resources and accessories files like property files.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(204, 102, 0);"&gt;.war files:&lt;/span&gt; These files are with the .war extension. The war file contains the web application that can be deployed on the any servlet/jsp container. The .war file contains jsp, html, javascript and other files for necessary for the development of web applications.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(204, 102, 0); font-weight: bold;"&gt;.ear files:&lt;/span&gt; The .ear  file contains the EJB modules of the application.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;What is the difference between Session Bean and Entity Bean?&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(204, 102, 0);"&gt;Session Bean:&lt;/span&gt; Session is one of the EJBs and it represents a single client inside the Application Server. Stateless session is easy to develop and its efficient. As compare to entity beans session beans require few server resources.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;A session bean is similar to an interactive session and is not shared; it can have only one client, in the same way that an interactive session can have only one user. A session bean is not persistent and it is destroyed once the session terminates.&lt;br /&gt;Entity Bean: An  entity bean represents persistent global data from the database. Entity beans  data are stored into database.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;Why J2EE is  suitable for the development distributed multi-tiered enterprise applications?&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;The J2EE platform consists of multi-tiered distributed application model. J2EE applications allows the developers to design and implement the business logic into components according to business requirement. J2EE architecture allows the development of multi-tired applications and the developed applications can be installed on different machines depending on the tier in the multi-tiered J2EE environment .&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt; J2EE application parts are: &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;a) Client-tier components run on the client machine.&lt;br /&gt;&lt;br /&gt;b) Web-tier  components run on the J2EE server.&lt;br /&gt;&lt;br /&gt;c) Business-tier components run on  the J2EE server and the&lt;br /&gt;&lt;br /&gt;d) Enterprise information system (EIS)-tier  software runs on the EIS servers&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-620210819298798550?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/620210819298798550/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=620210819298798550' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/620210819298798550'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/620210819298798550'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/03/j2ee-interview-questions_31.html' title='J2ee Interview Questions'/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-6487853872790708394</id><published>2008-03-31T22:55:00.000-07:00</published><updated>2008-03-31T22:56:32.345-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='J2ee Interview Questions'/><title type='text'>J2ee Interview Questions</title><content type='html'>&lt;div&gt;&lt;strong&gt;J2EE&lt;/strong&gt; Stands for Java 2 Enterprise Edition. J2EE is an environment for developing and deploying enterprise applications. J2EE specification is defined by Sun Microsystems Inc. The J2EE platform is one of the best platform for the development and deployment of enterprise applications. The J2EE platform is consists of a set of services, application programming interfaces (APIs), and protocols, which provides the functionality necessary for developing multi-tiered, web-based applications.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;&lt;strong&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;What do you understand by a J2EE  module? &lt;/span&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;A J2EE module is a software unit that consists of one or more J2EE components of the same container type along with one deployment descriptor of that type. J2EE specification defines four types of modules:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;a) EJB&lt;br /&gt;b) Web&lt;br /&gt;c) application client and&lt;br /&gt;d)  resource adapter&lt;br /&gt;&lt;br /&gt;In the J2EE applications modules can be deployed as  stand-alone units. Modules can also be assembled into J2EE applications.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;Tell me something about J2EE component?&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;J2EE component is a self-contained functional software unit supported by a container and configurable at deployment time. The J2EE specification defines the following J2EE components:&lt;br /&gt;&lt;br /&gt;Application clients  and applets are components that run on the client.&lt;br /&gt;Java servlet and  JavaServer Pages (JSP) technology components are Web components that run on the  server.&lt;br /&gt;&lt;br /&gt;Enterprise JavaBeans (EJB) components (enterprise beans) are business components that run on the server. J2EE components are written in the Java programming language and are compiled in the same way as any program in the language. The difference between J2EE components and "standard" Java classes is that J2EE components are assembled into a J2EE application, verified to be well formed and in compliance with the J2EE specification, and deployed to production, where they are run and managed by the J2EE server or client container.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;What are the contents of web  module?&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;A web module may contain:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;a) JSP  files&lt;br /&gt;b) Java classes&lt;br /&gt;c) gif and html files and&lt;br /&gt;d) web component  deployment descriptors&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;span style="color: rgb(153, 51, 0);"&gt;&lt;strong&gt;&gt;&gt;&gt;Next&gt;&gt;&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-6487853872790708394?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/6487853872790708394/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=6487853872790708394' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/6487853872790708394'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/6487853872790708394'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/03/j2ee-interview-questions.html' title='J2ee Interview Questions'/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-610466704975983243</id><published>2008-03-30T01:00:00.002-07:00</published><updated>2008-03-30T01:01:22.361-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CORE JAVA faqs-9'/><title type='text'>CORE JAVA FAQS</title><content type='html'>&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;41.&lt;/span&gt;     &lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;What is the difference between pre-emptive multi-tasking and co-operative  multi-tasking? &lt;/span&gt;&lt;br /&gt;       &lt;br /&gt;        In case of pre-emptive multitasking, the program is  interrupted without consulting first where as in case of co-operative  multitasking; programs are interrupted only when they are willing to yield  control.&lt;br /&gt;       &lt;br /&gt;        Windows 95,NT – pre-emptive multi-tasking where Windows 3.1 is  co-operative multitasking.&lt;br /&gt;        Pre-emptive multi-tasking is more effective as  compared co-operative multitasking.&lt;br /&gt;       &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;42.&lt;/span&gt;     &lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;What is difference between creating a thread by extending Thread class and  implementing Runnable? &lt;/span&gt;&lt;br /&gt;       &lt;br /&gt;        Explain the four different states of a thread &lt;br /&gt;       &lt;br /&gt;        &lt;span style="font-weight: bold; color: rgb(0, 0, 153);"&gt;The four different states of a thread are &lt;/span&gt;&lt;br /&gt;       &lt;br /&gt;        &lt;span style="font-weight: bold; color: rgb(51, 51, 153);"&gt;New:&lt;/span&gt; When a thread is created  with new operator .It is not yet running.&lt;br /&gt;       &lt;br /&gt;        &lt;span style="font-weight: bold; color: rgb(0, 0, 153);"&gt;Runnable: &lt;/span&gt;Once you invoke the  start method on the thread it becomes runnable. It is up to the OS to decide  when to give time to the thread to run. A runnable thread may or may not be  running.&lt;br /&gt;        &lt;span style="font-weight: bold; color: rgb(0, 0, 153);"&gt;&lt;br /&gt;Blocked : &lt;/span&gt;Thread enters this state under the following condition. &lt;br /&gt;        Someone calls sleep () on the thread.&lt;br /&gt;       &lt;br /&gt;        Thread calls an operation that  blocks on input/output.&lt;br /&gt;        Thread calls wait() method.&lt;br /&gt;        Thread tries to lock  an object that is currently locked by another thread.&lt;br /&gt;        &lt;span style="font-weight: bold; color: rgb(0, 0, 153);"&gt;&lt;br /&gt;Dead : &lt;/span&gt;The Thread is  dead for one of two reasons.&lt;br /&gt;       &lt;br /&gt;        It dies a natural death because the run method  exits normally.&lt;br /&gt;        It dies abruptly because an uncaught exception terminates  the run method.&lt;br /&gt;       &lt;br /&gt;   &lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;43&lt;/span&gt;.     &lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;What happens when there are more than one highest priority threads having  same priority? &lt;/span&gt;&lt;br /&gt;       &lt;br /&gt;        In that case only one of the thread is picked up. It is up to  the thread Scheduler to arbitrate between threads of same priority.&lt;br /&gt;        There is  no guarantee that all the same priority threads will be fairly treated. &lt;br /&gt;       &lt;br /&gt;   &lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;44.&lt;/span&gt;     &lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;Why do threads block on I/O ?&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Threads block on I/O so that other threads  may execute while the I/O operation is performed.&lt;br /&gt;       &lt;br /&gt;   &lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;45. &lt;/span&gt;     &lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;What are the methods which can only be called from within a Synchronized  method or block ? &lt;/span&gt;&lt;br /&gt;        &lt;span style="font-weight: bold; color: rgb(0, 0, 153);"&gt;&lt;br /&gt;Notify ():&lt;/span&gt; unblocks one randomly selected thread among the  threads that called wait() on this object.&lt;br /&gt;        &lt;span style="font-weight: bold; color: rgb(0, 0, 153);"&gt;&lt;br /&gt;NoitifyAll() :&lt;/span&gt; unblocks the  threads that called wait() on this object.&lt;br /&gt;        &lt;span style="font-weight: bold; color: rgb(0, 0, 153);"&gt;&lt;br /&gt;Wait ():&lt;/span&gt; causes the thread to  wait until it is notified.&lt;br /&gt;       &lt;br /&gt;   &lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;46.&lt;/span&gt;     &lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;What is the difference between yield and sleep  methods of Thread?&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;When a task invokes its yield () method, it returns to  the ready state. When a task invokes its sleep () method, it returns to the  waiting state.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-610466704975983243?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/610466704975983243/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=610466704975983243' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/610466704975983243'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/610466704975983243'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/03/core-java-faqs_3326.html' title='CORE JAVA FAQS'/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-4285074471165368945</id><published>2008-03-30T01:00:00.001-07:00</published><updated>2008-03-30T01:00:53.301-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CORE JAVA faqs-8'/><title type='text'>CORE JAVA FAQS</title><content type='html'>&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;36.&lt;/span&gt;     &lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;What happens during Resolution Phase?&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Resolution is the process of  locating classes, interfaces, fields, and methods referenced symbolically from a  types constant pool, and replacing those symbolic references with direct  references.&lt;br /&gt;     &lt;br /&gt; &lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;37.&lt;/span&gt;     &lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;How the initialization of class is is different from initialization of  interface? &lt;/span&gt;&lt;br /&gt;     &lt;br /&gt;      Initialization of class requires initialization of its super  classes but initialization of interfaces doesn’t require initialization of it  super interfaces.&lt;br /&gt;     &lt;br /&gt; &lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;38.&lt;/span&gt;     &lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;What is a JIT compiler? &lt;/span&gt;&lt;br /&gt;     &lt;br /&gt;      JIT compilers are used to convert the java byte  codes to native types on the fly.&lt;br /&gt;     &lt;br /&gt;      &lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;39.&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt; What is the difference between instance method and class method ? &lt;/span&gt;&lt;br /&gt;     &lt;br /&gt;      ·  Instance methods require an instance before they can be invoked; class methods  do not.&lt;br /&gt;      · Instance methods use dynamic (late) binding; class(static methods)  methods use static (early) binding.&lt;br /&gt;      &lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;40.&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt; What is the difference between a process and Thread? &lt;/span&gt;&lt;br /&gt;     &lt;br /&gt;      A process is a  self-contained running program within its own address space while a Thread is a  single sequential flow of control within a process.&lt;br /&gt;     &lt;br /&gt;      Each process has its own  set of variables where as Threads share the same data.&lt;br /&gt;     &lt;br /&gt;      Inter-process  communication is much slower and restrictive as compared to inter-thread &lt;br /&gt;      communication is faster.&lt;br /&gt;     &lt;br /&gt;      Creating and destroying Thread is much cheaper in  terms of performance overhead as compared to launching a new process.&lt;br /&gt;     &lt;br /&gt; &lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-4285074471165368945?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/4285074471165368945/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=4285074471165368945' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/4285074471165368945'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/4285074471165368945'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/03/core-java-faqs_7852.html' title='CORE JAVA FAQS'/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-6298592736426738140</id><published>2008-03-30T00:59:00.000-07:00</published><updated>2008-03-30T01:00:24.380-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CORE JAVA faqs-7'/><title type='text'>CORE JAVA FAQS</title><content type='html'>&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;31.&lt;/span&gt;     &lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;What are steps involved in loading of a class file into JVM?&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;· Produce a  stream of binary data that represents the type.&lt;br /&gt;&lt;br /&gt;· Parse the stream of binary  data into internal data structures in the method area.&lt;br /&gt;&lt;br /&gt;· Create an instance  of class java.lang.Class that represents the type.&lt;br /&gt;    &lt;br /&gt;&lt;br /&gt;     &lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;32.&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;Is it possible to detect  a malformed class file during early loading by the class loader? &lt;/span&gt;&lt;br /&gt;    &lt;br /&gt;     No it is  not possible. If a class loader encounters a missing or malformed class file  during early loading, it must wait to report that error until the class is first  active use by the program.&lt;br /&gt;    &lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;33.&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;What are the different stages of linking after  the class is loaded? &lt;/span&gt;&lt;br /&gt;    &lt;br /&gt;     Verification, prepare and resolve are the three phases  of linking.&lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;34. &lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;What is verification stage and what are steps involved during verification?  &lt;/span&gt;&lt;br /&gt;    &lt;br /&gt;     It ensures that the types obey the semantics of java language and doesn’t  violate the integrity of JVM.&lt;br /&gt;    &lt;br /&gt;     The entire process of detecting any kind of  problem with loaded types is placed under the category of verification. &lt;br /&gt;    &lt;br /&gt;     Verification of symbolic references and converting them to direct  references.&lt;br /&gt;    &lt;br /&gt;     · checking that final classes are not sub classed&lt;br /&gt;    &lt;br /&gt;     · checking  that final methods are not overridden&lt;br /&gt;    &lt;br /&gt;     · if the type being checked is a  non-abstract class, checking that all the methods declared in any&lt;br /&gt;     interfaces  implemented by the class are indeed implemented by the class&lt;br /&gt;    &lt;br /&gt;     · Making sure  no incompatible method declarations (such as two methods that have the same  name, the same number, order, and types of parameters, but different return  types) appear between the type and its supertypes.&lt;br /&gt;    &lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;3&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;5.&lt;/span&gt;     &lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;What is done during Preparation Stage?&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;     The Java Virtual Machine  allocates memory for the class variables and sets them to default initial  values. The class variables are not initialized to their proper initial values  until the initialization phase.&lt;br /&gt;    &lt;br /&gt;     Java Virtual Machine implementations may  also allocate memory for data structures that are intended to improve the  performance of the running program.&lt;br /&gt;    &lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-6298592736426738140?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/6298592736426738140/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=6298592736426738140' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/6298592736426738140'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/6298592736426738140'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/03/core-java-faqs_2427.html' title='CORE JAVA FAQS'/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-8849497377725091418</id><published>2008-03-30T00:55:00.000-07:00</published><updated>2008-03-30T00:59:29.741-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CORE JAVA faqs-6'/><title type='text'>CORE JAVA FAQS</title><content type='html'>&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;26.When the  JVM terminates ? &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The Java Virtual machine terminates when all the non-daemon  threads of java application terminates.&lt;br /&gt;    If permitted by the security manager  it can also call System.runtime.ext () for terminating the JVM.&lt;br /&gt;   &lt;br /&gt;&lt;span style="font-weight: bold;"&gt;27. &lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;Is it possible to know from the content of a class file whether it is a java  class file or not?&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;The first four bytes of every java class file is a magic  number “0xCAFEBABE”. So it is very easy to identify whether it is a java class  file or not.&lt;br /&gt;   &lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;&lt;br /&gt;28.Name the process thru which JVM makes the types available to the running  program? &lt;/span&gt;&lt;br /&gt;   &lt;br /&gt;    The Java Virtual Machine makes types available to the running  program through a process of loading, linking, and initialization.&lt;br /&gt;   &lt;br /&gt;    &lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;29.&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt; Define loading, linking and initialization of java class ? &lt;/span&gt;&lt;br /&gt;   &lt;br /&gt;    &lt;span style="font-weight: bold; color: rgb(0, 0, 153);"&gt;Loading :&lt;/span&gt;  Loading is the process of bringing a binary form for a type into the Java  Virtual Machine.&lt;br /&gt;    &lt;span style="font-weight: bold; color: rgb(0, 0, 153);"&gt;&lt;br /&gt;Linking :&lt;/span&gt; Linking is the process of incorporating the  binary type data into the runtime state of the virtual machine. Linking is  divided into three sub-steps: verification, preparation, and resolution. &lt;br /&gt;    &lt;span style="font-weight: bold; color: rgb(0, 0, 153);"&gt;&lt;br /&gt;Initialization:&lt;/span&gt; During initialization the class variables are their proper  initial values.&lt;br /&gt;   &lt;br /&gt;    &lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;30.&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt; What do you mean by first active use of a class in JVM? &lt;/span&gt;&lt;br /&gt;   &lt;br /&gt;&lt;br /&gt;· The invocation  of a constructor on a new instance of the class.&lt;br /&gt;&lt;br /&gt;· The creation of an array  that has the class as its an element type.&lt;br /&gt;&lt;br /&gt;· The invocation of a method  declared by the class (not inherited from a super class) .&lt;br /&gt;&lt;br /&gt;· The use or  assignment of a field declared by the class (not inherited from a superclass or  super interface), except for fields that are both static and final, and are  initialized by a compile-time constant expression.&lt;br /&gt;   &lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-8849497377725091418?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/8849497377725091418/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=8849497377725091418' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/8849497377725091418'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/8849497377725091418'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/03/core-java-faqs_6153.html' title='CORE JAVA FAQS'/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-2470096915905205745</id><published>2008-03-30T00:53:00.000-07:00</published><updated>2008-03-30T00:55:17.737-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CORE JAVA faqs-5'/><title type='text'>CORE JAVA FAQS</title><content type='html'>&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;21. How many times may an  object's finalize() method be invoked by the garbage collector and when it is  invoked ? &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;An object's finalize() method may only be invoked once by the  garbage collector when the object is unreachable.&lt;br /&gt;  &lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;22. Does garbage collection guarantee that a program will not run out of memory?  &lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;   Garbage collection does not guarantee that a program will not run out of  memory. It is possible for programs to use up memory resources faster than they  are garbage collected. It is also possible for programs to create objects that  are not subject to garbage collection.&lt;br /&gt;  &lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;&lt;br /&gt;23. How does the distributed garbage collection work in java? &lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;   · The RMI  subsystem implements a reference counting-based distributed garbage collection  (DGC) algorithm to provide automatic memory management facilities for remote  server objects.&lt;br /&gt;&lt;br /&gt;· Basically, DGC works by having the remote server keep  track of all external client references to it at any given time. When a client  obtains a remote reference, it is addded to the remote object's referenced set.  The DGC then marks the remote object as dirty and increases its reference count  by one. When a client drops a reference, the DGC decreases its reference count  by one, and marks the object as clean.&lt;br /&gt;&lt;br /&gt;When the reference count reaches zero,  the remote object is free of any live client references. It is then placed on  the weak reference list and subject to periodic garbage collection.&lt;br /&gt;  &lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;&lt;br /&gt;24.What is the priority of Garbage collection thread in java ? &lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;   This is a  low-priority thread in java.&lt;br /&gt;  &lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;&lt;br /&gt;25. How many applications can be run by one run-time instance of JVM ? &lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;   One  run-time instance of java application can run only one instance.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-2470096915905205745?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/2470096915905205745/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=2470096915905205745' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/2470096915905205745'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/2470096915905205745'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/03/core-java-faqs_5725.html' title='CORE JAVA FAQS'/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-6133030306447135813</id><published>2008-03-30T00:50:00.000-07:00</published><updated>2008-03-30T00:53:09.699-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CORE JAVA faqs-4'/><title type='text'>CORE JAVA FAQS</title><content type='html'>&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;16. What is a singleton class and how to  implement it? What are the advantages of Singleton class? &lt;/span&gt;&lt;br /&gt; &lt;br /&gt;  Singleton classes  are created to have only one instance.&lt;br /&gt;  A singleton may be used to represent  some unique system.&lt;br /&gt;  It is generally implemented by keeping the constructor  private.&lt;br /&gt;  It should have static members and methods.&lt;br /&gt;  The main advantage  of singleton class is memory management( Garbage collection)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;17. Why java  prohibits use of ‘synchronized’ inside a constructor ?&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;   Because other threads  cannot get a reference to the object until construction of the object completes.  This has got a performance overhead.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;18. What do you mean by Garbage collection  and what are its advantages and disadvantages? &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The purpose of garbage  collection is to identify and discard objects that are no longer needed by a  program so that their resources may be reclaimed.&lt;br /&gt;&lt;br /&gt;An object is eligible for  garbage collection when its reference is set to null. Method variables or local  variables are eligible for Garbage collection when they go out of scope. &lt;br /&gt;&lt;br /&gt;Garbage Collection cannot be forced explicitly. JVM may do garbage  collection if it is running short of memory.The call System.gc() does NOT force  the garbage collection but only suggests that the JVM may make an effort to do  garbage collection.&lt;br /&gt;&lt;br /&gt;It frees up the heap space and takes care of heap  fragmentation.&lt;br /&gt;&lt;br /&gt;It also helps to ensure program integrity as programmers are  unable to crash the JVM by incorrectly freeing the memory accidentally or  purposefully.&lt;br /&gt;&lt;br /&gt;The only disadvantage is garbage-collected heap is a  performance overhead.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;19.What do you mean by conservative garbage collector?  &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The garbage collectors that cannot distinguish between genuine object  references and look-alikes.&lt;br /&gt; &lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;20. Can an object's finalize () method be invoked  while it is reachable? &lt;/span&gt;&lt;br /&gt; &lt;br /&gt;  An object's finalize() method cannot be invoked by  the garbage collector while the object is still reachable. However, an object's  finalize() method may be invoked by other objects.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-6133030306447135813?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/6133030306447135813/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=6133030306447135813' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/6133030306447135813'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/6133030306447135813'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/03/core-java-faqs_7999.html' title='CORE JAVA FAQS'/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-5138972253710556367</id><published>2008-03-30T00:49:00.000-07:00</published><updated>2008-03-30T00:50:55.393-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CORE JAVA faqs-3'/><title type='text'>CORE JAVA FAQS</title><content type='html'>&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;11.What restrictions are placed on method overriding? &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;· Overridden methods  must have the same name, argument list, and return type.&lt;br /&gt;&lt;br /&gt;· The overriding  method may not limit the access of the method it overrides.&lt;br /&gt;&lt;br /&gt;· The overriding  method may not throw any exceptions that may not be thrown by the overridden  method.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;&lt;br /&gt;12. What is use of this and super key words? &lt;/span&gt;&lt;br /&gt;&lt;br /&gt; · ‘this’ is used for referring  to current instance of the object where as ‘super’ is used to refer to variables  and methods of its super class.&lt;br /&gt;&lt;br /&gt;· Incase of constructors, this() is used to  invoke a constructor of the same class. super() is used to invoke a superclass  constructor.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;13. What is the difference between a static and non-static variable? &lt;/span&gt;&lt;br /&gt;&lt;br /&gt; · A  static variable is associated with the class as a whole rather than with  specific instances of a class. Non-static variables take on unique values with  each object instance.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;14. What is polymorphism and what are different types of  polymorphism? &lt;/span&gt;&lt;br /&gt;&lt;br /&gt; · One name, different form and there are three forms.&lt;br /&gt;&lt;br /&gt;1.  Method overloading&lt;br /&gt;&lt;br /&gt;2. Method overriding through Interfaces&lt;br /&gt;&lt;br /&gt;3. Method  overriding through java interfaces.&lt;br /&gt;&lt;br /&gt; &lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;&lt;br /&gt;&lt;br /&gt;15. What is the essence of run-time  polymorphism behavior? &lt;/span&gt;&lt;br /&gt;&lt;br /&gt; With runtime polymorphism based on method overriding,  the decision as to which version of a method will be executed is based on the  actual type of object whose reference is stored in the reference variable, and  not on the type of the reference variable on which the method is invoked. &lt;br /&gt; The decisions as to which version of the method to invoke cannot be made at  compile time. That decision must be deferred and made at runtime. This is  sometimes referred to as late binding.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-5138972253710556367?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/5138972253710556367/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=5138972253710556367' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/5138972253710556367'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/5138972253710556367'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/03/core-java-faqs_8893.html' title='CORE JAVA FAQS'/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-2098164837961238920</id><published>2008-03-30T00:48:00.000-07:00</published><updated>2008-03-30T00:49:29.896-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CORE JAVA faqs-2'/><title type='text'>CORE JAVA FAQS</title><content type='html'>&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;6. What is a transient variable? &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;o The variable, which cannot be  serialized, is known as transient variable.&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;&lt;br /&gt;&lt;br /&gt;7. What are wrapped classes? &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;o  Wrapped classes are classes that allow primitive types to be accessed as  objects.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;8. What is an immutable object and what are its advantages? &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;· An  immutable object is an object and any object it references that does not change  after construction. The object is, therefore, immutable for its lifetime.&lt;br /&gt;&lt;br /&gt;·  Immutable classes are commonly used to represent strings, colors, and numeric  values.&lt;br /&gt;Advantage:&lt;br /&gt;&lt;br /&gt;· They guarantee that their state cannot change after  construction, they are inherently thread-safe.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;9. What are basic rules, which govern creation of immutable classes? &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;·  Declare the class final.&lt;br /&gt;&lt;br /&gt;· Declare all data private.&lt;br /&gt;&lt;br /&gt;· Provide only  getter methods and no setter methods.&lt;br /&gt;&lt;br /&gt;· Set all instance data in the  constructor.&lt;br /&gt;&lt;br /&gt;· Clone mutable objects for which a reference to them is  returned.&lt;br /&gt;&lt;br /&gt;· Clone mutable objects for which a reference to them is received. &lt;br /&gt;&lt;br /&gt;· Implement a deep clone if the default shallow clone is not correct for a  properly behaved immutable object.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;&lt;br /&gt;&lt;br /&gt;10. What is a Java package and how is it used?&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;· A Java package is a  naming context for classes and interfaces. A package is used to create a  separate name space for groups of classes and interfaces. Packages are also used  to organize related classes and interfaces into a single API unit and to control  accessibility to these classes and interfaces&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-2098164837961238920?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/2098164837961238920/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=2098164837961238920' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/2098164837961238920'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/2098164837961238920'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/03/core-java-faqs_30.html' title='CORE JAVA FAQS'/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-5618728522304975776</id><published>2008-03-30T00:35:00.000-07:00</published><updated>2008-03-30T00:47:56.496-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CORE JAVA faqs-1'/><title type='text'>CORE JAVA faqs</title><content type='html'>&lt;div&gt;&lt;span style="color: rgb(204, 0, 0); font-weight: bold;"&gt;1. What is the difference between an  Interface and Abstract class ?&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;· A class may implement several  interfaces where as it can extend only one abstract class.&lt;br /&gt;&lt;br /&gt;· An interface  cannot provide any code at all, much less default code where as an abstract  class can provide complete code, default code, and/or just stubs that has to be  overridden.&lt;br /&gt;&lt;br /&gt;· Static final constants can use the interfaces without  qualification in classes that implement the interface where as both static  constants and instance variables can use the abstract classes.&lt;br /&gt;&lt;br /&gt;· Interface  implementation can be added to any existing third part classes where as third  party classes must be rewritten to extend from the abstract classes.&lt;br /&gt;&lt;br /&gt;·  Interfaces are used to often represent peripheral ability of a class, not  central identity where as abstract class defines core identity of its  descendants.&lt;br /&gt;&lt;br /&gt;· If various implementations share is method signature then  Interface works best where as If the various implementations are all of a kind  and share a common status and behavior, usually an abstract class works best. &lt;br /&gt;&lt;br /&gt;· Interface is slow where as abstract class is fast in performance.&lt;br /&gt;&lt;br /&gt;· If  you add a new method to an interface, you must track down all implementations of  that interface in the universe and provide them with a concrete implementation  of that method&lt;br /&gt;where as in case of an abstract class if you add a new method to  an abstract class, you have the option of providing a default implementation of  it. Then all existing code will continue to work without change.&lt;br /&gt;&lt;br /&gt;· You can  put shared code into an abstract class, where you cannot into an interface. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;&lt;br /&gt;2. How do you write user-defined exceptions in Java? &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;· To write  user-defined exception in java, you exception class should extend Exception base  class have call the super class methods in your own methods.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;3. What is  multiple inheritance? Is it supported in java? &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;· This means one object  having multiple parents, which is not truly supported in java but supported in  C++. But overall design of java suggests that we can implement multiple  inheritances in java using interfaces.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;&lt;br /&gt;4. What is difference between an inner class and static inner class? &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;· A  non-static inner class may have object instances that are associated with  instances of the class's outer class. A static inner class does not have any  object instances.&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;&lt;br /&gt;&lt;br /&gt;5. What is an inner class and what is its advantage? &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;·  Inner class is class, which is defined inside a class as private class and  always bears a reference to the outer class.&lt;br /&gt;&lt;br /&gt;o Inner classes can be nested  within the body of a method.&lt;br /&gt;&lt;br /&gt;· Scope of inner class is the entire enclosing  class in which the inner class is nested.&lt;br /&gt;&lt;br /&gt;· Inner classes can access  attributes and methods in nesting class.&lt;br /&gt;&lt;br /&gt;· Each inner class is compiled into  a separate. class file labeled:NestingClass$InnerClass.&lt;br /&gt;&lt;br /&gt;· Inner classes can  contain methods that return handles to inner class instances.&lt;br /&gt;&lt;br /&gt;· Major  advantage of inner classes is the ability to create adaptor classes that  implement an interface.&lt;br /&gt;&lt;br /&gt;o Make all inner classes private to ensure hidden  implementation.&lt;br /&gt;&lt;br /&gt;o Rather than handle classes returning inner classes, they  return interfaces.&lt;br /&gt;&lt;br /&gt;· Inner classes frequently used with event handling in  applets.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-5618728522304975776?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/5618728522304975776/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=5618728522304975776' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/5618728522304975776'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/5618728522304975776'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/03/core-java-faqs.html' title='CORE JAVA faqs'/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-5681704751770031491</id><published>2008-03-30T00:33:00.001-07:00</published><updated>2008-03-30T00:33:59.555-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JVM FAQs-2'/><title type='text'>JVM FAQS</title><content type='html'>&lt;span style="color: rgb(255, 102, 0);"&gt;&lt;span style="font-weight: bold;"&gt;11. Should one pool  objects to help Garbage Collector?Should one call System.gc() periodically? &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;The answer is No!Pooling objects will cause them to live longer than necessary. The garbage collection methods will be much more efficient if you let it do the memory management. The strong advice is taking out object pools.Don't call System.gc(), HotSpot will make the determination of when its appropriate and will generally do a much better job.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 51, 0);"&gt;12. An application has a lot of threads and is running out of memory,  why?&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;You may be running into a problem with the default stack size for threads. In Java SE 6, the default on Sparc is 512k in the 32-bit VM, and 1024k in the 64-bit VM. On x86 Solaris/Linux it is 320k in the 32-bit VM and 1024k in the 64-bit VM.On Windows, the default thread stack size is read from the binary (java.exe). As of Java SE 6, this value is 320k in the 32-bit VM and 1024k in the 64-bit VM.You can reduce your stack size by running with the -Xss option. For example:java -server -Xss64kNote that on some versions of Windows, the OS may round up thread stack sizes using very coarse granularity. If the requested size is less than the default size by 1K or more, the stack size is rounded up to the default; otherwise, the stack size is rounded up to a multiple of 1 MB.64k is the least amount of stack space allowed per thread.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; &lt;span style="color: rgb(255, 102, 0);"&gt;&lt;span style="font-weight: bold;"&gt;13. If your program is I/O bound or running in  native methods, do these activities engage JVM?&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt; The answer is 'No'.If the program is I/O bound or running in native methods, then the VM is not involved in the consumption of CPU time. The VM technology will engage CPU for running bytecodes. Typical examples of time spent not running bytecode are graphical operations that make heavy use of native methods, and I/O operations such as reading and writing data to network sockets or database files.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; &lt;span style="color: rgb(204, 102, 0); font-weight: bold;"&gt;14. What is the  difference between interpreted code and compiled code?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;An interpreter produces a result from a program, while a compiler produces a program written in assembly language and in case of Java from bytecodes.The scripting languages like JavaScript,Python etc. require Interpreter to execute them.So a program written in scripting language will directly be executed with interpreter installed on that computer,if it is absent then this program will not execute.While in case of compiled code,an assembler or a virtual machine in case of Java is required to convert assembly level code or bytecodes into machine level instructions/commands.Generally, interpreted programs are slower than compiled programs, but are easier to debug and revise.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;&lt;span style="font-weight: bold;"&gt;15. Why Java based GUI intensive program has  performance issues?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;GUI intensive Java application mostly run  underlying OS specific native libraries which is time and more CPU cycles  consuming.&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(204, 102, 0);"&gt;&lt;br /&gt;The overall performance of a Java application depends on four  factors:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;The design of the application&lt;br /&gt;The speed at which the virtual  machine executes the Java bytecodes&lt;br /&gt;The speed at which the libraries that  perform basic functional tasks execute (in native code)&lt;br /&gt;The speed of the  underlying hardware and operating system&lt;br /&gt;The virtual machine is responsible for byte code execution, storage allocation, thread synchronization, etc. Running with the virtual machine are native code libraries that handle input and output through the operating system, especially graphics operations through the window system. Programs that spend significant portions of their time in those native code libraries will not see their performance on HotSpot improved as much as programs that spend most of their time executing byte codes.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;&lt;span style="font-weight: bold;"&gt;16. What is 64 bit Java ?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;A 64-bit version of Java has been available to Solaris SPARC users since the 1.4.0 release of J2SE. A 64-bit capable J2SE is an implementation of the Java SDK (and the JRE along with it) that runs in the 64-bit environment of a 64-bit OS on a 64-bit processor. The primary advantage of running Java in a 64-bit environment is the larger address space.This allows for a much larger Java heap size and an increased maximum number of Java Threads, which is needed for certain kinds of large or long-running applications. The primary complication in doing such a port is that the sizes of some native data types are changed. Not surprisingly the size of pointers is increased to 64 bits. On Solaris and most Unix platforms, the size of the C language long is also increased to 64 bits. Any native code in the 32-bit SDK implementation that relied on the old sizes of these data types is likely to require updating.Within the parts of the SDK written in Java things are simpler, since Java specifies the sizes of its primitive data types precisely. However even some Java code needs updating, such as when a Java int is used to store a value passed to it from a part of the implementation written in C.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(204, 102, 0);"&gt;&lt;span style="font-weight: bold;"&gt;17.  What is the difference between JVM and JRE?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;A Java Runtime Environment (JRE) is a prerequisite for running Java applications on any computer.A JRE contains a Java Virtual Machine(JVM),all standard,core java classes and runtime libraries. It does not contain any development tools such as compiler, debugger, etc. JDK(Java Development Kit) is a whole package required to Java Development which essentially contains JRE+JVM,and tools required to compile and debug,execute Java applications.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-5681704751770031491?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/5681704751770031491/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=5681704751770031491' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/5681704751770031491'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/5681704751770031491'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/03/jvm-faqs_3650.html' title='JVM FAQS'/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-1635226748815957808</id><published>2008-03-30T00:31:00.000-07:00</published><updated>2008-03-30T00:33:01.568-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JVM FAQs-1'/><title type='text'>JVM FAQS</title><content type='html'>&lt;span style="color: rgb(204, 102, 0); font-weight: bold;"&gt;6. What is Java class file's magic number?&lt;/span&gt;&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;A Magic Number of a class file is a unique identifier for tools to quickly differentiate class files from non class files.The first four bytes of each Java class file has the magic value as 0xCAFEBABE.And the answer to why this number,I do not actually know but there may be very few sensible and acceptable options possible constructed from letters A-F which can surely not be 'CAFEFACE' or 'FADECAFE'....&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 0); font-weight: bold;"&gt;7. How JVM performs Thread Synchronization?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;JVM associates a lock with an object or a class to achieve mutilthreading. A lock is like a token or privilege that only one thread can "possess" at any one time. When a thread wants to lock a particular object or class, it asks the JVM.JVM responds to thread with a lock maybe very soon, maybe later, or never. When the thread no longer needs the lock, it returns it to the JVM. If another thread has requested the same lock, the JVM passes the lock to that thread.If a thread has a lock,no other thread can access the locked data until the thread that owns the lock releases it.The JVM uses locks in conjunction with monitors.&lt;br /&gt;&lt;br /&gt;A monitor is basically a guardian in that it watches over a sequence of code, making sure only one thread at a time executes the code.Each monitor is associated with an object reference. It is the responsibility of monitor to watch an arriving thread must obtain a lock on the referenced object.When the thread leaves the block,it releases the lock on the associated object.A single thread is allowed to lock the same object multiple times.JVM maintains a count of the number of times the object has been locked. An unlocked object has a count of zero. When a thread acquires the lock for the first time, the count is incremented to one. Each time the thread acquires a lock on the same object, a count is incremented. Each time the thread releases the lock, the count is decremented. When the count reaches zero, the lock is released and made available to other threads.In Java language terminology, the coordination of multiple threads that must access shared data is called synchronization. The language provides two built-in ways to synchronize access to data: with synchronized statements or synchronized methods.The JVM does not use any special opcodes to invoke or return from synchronized methods. When the JVM resolves the symbolic reference to a method, it determines whether the method is synchronized. If it is, the JVM acquires a lock before invoking the method. For an instance method, the JVM acquires the lock associated with the object upon which the method is being invoked. For a class method, it acquires the lock associated with the class to which the method belongs. After a synchronized method completes, whether it completes by returning or by throwing an exception, the lock is released.Two opcodes, monitorenter and monitorexit are used by JVM for accomplishing this task.When monitorenter is encountered by the Java virtual machine, it acquires the lock for the object referred to by objectref on the stack. If the thread already owns the lock for that object, a count is incremented. Each time monitorexit is executed for the thread on the object, the count is decremented. When the count reaches zero, the monitor is released.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(204, 102, 0);"&gt;8.How JVM performs Garbage Collection?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Whenever a reference to an object on heap lies dangling or no longer in use then it becomes eligible for being garbage collected by JVM.JVM specifications do not force any specific kind of garbage collection algorithm though there are several algorithms like reference counting,tracing,compacting,copying,generational etc. in place.It is very important that garbage collection should be efficient and non interfering in execution of Java programs.There is a trade off between ease of implementation versus better performance while implementing garbage collection feature for a JVM.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;9. How to profile heap  usage?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Try using -Xaprof to get a profile of the allocations (objects and sizes) of your application.Also try -agentlib:hprof=heap=all (or other option, try -agentlib:hprof=help for a list).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;&lt;span style="font-weight: bold;"&gt;10. What will you do if VM exits while printing  "OutOfMemoryError" and increasing max heap size doesn't help?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;The Java HotSpot VM cannot expand its heap size if memory is completely allocated and no swap space is available. This can occur, for example, when several applications are running simultaneously. When this happens, the VM will exit after printing a message similar to the following.Exception java.lang.OutOfMemoryError: requested bytesIf you see this symptom, consider increasing the available swap space by allocating more of your disk for virtual memory and/or by limiting the number of applications you run simultaneously. You may also be able to avoid this problem by setting the command-line flags -Xmx and -Xms to the same value to prevent the VM from trying to expand the heap. Note that simply increasing the value of -Xmx will not help when no swap space is available.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-1635226748815957808?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/1635226748815957808/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=1635226748815957808' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/1635226748815957808'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/1635226748815957808'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/03/jvm-faqs_30.html' title='JVM FAQS'/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3801399119963252615.post-7898642946962255333</id><published>2008-03-30T00:25:00.000-07:00</published><updated>2008-03-30T00:30:59.646-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JVM FAQs'/><title type='text'>JVM FAQs</title><content type='html'>&lt;span style="font-size:180%;"&gt;&lt;strong style="font-weight: normal; font-style: italic;"&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 102);"&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;1.What is JVM?&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;A  Java Virtual Machine is a runtime environment required for execution of a Java  application.Every Java application runs inside a runtime instance of some  concrete implementation of abstract specifications of JVM.It is JVM which is  crux of 'platform independent' nature of the language.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 102);"&gt;&lt;span style="font-weight: bold;"&gt;2.What is a JVM consisted of?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Each  time a Java Application is executed then an instance of JVM ,responsible for its  running,is created.A JVM instance is described in terms of subsystems, memory  areas, data types, and instructions.The block diagram given below,depicts a view  of Internal Architecture of JVM :&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;&lt;span style="font-weight: bold;"&gt;3.What is a class loader and what is its  responsibilities?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;The Class loader is a subsystem of a JVM which is  responsible,predominantly for loading classes and interfaces in the system.Apart  from this,a class loader is responsible for the following  activities:-Verification of imported types(classes and interfaces)-Allocating  memory for class variables and initializing them to default values.Static fields  for a class are created and these are set to standard default values but they  are not explicitly initialized.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;The method tables are constructed for the  class.-&lt;/span&gt;Resolving symbolic references from type to direct references The class  loaders can be of two types: a bootstrap or primordial class loader and user  defined class loaderEach JVM has a bootstrap class loader which loads trusted  classes , including classes from Java API.JVM specs do not tell how to locate  these classes and is left to implementation designers.A Java application with  user defined class loader objects can customize class loading.These load  untrustworthy classes and not an intrinsic part of JVM.They are written in  Java,converted to class files and loaded into the JVM and installed like any  other objects.If you want to read this in more details then read Chapter 8,"The  Linking Model" of Inside Java 2 Virtual Machine by Bill Venners.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(204, 102, 0); font-weight: bold;"&gt;4.  &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;span style="color: rgb(204, 102, 0); font-weight: bold;"&gt;What is heap and  stack?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;The heap is the  part of memory of JVM where all objects reside.The stack is consisted of stack  frames.When a thread invokes a method,the JVM pushes a new frame onto that  thread's Java stack.Each stack frame is consisted of operand stack and the local  variable array.All arguments,local variables,intermediate computations and  return values if any are kept in these stack corresponding to the method  invoked.The stack frame on the top of the stack is called the active stack  frame,which is the current place of execution.When the method completes, the  virtual machine pops and discards the frame for that method.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;span style="font-weight: bold;"&gt;5. How is your Java program  executed inside JVM?&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;When JVM executes a Java application, a  runtime instance of JVM is born.This runtime instance invoke main() method of  Java application.The main() method of an application serves as the starting  point for that application's initial thread. The initial thread can in turn fire  off other threads.This thread has a program counter(PC) and Java stack.&lt;br /&gt;&lt;br /&gt;Whenever  main() method is invoked, a stack frame is pushed onto the stack,this then  becomes the active tack frame.The program counter in the new Java stack frame  will point to the beginning of the method.If there are more method invocations  within main() method then this process of pushing new stack frame onto the stack  for each method call is repeated as and when they are invoked.When a method  returns, the active frame is popped from the stack and the one below becomes the  active stack frame.The PC is set to the instruction after the method call and  the method continues.There is only one heap corresponding to an instance of JVM  and all objects created are stored here.This heap is shared by all threads  created in an application.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 153);"&gt;Inside the Java virtual machine, threads come in two  flavors:&lt;/span&gt; daemon and non- daemon. A daemon thread is ordinarily a thread used by  the virtual machine itself, such as a thread that performs garbage collection.  The application, however, can mark any threads it creates as daemon threads.&lt;br /&gt;&lt;a href="http://javarealtimequestions.blogspot.com"&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 153);"&gt;The  initial thread of an application-&lt;/span&gt;&lt;/a&gt;-the one that begins at main()--is a non-  daemon thread.A Java application continues to execute (the virtual machine  instance continues to live) as long as any non-daemon threads are still running.  When all non-daemon threads of a Java application terminate, the virtual machine  instance will exit. If permitted by the security manager, the application can  also cause its own demise by invoking the exit() method of class Runtime or  System.When main() returns,it terminates the application's only non-daemon  thread, which causes the virtual machine instance to exit.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3801399119963252615-7898642946962255333?l=javarealtimequestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javarealtimequestions.blogspot.com/feeds/7898642946962255333/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3801399119963252615&amp;postID=7898642946962255333' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/7898642946962255333'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3801399119963252615/posts/default/7898642946962255333'/><link rel='alternate' type='text/html' href='http://javarealtimequestions.blogspot.com/2008/03/jvm-faqs.html' title='JVM FAQs'/><author><name>Its For Techies</name><uri>http://www.blogger.com/profile/04854561330824512840</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
