<?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-2124855005622377541</id><updated>2012-01-05T00:51:19.827+05:30</updated><category term='Introduction'/><category term='Java Games'/><category term='Java Swings'/><category term='Video Tutorials'/><category term='Advanced Concepts'/><category term='Authors Update'/><category term='Java utilities'/><category term='Layout Managers'/><category term='Operators'/><category term='EBooks'/><category term='Control Statements'/><category term='Misc'/><category term='Threads'/><category term='Readers Appreciation/Affiliate Programme'/><category term='SCJP'/><category term='Installation help'/><category term='Interview Questions'/><category term='Access Control and Declaration'/><category term='Strings'/><category term='Exception Handling'/><category term='JDBC'/><category term='Object Oriented'/><title type='text'>JavaSync || Get Sync with Java</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.javasync.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://www.javasync.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default?start-index=101&amp;max-results=100'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>151</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-7838997366783341685</id><published>2012-01-04T02:20:00.004+05:30</published><updated>2012-01-05T00:51:19.836+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Authors Update'/><category scheme='http://www.blogger.com/atom/ns#' term='Interview Questions'/><category scheme='http://www.blogger.com/atom/ns#' term='Misc'/><title type='text'>uCertify PrepKit Review</title><content type='html'>&lt;div style="text-align: justify;"&gt;Again my trust on uCertify.com for preparation of proved worthy as I cleared the exam &lt;a href="http://www.ucertify.com/exams/Microsoft/70-433.html"&gt;M70-433 SQL Server 2008&lt;/a&gt;. Although .NET is basically not my technology but official assigments forced me to do it. Guess what I had the trust of uCertify to bank upon.&lt;br /&gt;&lt;br /&gt;I can summarize my experience with uCertify as follows:-&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;" I had registered for &lt;a href="http://www.ucertify.com/exams/Microsoft/70-433.html"&gt;M70-433 SQL Server 2008&lt;/a&gt;, Database Development certification. And came across uCertify.com which had helped me to clear the exam in past also. The tool from uCertify is amazing which helps us download the complete kit online and help to prepare through the series of tests.&lt;br /&gt;&lt;br /&gt;The study helper section gives a thorough explanation of all the topics of the exam. The material is amazing which covers all the dynamics of all the sections. Then the Learn and Practice section is best in class to prepare and learn for the actual certification with various Practice tests.Actally when you face the real exam you will be in your confort zonee to answer which makes job a lot easier, I would recommend people to log on to this website which truly is a blessing in disguise for people who are preparing for the technical exam. And I was able to clear the certification with ease."&lt;br /&gt;&lt;br /&gt;Take a trial today and I am sure you will not be disappointed.Check it out &lt;a href="http://www.ucertify.com/exams/Microsoft/70-433.html"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Thanks much for the help uCertify!!.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-7838997366783341685?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/7838997366783341685/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2012/01/ucertify-prepkit-review.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/7838997366783341685'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/7838997366783341685'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2012/01/ucertify-prepkit-review.html' title='uCertify PrepKit Review'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-4591202953292827463</id><published>2011-01-29T12:04:00.002+05:30</published><updated>2011-01-29T12:19:36.673+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='SCJP'/><category scheme='http://www.blogger.com/atom/ns#' term='Video Tutorials'/><category scheme='http://www.blogger.com/atom/ns#' term='Introduction'/><title type='text'>Java Video Tutorials || Learn Graphis,SCJP,JSP,Servlets etc</title><content type='html'>&lt;div style="text-align: justify;"&gt;Javasync brings Java video Tutorials for all the readers of Javasync.These video tutorials include tutorial of SCJP,Graphics,J2EE and JSP and Servlets.All these videos are of renowned Online Training providers.If you need any of the mentioned tutorials please click the link and download.All these downloads are exclusively brought to you by JavaSync.com.Please find the links below:-&lt;br /&gt;&lt;br /&gt;&lt;a style="font-weight: bold;" href="http://www.easy-share.com/1913702792/VTC%20Certified%20Programmer.iso"&gt;VTC Certified Java Programmer&lt;/a&gt;&lt;a style="font-weight: bold;" href="http://www.easy-share.com/1913702792/VTC%20Certified%20Programmer.iso"&gt; Video Tutorial&lt;/a&gt;&lt;br /&gt;&lt;a style="font-weight: bold;" href="http://www.easy-share.com/1913702793/VTC%20J2EE%20%28Java%202%20Enterprise%20Edition%29.iso"&gt;VTC J2EE (Java 2 Enterprise Edition)&lt;/a&gt;&lt;a style="font-weight: bold;" href="http://www.easy-share.com/1913702793/VTC%20J2EE%20%28Java%202%20Enterprise%20Edition%29.iso"&gt; Video Tutorial&lt;/a&gt;&lt;br /&gt;&lt;a style="font-weight: bold;" href="http://www.easy-share.com/1913702794/VTC%20Java%20Graphics.iso"&gt;VTC Java Graphis Video Tutorial&lt;/a&gt;&lt;br /&gt;&lt;a style="font-weight: bold;" href="http://www.easy-share.com/1913702795/VTC%20Java%20Introduction%20to%20the%20Java%20Programming%20Language.iso"&gt;VTC Introduction to Java Programming Video Tutorial&lt;/a&gt;&lt;br /&gt;&lt;a style="font-weight: bold;" href="http://www.easy-share.com/1913702796/VTC%20JSP%20and%20Servlets.iso"&gt;VTC JSP and Servlet Programming video tutorial&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-4591202953292827463?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/4591202953292827463/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2011/01/java-video-tutorials-learn.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/4591202953292827463'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/4591202953292827463'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2011/01/java-video-tutorials-learn.html' title='Java Video Tutorials || Learn Graphis,SCJP,JSP,Servlets etc'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-8817944194755822087</id><published>2010-11-15T00:40:00.002+05:30</published><updated>2010-11-15T01:07:22.091+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Access Control and Declaration'/><category scheme='http://www.blogger.com/atom/ns#' term='Introduction'/><category scheme='http://www.blogger.com/atom/ns#' term='Control Statements'/><title type='text'>Using Continue statement in Java</title><content type='html'>&lt;div style="text-align: justify;"&gt;Sometimes we want to force an early iteration of the loop.That is we might want to continue running the loop but escaping the execution for few conditions.To skip some iteration of the loop we can use continue statement.Its opposite of break.break lets us come out of loop and switch statements whereas continue keeps us inside with leaving some conditional iterations.&lt;br /&gt;&lt;br /&gt;For example if we want to print the odd numbers only then we may skip the iterations of even numbers.For this purpose we can use continue statement.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Let us consider below mentioned example:-&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;public&amp;nbsp;class&amp;nbsp;TestContinue{&lt;br /&gt; public&amp;nbsp;static&amp;nbsp;void&amp;nbsp;main(String&amp;nbsp;a[]){&lt;br /&gt;  for(int&amp;nbsp;i=0;i&amp;lt;10;i++){&lt;br /&gt;  if(i%2==0)&lt;br /&gt;  continue;&lt;br /&gt;  System.out.println(&amp;quot;The&amp;nbsp;Odd&amp;nbsp;Number&amp;nbsp;is&amp;nbsp;:-&amp;nbsp;&amp;quot;+i);&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-weight: bold;"&gt;NOTE:-&lt;/span&gt;continue statement can only be used inside a loop.It cannot be used inside switch or other blocks.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Couple of things about continue to Remember:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;1.In while and do-while loop a continue statement causes control to be transferred immediately to the conditional expression that controls the loop.&lt;br /&gt;&lt;br /&gt;2.In case of for loop ,continue statement takes the control first to the loop iteration and then to the conditional expression.All the statements written after continue statement are bypassed and loop continues the iteration.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Related Links:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a style="font-weight: bold;" href="http://www.javasync.com/2010/07/java-finalize-method.html"&gt;Java Finalize method&lt;/a&gt;&lt;br /&gt;&lt;a style="font-weight: bold;" href="http://www.javasync.com/2010/08/java-break-statement-using-break-to.html"&gt;Java Break statement&lt;/a&gt;&lt;br /&gt;&lt;a style="font-weight: bold;" href="http://www.javasync.com/2010/08/using-break-as-goto.html"&gt;How to use break as GOTO&lt;/a&gt;&lt;br /&gt;&lt;a style="font-weight: bold;" href="http://www.javasync.com/2010/11/how-to-use-java-command-line-arguments.html"&gt;How to use command line arguments &lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-8817944194755822087?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/8817944194755822087/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2010/11/using-continue-statement-in-java.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/8817944194755822087'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/8817944194755822087'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2010/11/using-continue-statement-in-java.html' title='Using Continue statement in Java'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-7117569877935362383</id><published>2010-11-14T18:14:00.005+05:30</published><updated>2010-11-15T00:40:05.362+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Introduction'/><title type='text'>How to use Java command Line Arguments</title><content type='html'>&lt;div style="text-align: justify;"&gt;Whenever we need to pass information into our program during execution ,we can use command line arguments.The Command line arguments are actually the arguments of main() method and are of String Format.Basically command line arguments are those directly follow program's name on the command prompt.As I told earlier that are none other than simple main() programs arguments.All the command line arguments are stored in the form of String.So it is advised to change to required type like integer,char etc before using them in the main program.&lt;br /&gt;&lt;br /&gt;Consider below Program as an Example:-&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;public class CommandArguments{&lt;br /&gt;&lt;br /&gt;public static void main(String a[]){&lt;br /&gt;&lt;br /&gt;int sum=Integer.parseInt(a[0])+Integer.parseInt(a[1]);&lt;br /&gt;&lt;br /&gt;System.out.println("The Sum is :- "+sum);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;As you can see that before adding the command arguments we typecasted them to Integer.This is an operation that is must before any numeric or other data type operation on command arguments.If we would not have typecasted the arguments then the result would be a concatenation of given values,this is because by default the command line arguments are stored as Strings.So it is must to typecast them before their use in application.Java Command Line arguments are mostly useful in command prompt based applications or text based applications.Where there is more of interaction between user and command prompt.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Reading Command Line Arguments:-&lt;/span&gt;&lt;br /&gt;We can read command line arguments using the array provided as an argument in main() method.All command line arguments gets stored in that String array.We can use the array reference to point to their values.Lets consider below example:-&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;public&amp;nbsp;class&amp;nbsp;CmdArg{&lt;br /&gt;&lt;br&gt;public&amp;nbsp;static&amp;nbsp;void&amp;nbsp;main(String&amp;nbsp;arg[]){&lt;br /&gt;  if(arg.length&amp;lt;2){&lt;br /&gt;  for(int&amp;nbsp;i=0;i&amp;lt;2;i++)&lt;br /&gt;  System.out.println(&amp;quot;Argument&amp;nbsp;is&amp;nbsp;:-&amp;nbsp;&amp;quot;+arg[i]) &lt;br /&gt;  }&lt;br /&gt;  else&lt;br /&gt;  System.out.prinltn(&amp;quot;Array&amp;nbsp;out&amp;nbsp;of&amp;nbsp;Bound&amp;quot;);&lt;br /&gt; }&lt;br /&gt;&lt;br&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Related Links:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/12/operator.html"&gt;&lt;span style="font-weight: bold;"&gt;The ? operator&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/12/dynamic-initialization.html"&gt;&lt;span style="font-weight: bold;"&gt;Dynamic Initialization&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2010/07/java-finalize-method.html"&gt;&lt;span style="font-weight: bold;"&gt;Java Finalize Methods&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a style="font-weight: bold;" href="http://www.javasync.com/2009/08/how-to-call-constructor-of-superclass.html"&gt;How to Constructors of Super class&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-7117569877935362383?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/7117569877935362383/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2010/11/how-to-use-java-command-line-arguments.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/7117569877935362383'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/7117569877935362383'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2010/11/how-to-use-java-command-line-arguments.html' title='How to use Java command Line Arguments'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-2974996535142391567</id><published>2010-08-15T10:58:00.003+05:30</published><updated>2010-08-15T11:08:42.226+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Operators'/><category scheme='http://www.blogger.com/atom/ns#' term='Introduction'/><category scheme='http://www.blogger.com/atom/ns#' term='Control Statements'/><title type='text'>Using Break as GOTO</title><content type='html'>&lt;div style="text-align: justify;"&gt;Break statement has following three uses:-&lt;br /&gt;&lt;br /&gt;1.Terminate the execution sequence in switch.&lt;br /&gt;2.Used to exit loops from anywhere.&lt;br /&gt;3.Break used as form of GOTO.&lt;br /&gt;&lt;br /&gt;GOTO statement as we know is not supported by Java.The reason being it provides control branching in unstructured and arbitrary manner.It is quite obvious from a C and C++ program that after reading through GOTO-ridden code is hard to understand the flow of program and also code is hard to maintain.GOTO also affects our performance considerations and compiler optimization.Indeed there are situations where GOTO is useful like if you are gone very deep inside loops then it would be easy to come out of those loops.&lt;br /&gt;&lt;br /&gt;Using this form of break ,you can break out of n number of blocks.In this form of break we can also specify that where execution will resume.Since this version of break uses labels we specify labels after break like below:&lt;br /&gt;   &lt;br /&gt;   &lt;span style="font-weight: bold;"&gt;break label ;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;label identifies a block of code where we want to take our program control.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;NOTE:-&lt;/span&gt;The program control resumes execution after the end of labelled block for example look at following :-&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;Class TestBreakGoto{&lt;br /&gt; public static void main(String a[]){&lt;br /&gt;   int i=0;&lt;br /&gt;   first:{&lt;br /&gt;     second : {&lt;br /&gt;       third : {&lt;br /&gt;        System.out.println("Started execution ");&lt;br /&gt;        if(i==0)&lt;br /&gt;        break second;&lt;br /&gt;        System.out.println("Exit Third");&lt;br /&gt;       }&lt;br /&gt;     System.out.println("Exit second");&lt;br /&gt;     }&lt;br /&gt;   System.out.prinltn("Out of second");&lt;br /&gt;   }&lt;br /&gt; }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;One important rule for break as GOTO is the labelled break statement must be inside the label block.That is look in above example we have three labels first,second and third.We can goto any label unit our break inside the innermost label otherwise it will give undefined label error.And also you must use higher blocks label to break from inner block.Otherwise the previously mentioned error will be encountered.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Useful Links:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/04/do-while-loop.html"&gt;&lt;span style="font-weight: bold;"&gt;do-while loop&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/04/while-loop.html"&gt;&lt;span style="font-weight: bold;"&gt;The while loop&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/03/ifelse-decision-construct.html"&gt;&lt;span style="font-weight: bold;"&gt;if-else construct&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/03/switch-construct-another-decision.html"&gt;&lt;span style="font-weight: bold;"&gt;The switch construct&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2010/08/java-break-statement-using-break-to.html"&gt;&lt;span style="font-weight: bold;"&gt;Java Break Statement&lt;/span&gt;&lt;/a&gt;&lt;a href="http://www.javasync.com/2009/04/do-while-loop.html"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-2974996535142391567?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/2974996535142391567/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2010/08/using-break-as-goto.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/2974996535142391567'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/2974996535142391567'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2010/08/using-break-as-goto.html' title='Using Break as GOTO'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-2085181429186938139</id><published>2010-08-14T20:43:00.004+05:30</published><updated>2010-08-14T21:07:07.623+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Introduction'/><category scheme='http://www.blogger.com/atom/ns#' term='Control Statements'/><title type='text'>Java Break statement || using break to exit a loop</title><content type='html'>&lt;div style="text-align: justify;"&gt;Java Provides 3 ways by which we can use the break statement:-&lt;br /&gt;&lt;br /&gt;1.It terminates switch statement&lt;br /&gt;2.It can be used to exit loop&lt;br /&gt;3.It can also be used  as GOTO statement.&lt;br /&gt;&lt;br /&gt;Here we will learn about  break statement used to exit a loop.&lt;br /&gt;&lt;br /&gt;Using break statement we can force the loop to terminate immediately ,bypassing all the conditional expressions and the execution resumes just after the next line following loop body.In other words we can say when a break statement is encountered inside the loop,the loop terminates immediately and program control resumes at the next statement following the loop.This concept would be more clear by understanding following example:-&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;class Looptest&lt;br /&gt;{&lt;br /&gt; public static void main(String a[])&lt;br /&gt; {&lt;br /&gt;  for(int i=0;i&amp;lt;10;i++)&lt;br /&gt;  {&lt;br /&gt;  if(i==5)&lt;br /&gt;  break;//terminated the loop after 5 iterations&lt;br /&gt;  System.out.println("i=  "+i);&lt;br /&gt;  }&lt;br /&gt; System.out.println("Loop complete after 5 iterations");&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The output of above is as expected 5 completed iterations&lt;br /&gt;&lt;br /&gt;i=  0&lt;br /&gt;i=  1&lt;br /&gt;i=  2&lt;br /&gt;i=  3&lt;br /&gt;i=  4&lt;br /&gt;Loop complete after 5 iterations&lt;br /&gt;&lt;br /&gt;As evident above in the example our for loop is designed to run 10 times but since during execution after 5 iterations the interpreter encounters break statement thus it exited current loop immediately and gives us output as above.Last statement in output indicates that loop executed successfully.There can be many uses of break like if we are running an infinite loop then if we wish to terminate loop at some point the it could be used .Also we can intentionally terminate the loop when some condition is satisfied.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;NOTE:-&lt;/span&gt;break statement can be used with any kind of loop be it a FOR LOOP,WHILE LOOP,DO WHILE LOOP.&lt;br /&gt;&lt;br /&gt;In case of nested loops the functionality remains same as for a single loop.That is if we put break in inner loop then the program control would be transferred to outer loop upon encountering the break statement.The point to remember is by placing break inside inner loop does not exit from all loops rather it transfers control to outer loop.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Useful Links:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a style="font-weight: bold;" href="http://www.javasync.com/2009/04/while-loop.html"&gt;The while loop&lt;/a&gt;&lt;/br&gt;&lt;br /&gt;&lt;a style="font-weight: bold;" href="http://www.javasync.com/2009/04/do-while-loop.html"&gt;The do-while loop&lt;/a&gt;&lt;/br&gt;&lt;br /&gt;&lt;a style="font-weight: bold;" href="http://www.javasync.com/2009/03/ifelse-decision-construct.html"&gt;if-else statement&lt;/a&gt;&lt;/br&gt;&lt;br /&gt;&lt;a style="font-weight: bold;" href="http://www.javasync.com/2009/04/if-else-if-control-statement.html"&gt;if-else-if statement&lt;/a&gt;&lt;/br&gt;&lt;br /&gt;&lt;a style="font-weight: bold;" href="http://www.javasync.com/2009/03/switch-construct-another-decision.html"&gt;The switch construct&lt;/a&gt;&lt;/br&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-2085181429186938139?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/2085181429186938139/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2010/08/java-break-statement-using-break-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/2085181429186938139'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/2085181429186938139'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2010/08/java-break-statement-using-break-to.html' title='Java Break statement || using break to exit a loop'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-2104597455902639657</id><published>2010-07-31T00:20:00.003+05:30</published><updated>2010-07-31T00:33:11.429+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Advanced Concepts'/><category scheme='http://www.blogger.com/atom/ns#' term='Misc'/><title type='text'>Java Finalize method</title><content type='html'>&lt;div style="text-align: justify;"&gt;Always in program that you make need some resources like file operations ,database connections .These resources are called non-Java resources and are need to freed once object associated with it is destroyed otherwise the heap size and connection pool keeps on growing.&lt;br /&gt;&lt;br /&gt;So when you do not need an object anymore do not forget to release the non-Java resource.&lt;span style="font-weight: bold;"&gt;finalize()&lt;/span&gt; method provides an automatic way of releasing such resources this mechanism is called &lt;span style="font-weight: bold;"&gt;finalization&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;By using &lt;span style="font-weight: bold;"&gt;finalization&lt;/span&gt;, you can define specific actions that will occur when an object is just about to be reclaimed by the garbage collector.To add a &lt;span style="font-weight: bold;"&gt;finalizer &lt;/span&gt;to your class ,what you need to do is just add a&lt;span style="font-weight: bold;"&gt; finalize() method&lt;/span&gt; to your class as follows:-&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 0);"&gt;public class FinalizeTest{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 0);"&gt;  protected void finalize(){&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 0);"&gt;     }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Inside this &lt;span style="font-weight: bold;"&gt;finalize()&lt;/span&gt; method you must specify the actions that are needed to be performed before an object is recycled.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;How finalize() method works:-&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Its important to note the concept of JVM and garbage collector.We knew that JVM does not guarantee that when garbage collector will work.It does not sweeps memory always an object goes outside the scope.So upon recycling the object in heap first garbage collector checks for associated &lt;span style="font-weight: bold;"&gt;finalize() method&lt;/span&gt; before recycling any object.&lt;br /&gt;You must have noticed the keyword protected mentioned before &lt;span style="font-weight: bold;"&gt;finalize &lt;/span&gt;it is put just to prevent access outside the class.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;NOTE:-&lt;/span&gt;finalize()&lt;/span&gt; is only called just prior to garbage collection to if any resource was left to be released .It is advised that you should not use &lt;span style="font-weight: bold;"&gt;finalize() method&lt;/span&gt; just to be on a safer side.Your program must release the resources in program itself .Since garbage collectors run is not guaranteed so&lt;span style="font-weight: bold;"&gt; finalize()&lt;/span&gt; execution will also not be guaranteed.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);font-size:100%;" &gt;IMPORTANT:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;1.Do not always rely on&lt;span style="font-weight: bold;"&gt; finalize()&lt;/span&gt; method.&lt;br /&gt;2.Like C++ has destructors &lt;span style="font-weight: bold;"&gt;finalize &lt;/span&gt;is just approximates the functionality of destructor.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-2104597455902639657?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/2104597455902639657/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2010/07/java-finalize-method.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/2104597455902639657'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/2104597455902639657'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2010/07/java-finalize-method.html' title='Java Finalize method'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-203988846748341333</id><published>2009-12-28T00:18:00.002+05:30</published><updated>2009-12-28T00:24:28.530+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Operators'/><title type='text'>The " ? " Operator</title><content type='html'>&lt;div style="text-align: justify;"&gt;Java includes a special Three-way(Ternary) operator that can replace certain types of if-then-else statements.These statements include assignment when certain conditions are fulfilled.This operator is " ? ".The working of " ? " operator is similar as in C,C++ and C#.The " ? " operator at first look might seem confusing but it is extremely useful in particular conditions when mastered.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;General Syntax :-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;expression 1 ? expression 2 : expression 3&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Here expression 1 can be any expression that evaluates to a Boolean value.If expression 1 is true then expression 2 is evaluated else expression 3 is evaluated.Both the expressions expression 1 and expression 2 must have a return type,they can never be void.Make it more clear by understanding below example.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Example:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;public class optest&lt;br /&gt;{&lt;br /&gt;   public static void main(String a[])&lt;br /&gt;   {&lt;br /&gt;       int ratio=0,num=20,denom=10;&lt;br /&gt;&lt;br /&gt;       /* The " ? " operator assignes 0 if condition denom==0 is true else it assigns num/denom to ratio if condituion is false*/&lt;br /&gt;&lt;br /&gt;       ratio=denom==0?0:num/denom;&lt;br /&gt;&lt;br /&gt;       System.out.println("The ratio is "+ratio);&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Output:-&lt;/span&gt;&lt;br /&gt;The ratio is 2&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Explanation:-&lt;/span&gt;When Java evaluates this assignment expression ,it first looks at the expression to the left of the question mark.If denom equals to zero then expression 2 between ? and : is evaluated else last expression is evaluated.The resultant is then assigned to the ratio variable used in expression 1.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Suggested Reading:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/02/arithmetic-operators.html"&gt;Arithmetic Operators&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/02/conditional-operator.html"&gt;Conditional Operators&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/02/logical-operators.html"&gt;Logical Operators&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/02/assignment-operators.html"&gt;Assignment Operators&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/02/relational-operator.html"&gt;Relational Operators&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/04/bitwise-logical-operators.html"&gt;Bitwise Logical Operators&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/05/java-practice-and-interview.html"&gt;Operators Practice Questions&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-203988846748341333?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/203988846748341333/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/12/operator.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/203988846748341333'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/203988846748341333'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/12/operator.html' title='The &quot; ? &quot; Operator'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-3782690332515781502</id><published>2009-12-23T22:35:00.003+05:30</published><updated>2009-12-28T00:27:16.961+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Access Control and Declaration'/><category scheme='http://www.blogger.com/atom/ns#' term='Introduction'/><title type='text'>Dynamic Initialization</title><content type='html'>&lt;div style="text-align: justify;"&gt;There are two types of variable mainly:-&lt;br /&gt;&lt;br /&gt;1.Instance Variable or Class Variable&lt;br /&gt;2.Local Variable or method variable&lt;br /&gt;&lt;br /&gt;Instance variable are initialized by JVM to their default values if not defined explicitly.Whereas the local variables needs to be defined each time time they are declared.But the local variables can be used to a greater effect by using the concept of dynamic initialization.&lt;br /&gt;&lt;br /&gt;Dynamic Initialization can be defined as the dynamic operation that allows variables to be initialized dynamically using any expression valid at the time of the variable declaration.&lt;br /&gt;&lt;br /&gt;Above definition implies that if you need a variable to store value of an expression you can use dynamic initialization.In which value of an expression is assigned to a variable.&lt;br /&gt;&lt;br /&gt;Dynamic Initialization can be clear by understanding following example:-&lt;br /&gt;&lt;br /&gt;class DynamicInit{&lt;br /&gt;  public static void main(String a[]){&lt;br /&gt;    int a=2;&lt;br /&gt;    int b=5;&lt;br /&gt;    int c=a*a+b*b;&lt;br /&gt;    System.out.println("value of c is "+c);&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Output :-&lt;/span&gt;The output of above program is&lt;br /&gt;value of c is 29&lt;br /&gt;&lt;br /&gt;In the above program we have three variables a,b and c.Each has been declared as ' int '.Variable a and b are declared and provided values on declaration whereas the variable c has been assigned a expression to evaluate and store its value.This is done through dynamic evaluation.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;NOTE:-&lt;/span&gt;One thing which has to be remembered is that the initialization expression may use any program construct including method calls,instance variables, literals etc.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Suggested Reading:-&lt;/span&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/04/class-declaration.html"&gt;&lt;br /&gt;Class Declaration&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/04/interface-declaration.html"&gt;Interface Declaration&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/06/local-variable-instance-variable-and.html"&gt;Local,instance variable and Shadowing&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/07/why-code-reuse-is-exclusive-feature-of.html"&gt;Code Reuse feature of Inheritance&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/06/why-java-classes-are-not-marked-final.html"&gt;Why Java classes are not final&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-3782690332515781502?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/3782690332515781502/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/12/dynamic-initialization.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/3782690332515781502'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/3782690332515781502'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/12/dynamic-initialization.html' title='Dynamic Initialization'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-3846213311782815831</id><published>2009-12-08T22:32:00.003+05:30</published><updated>2009-12-08T22:39:20.312+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Threads'/><title type='text'>Starting and running Multiple Threads</title><content type='html'>&lt;div style="text-align: justify;"&gt;In the previous tutorials about Threads we have learnt about the basics of Threads,How to create a Thread and also how to start a Thread.So far we have learnt how to start a single Thread but in this tutorial we will learn about how we can start and run Multiple Threads&lt;br /&gt;&lt;br /&gt;To start Multiple Threads  we use Runnable interface method which is best one.So we will implement the Runnable interface in our class and use the instance of our class to start Threads.To start a Thread we simply need a method start() to begin all the Threads.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Consider following example it will help you understand the Multiple Threads:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;class MultiTest implements Runnable&lt;br /&gt;{&lt;br /&gt; public void run()&lt;br /&gt; {&lt;br /&gt;  for(int i=0;i&lt;3;i++)&lt;br /&gt;   System.out.println("Run by " + Thread.currentThread().getName());&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public class ManyThreads&lt;br /&gt;{&lt;br /&gt; public static void main(String a[])&lt;br /&gt; {&lt;br /&gt;  MultiTest mt = new MultiTest();&lt;br /&gt;  Thread b = new Thread(mt);&lt;br /&gt;  Thread c = new Thread(mt);&lt;br /&gt;  c.setName("Programmer");&lt;br /&gt;  b.setName("Designer");&lt;br /&gt;  c.start();&lt;br /&gt;  b.start();&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Output:- &lt;/span&gt;When we executed the program with loop running 3 times then we got the output&lt;br /&gt;&lt;br /&gt;Run by Programmer&lt;br /&gt;Run by Programmer&lt;br /&gt;Run by Programmer&lt;br /&gt;Run by Designer&lt;br /&gt;Run by Designer&lt;br /&gt;Run by Designer&lt;br /&gt;&lt;br /&gt;but when we made loop to run for 100 times then it gave the output as&lt;br /&gt;&lt;br /&gt;Run by Designer&lt;br /&gt;Run by Programmer&lt;br /&gt;Run by Designer&lt;br /&gt;Run by Programmer&lt;br /&gt;Run by Designer&lt;br /&gt;Run by Programmer&lt;br /&gt;Run by Designer&lt;br /&gt;Run by Programmer&lt;br /&gt;......&lt;br /&gt;&lt;br /&gt;Well Friends one thing you need to know that you can never be certain of the output when many Threads are in operation.The bottomline is that the behaviour cannot be predicted and are also not guaranteed when multiple Threads are in execution.&lt;br /&gt;&lt;br /&gt;You must know that every Thread will start and come to finish but the order in which they begin execution is not always the order in the program.In the last example program you might not be able to figure it out but when you run the loop for a Thousand times then it will be clear that any order can be followed you can never be certain of the output.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Suggested Reading:-&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/09/java-thread-basics-learn-java-threads.html"&gt;Java Thread Basics&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/10/thread-life-cycle.html"&gt;Java Thread life cycle&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/10/ways-of-creating-threads-in-java.html"&gt;Ways of Thread creation&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/12/how-to-start-thread-in-java.html"&gt;How to Start Java Thread&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/11/main-thread-creation-and-handling.html"&gt;Main Thread creation and Handling&lt;/a&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/2124855005622377541-3846213311782815831?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/3846213311782815831/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/12/starting-and-running-multiple-threads.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/3846213311782815831'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/3846213311782815831'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/12/starting-and-running-multiple-threads.html' title='Starting and running Multiple Threads'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-7733860189463043816</id><published>2009-12-04T22:33:00.003+05:30</published><updated>2009-12-04T22:52:17.350+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Threads'/><title type='text'>How to Start a Thread in Java</title><content type='html'>&lt;div style="text-align: justify;"&gt;There are two ways of Thread creation either by implementing Runnable or extending the Thread class.In both the cases you need to start the thread for getting the functionality you need.So in order to start a thread we need a method which is &lt;span style="font-style: italic; color: rgb(51, 51, 255);"&gt;start()&lt;/span&gt; and it is invoked on Thread object.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;Remember:-&lt;/span&gt;&lt;span style="font-style: italic;"&gt;start()&lt;/span&gt; method is always invoked on Thread object to start a separate call stack of this thread,but if you call the &lt;span style="font-style: italic;"&gt;run()&lt;/span&gt; method on your Runnable object then it is simply a method call and cannot initiate a separate call stack.It also clears that You start a Thread not a Runnable.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;To start a new Thread in &lt;/span&gt;separate&lt;span style="font-weight: bold;"&gt; call stack use&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-weight: bold;"&gt;t.start() // where t is Thread object which is in execution.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;We have made a call to &lt;span style="font-style: italic;"&gt;start()&lt;/span&gt; method but know what happens behind the scenes there are three things happen:-&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;A new Thread in execution starts(in a new call stack).&lt;/li&gt;&lt;li&gt;The Thread moves from the new state to the runnable state.&lt;/li&gt;&lt;li&gt;Whenever the Thread gets a chance to execute then it goes to running state and the target &lt;span style="font-style: italic;"&gt;run()&lt;/span&gt; method will run.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;Consider the following example to understand how Threads are started and also you will come to know that invoking &lt;span style="font-style: italic;"&gt;run()&lt;/span&gt; method do works but it never ever initiate a new Thread or a separate call stack.&lt;br /&gt;&lt;br /&gt;class TestRunnable implements Runnable&lt;br /&gt;{&lt;br /&gt;    public void run()&lt;br /&gt;    {&lt;br /&gt;        for(int i=0;i&lt;5;i++)&lt;br /&gt;            System.out.println("In Runnable");&lt;br /&gt;    }&lt;br /&gt;   &lt;br /&gt;    public static void main(String a[])&lt;br /&gt;    {&lt;br /&gt;        Thread tr = Thread.currentThread();&lt;br /&gt;        System.out.println(tr);&lt;br /&gt;        TestRunnable r = new TestRunnable();&lt;br /&gt;        Thread t = new Thread(r);&lt;br /&gt;        System.out.println(r);&lt;br /&gt;        r.run();&lt;br /&gt;        System.out.println(t);&lt;br /&gt;        t.start();&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;OutPut:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Thread[main,5,main]&lt;br /&gt;TestRunnable@3e25a5&lt;br /&gt;In Runnable&lt;br /&gt;In Runnable&lt;br /&gt;Thread[First Thread,5,main]&lt;br /&gt;In Runnable&lt;br /&gt;In Runnable&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Explanations:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Here in above example there are two things we wanted to get you know that new Threads are started by calling &lt;span style="font-style: italic;"&gt;start()&lt;/span&gt; method on Thread object and Runnable can never ever start a new call stack.invoking &lt;span style="font-style: italic;"&gt;run()&lt;/span&gt; method simply works as another method invocation.&lt;br /&gt;Also you can see that when we tried to print the names of Threads then r comes with only as object names whereas the Thread t and tr have original Thread names.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Suggested Reading:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 12"&gt;&lt;meta name="Originator" content="Microsoft Word 12"&gt;&lt;link rel="File-List" href="file:///C:%5CUsers%5CJa%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml"&gt;&lt;link rel="themeData" href="file:///C:%5CUsers%5CJa%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx"&gt;&lt;link rel="colorSchemeMapping" href="file:///C:%5CUsers%5CJa%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:trackmoves/&gt;   &lt;w:trackformatting/&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:donotpromoteqf/&gt;   &lt;w:lidthemeother&gt;EN-US&lt;/w:LidThemeOther&gt;   &lt;w:lidthemeasian&gt;X-NONE&lt;/w:LidThemeAsian&gt;   &lt;w:lidthemecomplexscript&gt;X-NONE&lt;/w:LidThemeComplexScript&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;    &lt;w:splitpgbreakandparamark/&gt;    &lt;w:dontvertaligncellwithsp/&gt;    &lt;w:dontbreakconstrainedforcedtables/&gt;    &lt;w:dontvertalignintxbx/&gt;    &lt;w:word11kerningpairs/&gt;    &lt;w:cachedcolbalance/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;   &lt;m:mathpr&gt;    &lt;m:mathfont val="Cambria Math"&gt;    &lt;m:brkbin val="before"&gt;    &lt;m:brkbinsub val="--"&gt;    &lt;m:smallfrac val="off"&gt;    &lt;m:dispdef/&gt;    &lt;m:lmargin val="0"&gt;    &lt;m:rmargin val="0"&gt;    &lt;m:defjc val="centerGroup"&gt;    &lt;m:wrapindent val="1440"&gt;    &lt;m:intlim val="subSup"&gt;    &lt;m:narylim val="undOvr"&gt;   &lt;/m:mathPr&gt;&lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" defunhidewhenused="true" defsemihidden="true" defqformat="false" defpriority="99" latentstylecount="267"&gt;   &lt;w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Normal"&gt;   &lt;w:lsdexception locked="false" priority="9" semihidden="false" unhidewhenused="false" qformat="true" name="heading 1"&gt;   &lt;w:lsdexception locked="false" priority="9" qformat="true" name="heading 2"&gt;   &lt;w:lsdexception locked="false" priority="9" qformat="true" name="heading 3"&gt;   &lt;w:lsdexception locked="false" priority="9" qformat="true" name="heading 4"&gt;   &lt;w:lsdexception locked="false" priority="9" qformat="true" name="heading 5"&gt;   &lt;w:lsdexception locked="false" priority="9" qformat="true" name="heading 6"&gt;   &lt;w:lsdexception locked="false" priority="9" qformat="true" name="heading 7"&gt;   &lt;w:lsdexception locked="false" priority="9" qformat="true" name="heading 8"&gt;   &lt;w:lsdexception locked="false" priority="9" qformat="true" name="heading 9"&gt;   &lt;w:lsdexception locked="false" priority="39" name="toc 1"&gt;   &lt;w:lsdexception locked="false" priority="39" name="toc 2"&gt;   &lt;w:lsdexception locked="false" priority="39" name="toc 3"&gt;   &lt;w:lsdexception locked="false" priority="39" name="toc 4"&gt;   &lt;w:lsdexception locked="false" priority="39" name="toc 5"&gt;   &lt;w:lsdexception locked="false" priority="39" name="toc 6"&gt;   &lt;w:lsdexception locked="false" priority="39" name="toc 7"&gt;   &lt;w:lsdexception locked="false" priority="39" name="toc 8"&gt;   &lt;w:lsdexception locked="false" priority="39" name="toc 9"&gt;   &lt;w:lsdexception locked="false" priority="35" qformat="true" name="caption"&gt;   &lt;w:lsdexception locked="false" priority="10" semihidden="false" unhidewhenused="false" qformat="true" name="Title"&gt;   &lt;w:lsdexception locked="false" priority="1" name="Default Paragraph Font"&gt;   &lt;w:lsdexception locked="false" priority="11" semihidden="false" unhidewhenused="false" qformat="true" name="Subtitle"&gt;   &lt;w:lsdexception locked="false" priority="22" semihidden="false" unhidewhenused="false" qformat="true" name="Strong"&gt;   &lt;w:lsdexception locked="false" priority="20" semihidden="false" unhidewhenused="false" qformat="true" name="Emphasis"&gt;   &lt;w:lsdexception locked="false" priority="59" semihidden="false" unhidewhenused="false" name="Table Grid"&gt;   &lt;w:lsdexception locked="false" unhidewhenused="false" name="Placeholder Text"&gt;   &lt;w:lsdexception locked="false" priority="1" semihidden="false" unhidewhenused="false" qformat="true" name="No Spacing"&gt;   &lt;w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading"&gt;   &lt;w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List"&gt;   &lt;w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid"&gt;   &lt;w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1"&gt;   &lt;w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2"&gt;   &lt;w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1"&gt;   &lt;w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2"&gt;   &lt;w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1"&gt;   &lt;w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2"&gt;   &lt;w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3"&gt;   &lt;w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List"&gt;   &lt;w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading"&gt;   &lt;w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List"&gt;   &lt;w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid"&gt;   &lt;w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 1"&gt;   &lt;w:lsdexception locked="false" unhidewhenused="false" name="Revision"&gt;   &lt;w:lsdexception locked="false" priority="34" semihidden="false" unhidewhenused="false" qformat="true" name="List Paragraph"&gt;   &lt;w:lsdexception locked="false" priority="29" semihidden="false" unhidewhenused="false" qformat="true" name="Quote"&gt;   &lt;w:lsdexception locked="false" priority="30" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Quote"&gt;   &lt;w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="19" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Emphasis"&gt;   &lt;w:lsdexception locked="false" priority="21" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Emphasis"&gt;   &lt;w:lsdexception locked="false" priority="31" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Reference"&gt;   &lt;w:lsdexception locked="false" priority="32" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Reference"&gt;   &lt;w:lsdexception locked="false" priority="33" semihidden="false" unhidewhenused="false" qformat="true" name="Book Title"&gt;   &lt;w:lsdexception locked="false" priority="37" name="Bibliography"&gt;   &lt;w:lsdexception locked="false" priority="39" qformat="true" name="TOC Heading"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Font Definitions */  @font-face 	{font-family:"Cambria Math"; 	panose-1:2 4 5 3 5 4 6 3 2 4; 	mso-font-charset:0; 	mso-generic-font-family:roman; 	mso-font-pitch:variable; 	mso-font-signature:-1610611985 1107304683 0 0 159 0;} @font-face 	{font-family:Calibri; 	panose-1:2 15 5 2 2 2 4 3 2 4; 	mso-font-charset:0; 	mso-generic-font-family:swiss; 	mso-font-pitch:variable; 	mso-font-signature:-1610611985 1073750139 0 0 159 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-unhide:no; 	mso-style-qformat:yes; 	mso-style-parent:""; 	margin-top:0in; 	margin-right:0in; 	margin-bottom:10.0pt; 	margin-left:0in; 	line-height:115%; 	mso-pagination:widow-orphan; 	font-size:11.0pt; 	font-family:"Calibri","sans-serif"; 	mso-fareast-font-family:Calibri; 	mso-bidi-font-family:"Times New Roman";} a:link, span.MsoHyperlink 	{mso-style-priority:99; 	color:blue; 	text-decoration:underline; 	text-underline:single;} a:visited, span.MsoHyperlinkFollowed 	{mso-style-noshow:yes; 	mso-style-priority:99; 	color:purple; 	mso-themecolor:followedhyperlink; 	text-decoration:underline; 	text-underline:single;} .MsoChpDefault 	{mso-style-type:export-only; 	mso-default-props:yes; 	font-size:10.0pt; 	mso-ansi-font-size:10.0pt; 	mso-bidi-font-size:10.0pt; 	mso-ascii-font-family:Calibri; 	mso-fareast-font-family:Calibri; 	mso-hansi-font-family:Calibri;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.0in 1.0in 1.0in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-priority:99; 	mso-style-qformat:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:11.0pt; 	font-family:"Calibri","sans-serif"; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:"Times New Roman"; 	mso-fareast-theme-font:minor-fareast; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin; 	mso-bidi-font-family:"Times New Roman"; 	mso-bidi-theme-font:minor-bidi;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;a href="http://www.javasync.com/2009/10/thread-life-cycle.html"&gt;&lt;span style="text-decoration: underline;"&gt;&lt;span style="font-weight: bold;"&gt;Thread Life Cycle&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/09/java-thread-basics-learn-java-threads.html"&gt;&lt;span style="font-weight: bold;"&gt;Java Thread Basics&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/10/ways-of-creating-threads-in-java.html"&gt;&lt;span style="font-weight: bold;"&gt;Ways of creating a Thread&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/11/main-thread-creation-and-handling.html"&gt;&lt;span style="font-weight: bold;"&gt;Main Thread creation and handling&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-7733860189463043816?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/7733860189463043816/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/12/how-to-start-thread-in-java.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/7733860189463043816'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/7733860189463043816'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/12/how-to-start-thread-in-java.html' title='How to Start a Thread in Java'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-2381511328181040156</id><published>2009-12-02T22:46:00.003+05:30</published><updated>2009-12-02T23:15:36.940+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java Swings'/><title type='text'>How to use Swing Scroll Panes</title><content type='html'>&lt;div style="text-align: left;"&gt;A Scroll Pane is a component like JFrame or JPanel which is used to add other components but Scroll Pane has a Scroll Bar Associated with it which is a unique characteristic of this component Container.Scroll Panes are implemented in swing by JScrollPane class ,which extends JComponent class.Scroll Bar is either Vertical or Horizontal and they are used in Scroll Panes as needed.Like if you want to display the Scroll Bars all the time then you may use them always and also you might choose them to show up when container overflows.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Constructors used to create the Scroll Pane in Swings are :-&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;JScrollPane(Component cmp)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;JScrollPane(int vert, int horiz)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;JScrollPane(Component cmp, int vert, int horiz)&lt;/span&gt; &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;Remember:-&lt;/span&gt; A window can not be added to a Scroll Pane like JFrame cannot be added to a JScrollPane,but JPanel and other similar containers can be used which are not windows.&lt;br /&gt;&lt;br /&gt;In above constructors cmp is the component to be added on the ScrollPane.vert and horiz are the integer constants that are defined when the horizontal or vertical ScrollBars are shown in the ScrollPane.These constants are defined in ScrollPaneConstants interface.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Some example constants are :-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;1.VERTICAL_SCROLLBAR_ALWAYS (Always shows up vertical scrollbar)&lt;/span&gt; &lt;span style="color: rgb(51, 51, 255);"&gt;2.VERTICAL_SCROLLBAR_AS_NEEDED(Shows&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; up vertical Scrollbar when needed)&lt;/span&gt; &lt;span style="color: rgb(51, 51, 255);"&gt;3.HORIZONTAL_SCROLLBAR_ALWAYS (Always shows up horizontal scrollbar)&lt;/span&gt; &lt;span style="color: rgb(51, 51, 255);"&gt;4.HORIZONTAL_SCROLLBAR_AS_NEEDED(Shows up horizontal Scrollbar when needed)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Lets take a look at following example which lets you learn how to create and use JScrollPanes in your applications.&lt;br /&gt;&lt;br /&gt;import java.awt.*;&lt;br /&gt;import javax.swing.*;&lt;br /&gt;&lt;br /&gt;public class Scrollpanedemo extends JFrame&lt;br /&gt;{&lt;br /&gt;    public Scrollpanedemo()&lt;br /&gt;    {&lt;br /&gt;        JFrame frm = new JFrame("Scroll Pane demo");&lt;br /&gt;        JPanel panel = new JPanel();&lt;br /&gt;        panel.setLayout(new GridLayout(20,5));&lt;br /&gt;        for(int i=0;i&lt;100;i++)&lt;br /&gt;        {&lt;br /&gt;            panel.add(new JButton("Button no. " + (i+1)));&lt;br /&gt;        }&lt;br /&gt;        int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;&lt;br /&gt;        int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;&lt;br /&gt;        JScrollPane jsp = new JScrollPane(panel,v,h);&lt;br /&gt;        frm.getContentPane().add(jsp);&lt;br /&gt;        frm.setBounds(400,200,380,310);&lt;br /&gt;        frm.setVisible(true);&lt;br /&gt;    }&lt;br /&gt;   &lt;br /&gt;    public static void main(String a[])&lt;br /&gt;    {&lt;br /&gt;        new Scrollpanedemo();&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt; In the above example we create a frame and add a scrollpane over it.Then we create a panel which contains all the components and add it to the scrollpane.We have used the AS_NEEDED constants since we want to show that when our scrollpane overflows then the Scroll Bars shows up.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_1CvsF-MJpr4/SxajU9ZyPAI/AAAAAAAAASM/AqSFa2qWkYw/s1600-h/scroll+pane+demo.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 376px; height: 309px;" src="http://2.bp.blogspot.com/_1CvsF-MJpr4/SxajU9ZyPAI/AAAAAAAAASM/AqSFa2qWkYw/s400/scroll+pane+demo.jpg" alt="" id="BLOGGER_PHOTO_ID_5410691582807653378" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Suggested Reading :-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/04/using-jtextfield-and-jtextarea.html"&gt;Using JTextField and JTextArea&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/12/how-to-set-icons-on-swing-buttons.html"&gt;How to set Icons on Swing Buttons&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/04/how-to-create-check-boxes.html"&gt;How to Create and use checkboxes&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/07/using-tabbed-panes-in-java-swings.html"&gt;Using TabbedPanes in Java Swings&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/06/how-to-create-pop-up-menus-in-java_19.html"&gt;How to create popup menus in Java&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/04/dropdown-menu-or-choice-menu.html"&gt;Using DropDown menu or Choice menu&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-2381511328181040156?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/2381511328181040156/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/12/how-to-use-swing-scroll-panes.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/2381511328181040156'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/2381511328181040156'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/12/how-to-use-swing-scroll-panes.html' title='How to use Swing Scroll Panes'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_1CvsF-MJpr4/SxajU9ZyPAI/AAAAAAAAASM/AqSFa2qWkYw/s72-c/scroll+pane+demo.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-4195017338664156365</id><published>2009-12-02T01:44:00.004+05:30</published><updated>2009-12-02T02:24:57.431+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java Swings'/><title type='text'>How to Set Icons on Swing Buttons</title><content type='html'>&lt;div style="text-align: justify;"&gt;Swing Buttons provides many exclusive features that are not found in the Button class defined in the AWT package.Swing Buttons are the subclass of AbstractButton class,which extends JComponent.You can always associate an icon of your choice with a Swing Button.The Icons are set as program runs or set when some event is fired like button pressed.AbstractButton class contains many methods that allow you to control the behaviour of buttons,check boxes and Radio Buttons.There is the way you can set the icon on the swing button and it is through the JButton constructor.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;Despite of being set by constructor we can change the Icon of our Button whenever some action is fired or some condition is met.We can define different Icons when button :-&lt;br /&gt;&lt;br /&gt;1.is disabled&lt;br /&gt;2.is pressed&lt;br /&gt;3.is selected(for radio buttons etc)&lt;br /&gt;4.gets mouse focus&lt;br /&gt;&lt;br /&gt;JButton class is responsible for creation of all types of push buttons whether with icons or with text or both.The constructor used to create Button with Icon is&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;JButton(Icon i)&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;But if you also want to add Text with Icon then the constructor will be&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;JButton(Str&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;ing s ,Icon i)&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;In case you forgot to add text and you want to add text to the button whenever you want then use following method with JButton object.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;setText(S&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;tring str)&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;The following example will help in understanding how to set Icons and how you can change them according to your need.&lt;br /&gt;&lt;br /&gt;import javax.swing.*;&lt;br /&gt;import java.awt.event.*;&lt;br /&gt;import javax.swing.AbstractButton;&lt;br /&gt;&lt;br /&gt;public class ButtonImage extends JFrame implements ActionListener&lt;br /&gt;{&lt;br /&gt;   JButton button;&lt;br /&gt;   public ButtonImage()&lt;br /&gt;   {&lt;br /&gt;       JFrame frm = new JFrame("Icon on Button");&lt;br /&gt;       JPanel panel = new JPanel();&lt;br /&gt;       &lt;span style="font-style: italic; color: rgb(255, 0, 0);"&gt;ImageIcon imageicon = new ImageIcon("d:\\Anmtd_Feed.gif");&lt;/span&gt;&lt;br /&gt;       ImageIcon im = new ImageIcon("d:\\snap.jpg");&lt;br /&gt;       ImageIcon img = new ImageIcon("e:\\softwares\\ICON gallery\\Icons-1\\128 x 128\\apple1 (1).ico");&lt;br /&gt;       button = new JButton(imageicon);&lt;br /&gt;       button.setText("The Feed Icon");&lt;br /&gt;       panel.add(button);&lt;br /&gt;       button.addActionListener(this);&lt;br /&gt;       &lt;span style="font-style: italic; color: rgb(255, 0, 0);"&gt;button.setDisabledIcon(im);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(255, 0, 0);"&gt;        button.setRolloverIcon(img);&lt;/span&gt;&lt;br /&gt;       frm.getContentPane().add(panel);&lt;br /&gt;       frm.setVisible(true);&lt;br /&gt;       frm.setBounds(100,100,250,150);&lt;br /&gt;   }&lt;br /&gt; &lt;br /&gt;   public void actionPerformed(ActionEvent ae)&lt;br /&gt;   {&lt;br /&gt;       if (ae.getSource()==button)&lt;br /&gt;       {&lt;br /&gt;           button.setEnabled(false);&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt; &lt;br /&gt;   public static void main(String a[])&lt;br /&gt;   {&lt;br /&gt;       new ButtonImage();&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This is first output Frame.In example it is shown that how we can change the button image when the button is disabled or whenever mouse moves over it.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The method &lt;span style="font-style: italic;"&gt;setDisabledIcon(Icon i)&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;setRolloverIcon(Icon i) &lt;/span&gt;changes icons when the button is disabled or Hovered by Mouse respectively.ImageIcon is just a class which implements the Icon interface thus we are passing here ImageIcon as it is more convenient to use and most of all it implements Icon interface.&lt;br /&gt;&lt;/div&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_1CvsF-MJpr4/SxV_kS3C7AI/AAAAAAAAASE/KvKu4EnHkS8/s1600/icons+on+button.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 249px; height: 155px;" src="http://3.bp.blogspot.com/_1CvsF-MJpr4/SxV_kS3C7AI/AAAAAAAAASE/KvKu4EnHkS8/s320/icons+on+button.jpg" alt="" id="BLOGGER_PHOTO_ID_5410370788870253570" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;You can check on your own just change the Icon or Image paths then when the button is pressed the button is disabled and the image is changed once the button is disabled then there is no way you can change the icon of the button.That is why move mouse over the button first to test and then press the button.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Suggested Reading:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/03/setting-tooltip-and-icon.html"&gt;Setting Tooltip and Icon&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/07/using-tabbed-panes-in-java-swings.html"&gt;Using Tabbed Panes in Java Swings&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/07/adding-border-in-swing-application.html"&gt;Adding Borders to swing Components&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/03/setting-mnemonics-and-shortcut-keys.html"&gt;Setting Mnemonics and Shortcut keys&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&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/2124855005622377541-4195017338664156365?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/4195017338664156365/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/12/how-to-set-icons-on-swing-buttons.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/4195017338664156365'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/4195017338664156365'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/12/how-to-set-icons-on-swing-buttons.html' title='How to Set Icons on Swing Buttons'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_1CvsF-MJpr4/SxV_kS3C7AI/AAAAAAAAASE/KvKu4EnHkS8/s72-c/icons+on+button.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-7064275451259046899</id><published>2009-11-13T00:23:00.003+05:30</published><updated>2009-11-13T00:54:47.418+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Advanced Concepts'/><category scheme='http://www.blogger.com/atom/ns#' term='Misc'/><title type='text'>The Garbage Collector Approaches</title><content type='html'>&lt;div style="text-align: justify;"&gt;A &lt;a href="http://www.javasync.com/2009/11/java-garbage-collector.html"&gt;Garbage Collector &lt;/a&gt;must do two things:-&lt;br /&gt;&lt;br /&gt;1.Detect garbage objects&lt;br /&gt;2.Deallocate the memory of garbage objects and make it available for the program.&lt;br /&gt;&lt;br /&gt;There are four approaches that a garbage collector may adopt to detect the garbage objects.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;A) Reference -counting Collectors :-&lt;/span&gt;Reference counting garbage collectors keep a count of the references for the each live object.When an object is created ,the reference count of each object is set to one.When you reference the object ,the reference count is incremented by one.Similarly when a reference to an object is eliminated ,the reference count is decremented by one.An object which has reference count zero is a garbage object when the object is garbage collected ,the references of the object that it refers to are decremented.Therefore garbage collection of the one may lead to the creation of other garbage objects.This method can be executed in small parts with the program ,and the program need not to be interrupted for a long time .However ,there is an overhead of incrementing and decrementing the counter everytime something happens on the references side.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;B) Tracing Collectors :-&lt;/span&gt;In this technique ,a set of root is defined from where objects are traced .An object is reachable if there are objects that referenced and cannot ,therefore be accessed in the program.Objects that are reachable are marked .At the end of the trace ,all marked objects can be garbage collected.&lt;br /&gt;This is also known as the mark and sweep algorithm .The mark phase marks all the referenced objects .The sweep phase garbage collects the memory of unreachable and unreferenced objects.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;C) Compacting Collectors :-&lt;/span&gt;These collectors reduce the degree of &lt;a href="http://en.wikipedia.org/wiki/Fragmentation_%28computer%29"&gt;memory fragmentation&lt;/a&gt; by moving the all unused and free space on one side during garbage collection.The free memory is then available as one huge chunk.All references need to be shifted ,objects are the updated to refer to the new memory locations.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;D)Adaptive Collectors :-&lt;/span&gt;This algorithm makes the use of the fact that different garbage collectors algorithm works better in different situations .The adaptive algorithm monitors the situation and uses the garbage technique that best suits the situation .It may switch from one technique to the other according to the need.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Suggested Reading:-&lt;/span&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/11/java-sandbox.html"&gt;Java Sandbox&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/11/java-garbage-collector.html"&gt;Java Garbage Collectors&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/11/java-architecture-tradeoffs.html"&gt;Java Architectutre Tradeoffs&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/05/java-class-loader-architecture.html"&gt;Java class loader architecture&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-7064275451259046899?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/7064275451259046899/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/11/garbage-collector-approaches.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/7064275451259046899'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/7064275451259046899'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/11/garbage-collector-approaches.html' title='The Garbage Collector Approaches'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-8909833908313495605</id><published>2009-11-12T00:54:00.003+05:30</published><updated>2009-11-12T02:10:19.309+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Advanced Concepts'/><category scheme='http://www.blogger.com/atom/ns#' term='Misc'/><title type='text'>Java Garbage Collector</title><content type='html'>&lt;div style="text-align: justify;"&gt;It is known that you can allocate memory to an object or an array using the ' new ' operator.You cannot  however release the memory explicitly through your code.Garbage Collection is the process that automatically frees the memory of objects that are no longer in use.There is no specification of a technique for garbage collection and the implementation has been left to the vendors.&lt;br /&gt;&lt;br /&gt;When a programmer stops referencing an object ,the object is not required any more and becomes garbage.The space that is used by the object can be released and used for another objects.In native languages like C and C++ you can explicitly release the memory allocated to objects and data members.Since the native languages are so memory vulnerable that if programmer forgot to release the unused memory then he may run into all sorts of trouble.&lt;br /&gt;&lt;br /&gt;Java programming language was first of its kind which has the capability of automatic garbage collection.Garbage collection frees a programmer from the burden of freeing the memory time and time again.The garbage collector itself decides the objects that are of no use or no more referenced in the program and release the memory allocated to them.&lt;br /&gt;&lt;br /&gt;Garbage collection is one of the coolest feature Java has but the so called garbage collector has a huge problem that it does memory fragmentation.That's right he is not wise enough to make the decision to make memory the contiguous block of free addresses.What Garbage collector does is it sweeps all the unreferenced objects and makes them free but it leads to memory fragmentation in which there are space available between the chunks of data or vice verse.This memory fragmentation thing to an extent slows down the things a bit due to extra switching overhead.This burden counts to nothing if the application is small but if the application is huge then there is every possibility that your application being slow(&lt;a href="http://www.javasync.com/2009/11/java-architecture-tradeoffs.html"&gt;Read about Java architecture Trade offs&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;NOTE:-&lt;/span&gt;You can not enforce Garbage collector to run whenever you want .Rather it will run whenever it wants to.So each time you make a call to Garbage collector (&lt;span style="font-style: italic; color: rgb(51, 51, 255);"&gt;System.gc();&lt;/span&gt;) doesn't mean that you actually deallocated the memory from unused objects.It is like a Thread in execution when you are not certain about the output or steps to output.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Suggested Reading:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/11/java-sandbox.html"&gt;JAVA Sandbox&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/05/java-architecture.html"&gt;JAVA Architecture&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/09/memory-management-in-java.html"&gt;Memory Management in JAVA&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/05/java-class-loader-architecture.html"&gt;JAVA Class loader Architecture&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.javasync.com/2009/08/how-jvm-handles-strings-objects-and.html"&gt;How JVM Handles Strings and Literals&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-8909833908313495605?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/8909833908313495605/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/11/java-garbage-collector.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/8909833908313495605'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/8909833908313495605'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/11/java-garbage-collector.html' title='Java Garbage Collector'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-4214176052970800057</id><published>2009-11-07T22:30:00.005+05:30</published><updated>2009-11-10T22:38:12.114+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Misc'/><title type='text'>The Java SandBox</title><content type='html'>&lt;div style="text-align: justify;"&gt;The sandbox allows code to be downloaded from any source,but applies restriction on it upon execution.You can also say sandbox isolates particular code during execution to apply the restrictions.A Java sandbox is an area in memory outside which the Java program cannot make calls.This prevents Java programs from being able to call low level system functions that may cause data corruption or other damages.The Java sandbox is used by Java to discourage unsafe applets from accessing the resources.It applies several restrictions on the applets.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;The Java sandbox has three components:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;ol style="text-align: justify;"&gt;&lt;li&gt;The Bytecode verifier&lt;/li&gt;&lt;li&gt;The applet class loader&lt;/li&gt;&lt;li&gt;The security Manager&lt;/li&gt;&lt;/ol&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;The Bytecode Verifier&lt;/span&gt;&lt;br /&gt;The first level of Java security is the Java Bytecode verifier.The Bytecode is verified before it is allowed to run on the users machine.It is checked to authenticate its creation by the Java compiler ,and its access is restricted accordingly.The Bytecode verifier makes sure that the format of the bytecode fragment is correct.A built-in theorem is applied on each fragment to make sure that the bytecode does not violate access restrictions or try to access objects using incorrect information.The bytecode is checked in two phases.The first phase takes place when the bytecode is loaded.The verifier checks for the structure of the .class file.Phase two occurs when the bytecode is executed .The verifier checks the validity of the classes,the variables and the methods used in the program.This is done because Java programs are dynamically linked.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;The Applet class loader&lt;/span&gt;&lt;br /&gt;The second level of security defense id the Java Applet class loader.All Java objects belong to classes and the applet class loader determines how and when an applet is allowed to add classes to a running Java environment.It also makes sure that important parts of the Java Runtime Environment(JRE) are not replaced by any applet code.In a Java environment ,there can be many active class loaders and at the same time ,each class loader can create its own runtime environment .The applet class loader loads all the applets and their references.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;The Security Manager&lt;/span&gt;&lt;br /&gt;The third level ,and a very important part of the Java sandbox ,is the security manager .The security Manager defines the boundaries of the sandbox.The Java API refers to the security manager before it allows any access to the resource.It restricts the way in which the applet uses visible interfaces.While loading classes,the class loader always compiles with the security manager's decision .Built -in classes are given preference over classes loaded over the net.The sandbox can be used to run untrusted code on the users machine.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;NOTE:-&lt;/span&gt;A Java protected domain is an extension of the Java sandbox in a file system.Java protected domains enable the use of permission or use a default setting for providing access to function calls outside the sandbox.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Suggested Reading:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://javasync.com/2009/05/java-architecture.html"&gt;Java Architecture&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javasync.com/2009/11/java-architecture-tradeoffs.html"&gt;Java Architecture trade offs&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javasync.com/2009/05/java-architecture-features-and.html"&gt;Java Architecture Features&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javasync.com/2009/05/java-class-loader-architecture.html"&gt;Java class loader architecture&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javasync.com/2009/09/memory-management-in-java.html"&gt;Memory management in Java&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-4214176052970800057?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/4214176052970800057/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/11/java-sandbox.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/4214176052970800057'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/4214176052970800057'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/11/java-sandbox.html' title='The Java SandBox'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-4478454694221959249</id><published>2009-11-07T22:17:00.003+05:30</published><updated>2009-11-13T00:58:20.152+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Advanced Concepts'/><category scheme='http://www.blogger.com/atom/ns#' term='Misc'/><title type='text'>The Java Architecture TradeOffs</title><content type='html'>&lt;div style="text-align: justify;"&gt;Java is a common programming language and the basic purpose of Java is to develop network programs.Now it is also used to develop system software's and programs too.The Java architecture has trade off between speed and efficiency.In case of Java the efficiency beats the speed the execution and rightly so because there are issues which are needed to be addressed in order to become a sound programming language.&lt;br /&gt;&lt;br /&gt;Java has some incredible features which are not in any programming language.But these features comes at some price.The features offered by Java makes Java programs slow in execution.Most of you must not be aware of the fact that Java programs are slower than C++ programs.There are some reasons which states that Java programs are slow in comparison to C++ or C.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;1.&lt;/span&gt;Java ByteCode is slow in interpreting than executing the machine code of C++.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;2.&lt;/span&gt;Checks on array bounds are made on each and every array.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;3.&lt;/span&gt;All the variables are checked for type at RunTime.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;4.&lt;/span&gt;Java programs are dynamically linked and therefore,the programs has to wait for bytecode to get downloaded.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;5.&lt;/span&gt;Java checks for null values for all the objects at runtime.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;6.&lt;/span&gt;The garbage collector is not very efficient in sweeping the unused space.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;7.&lt;/span&gt;There are also no concept of pointers involved in Java.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;8.&lt;/span&gt;The extra security checks makes Java more slow in executing(interpreting) the programs(ex:&lt;a href="http://www.javasync.com/2009/11/java-sandbox.html"&gt;Java Sandbox&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;With so many security and value based checks the Java is indeed slow but it provides more security which is not provided by any other language.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Suggested Reading:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/05/java-architecture.html"&gt;Java Architecture&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/05/java-architecture-features-and.html"&gt;Java Architecture Features&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/05/java-class-loader-architecture.html"&gt;Java Class loader Architecture&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/09/memory-management-in-java.html"&gt;Memory Management in Java&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/10/how-to-executing-system-programs-from.html"&gt;How to Execute System Programs&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-4478454694221959249?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/4478454694221959249/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/11/java-architecture-tradeoffs.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/4478454694221959249'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/4478454694221959249'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/11/java-architecture-tradeoffs.html' title='The Java Architecture TradeOffs'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-7841390666420588801</id><published>2009-11-03T23:13:00.003+05:30</published><updated>2009-11-03T23:29:24.455+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Threads'/><title type='text'>The main Thread - Creation and Handling</title><content type='html'>&lt;div style="text-align: justify;"&gt;Every Java program when started,one thread begins running immediately.This is called the main Thread.The reason it is called main Thread is that it starts execution when our program begins.There are two basic characteristics of main Thread are:-&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;1.It is the Thread from which other threads are generated.&lt;br /&gt;2.It finishes last to perform various tasks which are related to resources.&lt;br /&gt;&lt;br /&gt;Main Thread works simply like a method ,from which new calls to Threads are generated and Threads are called in the call stack of main Thread.All called or created Threads must finish before than main Thread.It works simply as a method call.The main Thread finishes when all other Threads are returned.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_1CvsF-MJpr4/SvBuoaoh4YI/AAAAAAAAARw/FzT3Wybt2yQ/s1600-h/main+thread.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 257px;" src="http://1.bp.blogspot.com/_1CvsF-MJpr4/SvBuoaoh4YI/AAAAAAAAARw/FzT3Wybt2yQ/s400/main+thread.jpg" alt="" id="BLOGGER_PHOTO_ID_5399937593840361858" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;NOTE:-&lt;/span&gt;Every Thread has its own seperate call stack to store its own variable and place mathod calls.The main method calls executes other Threads just in the same fashion as the main() method does.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Remember:-&lt;/span&gt;Each and every Java program when starts a main Thread.Keep it in your memory.&lt;br /&gt;&lt;br /&gt;Main Thread is automatically created by the JVM when the program is started but the fact is you can control your main Thread too just like any other Thread.&lt;br /&gt;&lt;br /&gt;You can craete instance of main Thread as follows:-&lt;br /&gt;&lt;br /&gt;? you can use the currentThread() method which is public and static.&lt;br /&gt;i.e.&lt;br /&gt;public static Thread currentThread()&lt;br /&gt;This method as the name suggests returns the reference to the Thread in which it is invoked.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Example:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;class Threadex{&lt;br /&gt;public static void main(String a[]){&lt;br /&gt;Thread t = Thread.currentThread();&lt;br /&gt;System.out.println("Current Thread is "+t);&lt;br /&gt;t.setName("Main Thread");&lt;br /&gt;System.out.println("Current Thread is "+t);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;in the output you will notice that the name of Thread is chnaged to Main Thread.&lt;br /&gt;setName() method is used to set the name of current Thread.The other same method is getName() which returns the name of the Thread.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Suggetsed Reading:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a style="font-weight: bold;" href="http://javatutorialsworld.blogspot.com/2009/10/ways-of-creating-threads-in-java.html"&gt;Ways of creating Threads&lt;/a&gt;&lt;br /&gt;&lt;a style="font-weight: bold;" href="http://javatutorialsworld.blogspot.com/2009/09/java-thread-basics-learn-java-threads.html"&gt;Java Thread Basics&lt;/a&gt;&lt;br /&gt;&lt;a style="font-weight: bold;" href="http://javatutorialsworld.blogspot.com/2009/10/thread-life-cycle.html"&gt;Thread life Cycle&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-7841390666420588801?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/7841390666420588801/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/11/main-thread-creation-and-handling.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/7841390666420588801'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/7841390666420588801'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/11/main-thread-creation-and-handling.html' title='The main Thread - Creation and Handling'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_1CvsF-MJpr4/SvBuoaoh4YI/AAAAAAAAARw/FzT3Wybt2yQ/s72-c/main+thread.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-4859387062369084173</id><published>2009-10-31T22:40:00.003+05:30</published><updated>2009-10-31T23:38:10.523+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Threads'/><title type='text'>ways of creating Threads in Java Program</title><content type='html'>&lt;div style="text-align: justify;"&gt;Multi threaded applications are the base of all modern computing applications.Threads save lot of time and keeps utilizing computing resources to the optimum levels.It is important for a Java developer to understand how to create Threads.&lt;br /&gt;There are two ways by which you can create Threads:-&lt;br /&gt;&lt;br /&gt;1.By extending Thread class&lt;br /&gt;2.By implementing Runnable Interface&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Creating Threads by extending Thread class&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The &lt;span style="font-style: italic;"&gt;java.lang.Thread&lt;/span&gt; class is used to construct and access individual threads in a multi threaded application.Thread class supports many methods that obtain information about the activities of a Thread,set and check properties of a Thread and cause a Thread to wait,be interrupted or be destroyed.Extending the Thread class enables your class to run in a separate new call stack.Just like the main Thread.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Example:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;class MThread extends Thread{&lt;br /&gt;&lt;br /&gt;// code goes here&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Creating Threads by Implementing Runnable Interface&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Extending Thread class for creating Threads is no doubt a bad OO Practice because since Java doesn't support multiple Inheritance,if you extend one class and also need to incorporate features of Other class then what you are supposed to do?&lt;br /&gt;Let us Consider a scenario where we want to create an Applet which has some Thread capabilities,now if you extend Thread then from where applet methods come from and if you extend Applet class then from where the Thread capabilities come from.This is the reason why the Java creators decided to give some extra flexibility by providing us with Runnable Interface which consists of only a single method called &lt;span style="font-style: italic;"&gt;run()&lt;/span&gt;.All the Thread related code goes inside &lt;span style="font-style: italic;"&gt;run() &lt;/span&gt;method and Thread &lt;span style="font-style: italic;"&gt;run() &lt;/span&gt;method is invoked when we call &lt;span style="font-style: italic;"&gt;start()&lt;/span&gt; method on Thread object.This &lt;span style="font-style: italic;"&gt;run()&lt;/span&gt; method starts a new call stack in this case but it has to be invoked to get things working.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Example:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;class MThread implements Runnable{&lt;br /&gt;&lt;br /&gt;public void run(){&lt;br /&gt;//Thread stuff goes here&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;NOTE:-&lt;/span&gt;Consider the context of Applet and Thread scenario ,when you use Runnable interface,the Thread becomes a part of the Applet and grants full access to its data members and methods.The subclass of Thread is limited to access the public components of any class.Therefore ,when the Thread depends strongly on the components of Applet class use Runnable Interface.Use this concept in general terms not only for Applet context.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Suggested Reading:-&lt;/span&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/09/java-thread-basics-learn-java-threads.html"&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Java Thread Basics&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/10/thread-life-cycle.html"&gt;&lt;span style="font-weight: bold;"&gt;Thread Life Cycle&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-4859387062369084173?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/4859387062369084173/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/10/ways-of-creating-threads-in-java.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/4859387062369084173'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/4859387062369084173'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/10/ways-of-creating-threads-in-java.html' title='ways of creating Threads in Java Program'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-4097720181753318189</id><published>2009-10-29T22:28:00.006+05:30</published><updated>2009-10-31T23:40:47.860+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Threads'/><title type='text'>Thread Life Cycle</title><content type='html'>A Thread encounters four states during its life time which are:-&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;1.New Thread(Init)&lt;br /&gt;2.Runnable&lt;br /&gt;3.Waiting/Blocked/Ready&lt;br /&gt;4.Terminated&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_1CvsF-MJpr4/SunOhDfoWyI/AAAAAAAAARo/cKYGbDOUzRs/s1600-h/Thread+life+cycle.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 123px;" src="http://4.bp.blogspot.com/_1CvsF-MJpr4/SunOhDfoWyI/AAAAAAAAARo/cKYGbDOUzRs/s400/Thread+life+cycle.png" alt="" id="BLOGGER_PHOTO_ID_5398072695649229602" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;In order to get to the roots of the threads you have to understand all the states of Threads life cycle.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;1.New Thread(Init)&lt;/span&gt; :-  Whenever an instance of Thread is created it enters the new Thread state.It is not mandatory for you to always extend the Thread class.In order to create a new Thread instance there is also another convenient option which is implementing the Runnable interface.Once a new Thread is created you can start the thread.Consider following example:-&lt;br /&gt;&lt;br /&gt;Creating a new Thread&lt;br /&gt;&lt;br /&gt;Thread NThread = new Thread(this);&lt;br /&gt;The above expression creates an empty Thread with no resources allocated to it.The NThread can be started by using the &lt;span style="font-style: italic;"&gt;start()&lt;/span&gt; method on the Thread object.&lt;br /&gt;&lt;br /&gt;i.e.   NThread.start();&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;2.Runnable&lt;/span&gt;:-  When the &lt;span style="font-style: italic;"&gt;start()&lt;/span&gt; method is invoked,the Thread enters Runnable state.Thread invokes &lt;span style="font-style: italic;"&gt;start()&lt;/span&gt; method doesn't mean that the Thread will go on to execute straight away.It may begin execution but its not mandatory,it will begin executing when the processor becomes idle.If processor is idle then the Thread will start executing straight away.The processor maintains a queue to know about which Thread is coming next.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;NOTE:-&lt;/span&gt; Invoking &lt;span style="font-style: italic;"&gt;start()&lt;/span&gt; method does not guarantee about the execution of the Thread,Thread may begin execution immediately or it may keep you waiting for a long time anything can happen,but the bottom line is "In case of Threads Nothing is Guaranteed" until and unless you make them do guaranteed behaviour.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;3.Waiting/Blocked/Ready&lt;/span&gt; :-  During this state the Threads are remained in a pool .This Thread pool contains Threads which are either blocked by some IO or resource or waiting for their turn.&lt;span style="font-style: italic;"&gt;sleep(),wait()&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;notify()&lt;/span&gt; are a few methods which put threads into this state.Once again I will say that the order in which the Threads are waiting does not holds any importance in context to their execution because selection of Thread to execute is totally based on the decision of the underlying OS.That is why nothing is guaranteed in Thread world!!!!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Terminated&lt;/span&gt;:- A Thread can be either killed or die naturally .When the thread completes its &lt;span style="font-style: italic;"&gt;run()&lt;/span&gt; method then it dies naturally,but if you want to kill a Thread the assign null to its object.The best way to check whether the Thread is dead or alive is to use i&lt;span style="font-style: italic;"&gt;sAlive()&lt;/span&gt; method.It returns state dead or alive.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Important&lt;/span&gt;:-  If a Thread is once dead or terminated then it cannot be restarted.You can also not call the methods of a dead Thread.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;NOTE:-&lt;/span&gt;  "  IN THE WORLD OF THREAD NOTHING IS GUARANTEED!!!!!!" but you can assume you will learn the behaviours of Threads.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Suggested Reading:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a style="font-weight: bold;" href="http://javatutorialsworld.blogspot.com/2009/09/java-thread-basics-learn-java-threads.html"&gt;Java Thread Basics&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/10/ways-of-creating-threads-in-java.html"&gt;&lt;span style="font-weight: bold;"&gt;Ways of creating Threads&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-4097720181753318189?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/4097720181753318189/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/10/thread-life-cycle.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/4097720181753318189'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/4097720181753318189'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/10/thread-life-cycle.html' title='Thread Life Cycle'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_1CvsF-MJpr4/SunOhDfoWyI/AAAAAAAAARo/cKYGbDOUzRs/s72-c/Thread+life+cycle.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-6320939390653074649</id><published>2009-10-17T00:00:00.003+05:30</published><updated>2009-10-17T00:52:43.234+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Misc'/><category scheme='http://www.blogger.com/atom/ns#' term='Java utilities'/><title type='text'>How to Compute Program Execution Time in Java</title><content type='html'>&lt;div style="text-align: justify;"&gt;I don't think you need to compute your program execution time everytime you execute your program but sometimes when you need to compare performance then it becomes necessary to compute the execution time.When you need to compare two programming styles then you may consider calculating the time required by each program program to complete the task ,lesser the time the more fast the program is.The fact is since the processors are too fast now days and due to even faster RAM's the million of loops complete within split of a second.So there is need to calculate speed till  the precision of 1000th of a second.Here in order to compute the time we will use the &lt;span style="font-weight: bold; font-style: italic;"&gt;currentTimeMillis()&lt;/span&gt; method of &lt;span style="font-weight: bold;"&gt;System&lt;/span&gt; class which returns current time of your computer system.There is a very simple logic which is implemented to create this utility.&lt;br /&gt;&lt;br /&gt;In the following example we will compute the program execution time of &lt;span style="font-weight: bold; font-style: italic;"&gt;main()&lt;/span&gt; method.As we enter the &lt;span style="font-weight: bold; font-style: italic;"&gt;main()&lt;/span&gt; method we will compute the system time and after implementation of programming logic or business logic we will again compute the system time.Remember the system time is returned as long in milliseconds.So now you have  two values first when we started our &lt;span style="font-weight: bold; font-style: italic;"&gt;main()&lt;/span&gt; method and second just  before exiting the main.We assume here is that the program exits immediately after getting second value.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Source code and Example:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;// Method to be used &lt;span style="font-weight: bold; font-style: italic;"&gt;System.currentTimeMillis()&lt;/span&gt;&lt;br /&gt;//This method returns&lt;span style="font-weight: bold; font-style: italic;"&gt; long &lt;/span&gt;values.&lt;br /&gt;&lt;br /&gt;class timecalc&lt;br /&gt;{&lt;br /&gt;public static void main(String a[]){&lt;br /&gt;long time = System.currentTimeMillis();&lt;br /&gt;System.out.println(time);&lt;br /&gt;for(int i=0;i&lt;5000000;i++)&lt;br /&gt;{&lt;br /&gt;     for(int j=0;j&lt;1000;j++);&lt;br /&gt;}&lt;br /&gt;long end = System.currentTimeMillis();&lt;br /&gt;System.out.println(end-time);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Output :-&lt;/span&gt;&lt;br /&gt;3782&lt;br /&gt;Remember the output may vary according to your computers speed.speed is affected by various factors like RAM,processor speed,running programs,cache etc.&lt;br /&gt;&lt;br /&gt;Here in above example I have taken such long loop because just to calculate the time difference and to just give you a demo how things goes.When you compute for several hundreds of values then it is possible that it might return 0.Everytime your run your program and you are expected to get a different value.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Suggested Reading :-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a style="color: rgb(255, 0, 0);" href="http://javatutorialsworld.blogspot.com/2009/05/compute-any-day-in-calendar-using.html"&gt;Compute any day and date in calendar&lt;/a&gt;&lt;br /&gt;&lt;a style="color: rgb(255, 0, 0);" href="http://javatutorialsworld.blogspot.com/2009/05/datetime-in-your-specified-format.html"&gt;Get date and time in your specified format&lt;/a&gt;&lt;br /&gt;&lt;a style="color: rgb(255, 0, 0);" href="http://javatutorialsworld.blogspot.com/2009/10/how-to-executing-system-programs-from.html"&gt;How to execute system programs from your programs?&lt;/a&gt;&lt;br /&gt;&lt;a style="color: rgb(255, 0, 0);" href="http://javatutorialsworld.blogspot.com/2009/09/most-common-scoping-errors-commited-by.html"&gt;Most common scoping errors commited by Novice programmers&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-6320939390653074649?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/6320939390653074649/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/10/how-to-compute-program-execution-time.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/6320939390653074649'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/6320939390653074649'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/10/how-to-compute-program-execution-time.html' title='How to Compute Program Execution Time in Java'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-2434988034876031665</id><published>2009-10-15T01:21:00.004+05:30</published><updated>2009-10-15T02:11:33.323+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Interview Questions'/><category scheme='http://www.blogger.com/atom/ns#' term='Misc'/><title type='text'>Core Java Very basic Questions || Important Core Java Questions</title><content type='html'>&lt;div style="text-align: justify;"&gt;Java programming language is very vast programming language,even I must say each and every programming language is very vast.Understanding Java programming language and applying its concept needs the knowledge and skills of Java programming language.I have gone through various important questions during my ride to SCJP.So I have prepared a list of such important questions of Java programming language which will help you not only in understanding the topic but also If you are preparing for SCJP they will be helpful.&lt;br /&gt;&lt;br /&gt;Try to answer these questions on your own but if you cannot recall the concept go refer book,any core Java book will do.&lt;br /&gt;&lt;br /&gt;Important Core Java Questions :-&lt;br /&gt;&lt;br /&gt;1.How many access modifiers a class can use and which are they?&lt;br /&gt;2.What are the Instance variables?&lt;br /&gt;3.What are local variables?&lt;br /&gt;4.What is the default access modifier and how it is different from protected access modifier?&lt;br /&gt;5.Can you ever mark a class as final?&lt;br /&gt;6.Is it true that we can use abstract and final both on same time and same Java entity?&lt;br /&gt;7.What is the IS-A and HAS-A relationship in Java?&lt;br /&gt;8.What is multiple inheritance and how you can implement multiple inheritance in Java?&lt;br /&gt;9.What is the size of compiler generated Java Bytecode?&lt;br /&gt;10.Does Interfaces follow the Inheritance?&lt;br /&gt;11.A subclass can inherit the private member of superclass is this statement true,give reason?&lt;br /&gt;12.What is the bit depth of Boolean variable in Java?&lt;br /&gt;13.What will happen if finally block itself generates an Exception?&lt;br /&gt;14.What is exception propagation?&lt;br /&gt;15.How Inheritance is affected by object serialization?&lt;br /&gt;&lt;br /&gt;These are a few questions which I thought as Important.Further there are some references I am giving in order to solve these questions.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Suggested Reading:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/09/exception-propagation-propagation-of.html"&gt;&lt;span style="font-weight: bold;"&gt;Exception Propagation&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/07/is-and-has-relationship-every-thing.html"&gt;&lt;span style="font-weight: bold;"&gt;IS-A and HAS-A relationship&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/07/interfacesrules-and-explanations.html"&gt;&lt;span style="font-weight: bold;"&gt;Interfaces rules and Explanations&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a style="font-weight: bold;" href="http://javatutorialsworld.blogspot.com/2009/06/why-java-classes-are-not-marked-final.html"&gt;Why Java classes are not marked final&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-2434988034876031665?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/2434988034876031665/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/10/core-java-very-basic-questions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/2434988034876031665'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/2434988034876031665'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/10/core-java-very-basic-questions.html' title='Core Java Very basic Questions || Important Core Java Questions'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-4939722427157863943</id><published>2009-10-13T01:08:00.003+05:30</published><updated>2009-10-13T02:29:20.435+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Advanced Concepts'/><category scheme='http://www.blogger.com/atom/ns#' term='Misc'/><category scheme='http://www.blogger.com/atom/ns#' term='Java utilities'/><title type='text'>How to executing System programs from your Java programs and applications</title><content type='html'>&lt;div style="text-align: justify;"&gt;Java is capable of executing threads by starting and running them.Java Programming language also provides you with the ability to start the heavyweight system processes.Threads are lightweight processes and can be called as a subprocess.Executing or starting a System process is completely different than executing a thread.&lt;br /&gt;&lt;br /&gt;Java.lang provides a method &lt;span style="font-weight: bold; font-style: italic;"&gt;exec()&lt;/span&gt; which is used to name and run the process.The &lt;span style="font-weight: bold; font-style: italic;"&gt;exec()&lt;/span&gt; method returns a process object and is invoked on Runtime instance.Runtime is an abstract class whcih can be instantiated as following:-&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;Runtime rt = Runtime.getRuntime();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;While you write and use &lt;span style="font-weight: bold; font-style: italic;"&gt;exec()&lt;/span&gt; in your programs do remember that &lt;span style="font-weight: bold; font-style: italic;"&gt;exce()&lt;/span&gt; method throws an IOException which needs to be handled as it is a checked Exception.Make sure to write the &lt;span style="font-weight: bold; font-style: italic;"&gt;exec()&lt;/span&gt; inside a try/catch block which can handle an IOException.&lt;br /&gt;&lt;br /&gt;The process object which is used to get the value from &lt;span style="font-weight: bold; font-style: italic;"&gt;exec()&lt;/span&gt; can be used to control how your Java program interacts with the running process.&lt;br /&gt;The &lt;span style="font-weight: bold; font-style: italic;"&gt;exec()&lt;/span&gt; method is an environment dependent method so do make sure to write OS specific process names as arguments to &lt;span style="font-weight: bold; font-style: italic;"&gt;exec()&lt;/span&gt;.The argumemnts passed must be system recognizable commands.&lt;br /&gt;&lt;br /&gt;Here the following example shows how the Window's notepad is launched through the Java program.Notepad is a simple text editor of windows.The example uses &lt;span style="font-weight: bold; font-style: italic;"&gt;exec()&lt;/span&gt; method to invoke the notepad process.&lt;br /&gt;&lt;br /&gt;class LaunchNotepad{&lt;br /&gt;public static void main(String a[]){&lt;br /&gt;Runtime rt = Runtime.getRuntime();&lt;br /&gt;Process p =null;&lt;br /&gt;try{&lt;br /&gt;p=rt.exec("notepad");&lt;br /&gt;}catch(Exception e)&lt;br /&gt;{System.out.println("Error in Starting Notepad");}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Now you system is up and running the notepad process.Similarly you can invoke any process you like through you Java Application what you have to know is the system call which will be passed as argument in the &lt;span style="font-weight: bold; font-style: italic;"&gt;exec() &lt;/span&gt;method.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Related posts :-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a style="color: rgb(255, 0, 0);" href="http://javatutorialsworld.blogspot.com/2009/09/java-thread-basics-learn-java-threads.html"&gt;Java Thread Basics&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/09/memory-management-in-java.html"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;Memory Management in Java&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/05/compute-any-day-in-calendar-using.html"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;Compute any day in calendar&lt;/span&gt;&lt;/a&gt;&lt;br /&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/2124855005622377541-4939722427157863943?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/4939722427157863943/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/10/how-to-executing-system-programs-from.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/4939722427157863943'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/4939722427157863943'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/10/how-to-executing-system-programs-from.html' title='How to executing System programs from your Java programs and applications'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-3509881444869485523</id><published>2009-09-21T22:45:00.003+05:30</published><updated>2009-09-21T23:17:12.896+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Exception Handling'/><title type='text'>Exception propagation : Propagation of Uncaught exceptions</title><content type='html'>&lt;div style="text-align: justify;"&gt;There are many important things to remember to catch an exception.Fir instance one must use catch or finally to catch the thrown exceptions in try block.Also remember that try will never work without either a catch or finally.This is a must follow condition.&lt;br /&gt;&lt;br /&gt;So what happens to a exception which is not caught by any of the catch block, of course they keep looking for its handler (its always good to catch 'em) and if they failed to find one they just propagate from one method to the other and end up crashing the program.Whenever an exception is not caught by any catch block in the method then method is said to be ducking the exception.It also means that method passes its course of work to other method to handle the exception.The exception propagation follows call stack.I think you are now grown up and must know what a call stack means.Lets rewind the stack concept that a call stack is a stack where methods are placed in LIFO order based on method call.For example if yo have called method abc() from main() then main() method will be placed at bottom of the stack and the called method abc() will be on top.After the abc finish execution the abc() will be popped from the stack and main() will take pole position.&lt;br /&gt;&lt;br /&gt;The above call stack concept also applies to the Exception propagation.Consider we have two methods a() and b().main() calls a() and after that a() calls method b().Now suppose the called method b() is facing heat from JVM and it resulted in exception then the exception will look for specific handler,if it failed to either specific handler or a superclass handler then it start to look in the calling method that is a().Here also it will follow the same procedure and if it again failed it will go to main() method and in the end if it again failed at the bottom of the stack then mate its ultimate law of nature that it has to die a horrible death,or it will produce a complete stack trace of the exception.Following figure shows how call stack woks and exception propagate"-&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_1CvsF-MJpr4/Sre42UmWyHI/AAAAAAAAAPo/G2AIEGHga6M/s1600-h/call+stack.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 159px; height: 132px;" src="http://1.bp.blogspot.com/_1CvsF-MJpr4/Sre42UmWyHI/AAAAAAAAAPo/G2AIEGHga6M/s400/call+stack.bmp" alt="" id="BLOGGER_PHOTO_ID_5383975122926749810" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Make it even more clear by considering the following example:-&lt;br /&gt;&lt;br /&gt;public class Exceptionpropagation{&lt;br /&gt;public static void main(String[] a){&lt;br /&gt;domore();&lt;br /&gt;}&lt;br /&gt;public void domore(){&lt;br /&gt;doevenmore();&lt;br /&gt;}&lt;br /&gt;public void doevenmore(){&lt;br /&gt;int x=10/0;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;The produced will be in the order of stack call that is from code it is clear that the exception is generated from doevenmore() so it will be listed on top of stack trace and following the stack trace you can find out where actually the exception has happened.&lt;br /&gt;&lt;br /&gt;The resulting exception would be and its stack trace :-&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Exception in thread "main" &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;java.lang.ArithmeticException: / by zero     &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;at Exceptionpropagation.doevenmore(Exceptionpropagation.java:13)     &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;at Exceptionpropagation.domore(Exceptionpropagation.java:10)     &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;at Exceptionpropagation.main(Exceptionpropagation.java:7) &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Process Exit...&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Suggested Reading:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/02/exception-handlingbasics.html"&gt;Exception Handling Basics&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/02/exceptionstry-catch-part1.html"&gt;Exceptions: try-catch part 1&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/02/exception-handlingtry-catch-part2.html"&gt;Exceptions: try-catch part 2&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/03/use-of-finally.html"&gt;Use of Finally&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/03/all-exception-classes-are-subtypes-of.html"&gt;Exception Hierarchy&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/03/user-defined-exceptions.html"&gt;User defined exceptions&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/03/exception-matching.html"&gt;Exception Matching&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Sponsored Listings:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a style="font-weight: bold; color: rgb(0, 153, 0);" href="http://www.AffiliateHarvest.com/click.aspx?adID=25&amp;amp;affID=86"&gt;Play free trivia and test your skill&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-3509881444869485523?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/3509881444869485523/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/09/exception-propagation-propagation-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/3509881444869485523'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/3509881444869485523'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/09/exception-propagation-propagation-of.html' title='Exception propagation : Propagation of Uncaught exceptions'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_1CvsF-MJpr4/Sre42UmWyHI/AAAAAAAAAPo/G2AIEGHga6M/s72-c/call+stack.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-1382656200510862084</id><published>2009-09-18T01:55:00.003+05:30</published><updated>2009-09-18T02:12:36.295+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Access Control and Declaration'/><category scheme='http://www.blogger.com/atom/ns#' term='Misc'/><category scheme='http://www.blogger.com/atom/ns#' term='Object Oriented'/><title type='text'>Most Common Scoping errors commited by Novice Java Programmers</title><content type='html'>&lt;div style="text-align: justify;"&gt;Scoping errors comes in various sizes and shapes.Novice Java programmers most often commit some silly mistakes which are undesirable.The most common mistake novice programmers commit is scoping errors which comes in many ways.One is happens when the variable is shadowed and two scopes overlap.It becomes very much difficult to identify the problem.The reason why scoping errors comes into effect is when programmer attempts to access a variable not in scope or visibility.There are few common mistakes which are explained below.Lets take a look:-&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;1.Attempting to access an instance variable from a static context (i.e. from main() method)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Since static variable can only be accessed from static context thus there is no way you can access the non-static instance variable in static context without a reference.For example:-&lt;br /&gt;&lt;br /&gt;Class Scopetest{&lt;br /&gt;int x=10;&lt;br /&gt;public static void main(String a[]){&lt;br /&gt;System.out.println(x++);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;This will result in an error&lt;br /&gt;&lt;span style="font-style: italic;font-family:trebuchet ms;" &gt;Scopetest&lt;/span&gt;&lt;span style="font-style: italic;font-family:arial;" &gt;.java:4: non-static variable x cannot be referenced from a static context &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:arial;" &gt;System.out.println(x++); &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Despite this you can use the instance of Scopetest class to access the variable as shown below:-&lt;br /&gt;&lt;br /&gt;class Scopetest{&lt;br /&gt;int x=10;&lt;br /&gt;public static void main(String a[]){&lt;br /&gt;System.out.println(&lt;span style="font-weight: bold;"&gt;new &lt;/span&gt;Scopetest&lt;span style="font-weight: bold;"&gt;()&lt;/span&gt;.x++);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;This will produce output as 10.&lt;br /&gt;So,remember you can never ever access a non-static instance variable within a static context alone.You have to use the enclosing class instance.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;2.Attempting to use a block variable after the code block is completed.&lt;/span&gt;&lt;br /&gt;How often we commit this error,I guess everyone of us has faced it.So remember never ever try to invoke a variable which is ended its life.That is block variable lifetime is until the code block completes.As block finished execution the variable will also perish from memory,thus any reference out of this block result in a compiler slap!!!&lt;br /&gt;Lets take a look at following example:-&lt;br /&gt;&lt;br /&gt;class Scopetest{&lt;br /&gt;public static void main(String a[]){&lt;br /&gt;for(i=0;i&lt;2;i++) style="font-style: italic;"&gt;.java:5: cannot find symbol&lt;br /&gt;&lt;span style="font-style: italic;"&gt;symbol  : variable i &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;location: class &lt;/span&gt;Scopetest&lt;br /&gt;&lt;span style="font-style: italic;"&gt;if(i&lt;3)&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;3.Attempting to access a local variable from nested method.&lt;/span&gt;&lt;br /&gt;When a method invokes another method then the calling method does not have access to the called methods variables and vice versa.For example:-If we have a method do1() which called by another method do2() then do1() cannot access the variables local to do2().It is evident from the following example:-&lt;br /&gt;&lt;br /&gt;class Scopetest{&lt;br /&gt;public static void main(String[] a){&lt;br /&gt;Scopetest s = new Scopetest();&lt;br /&gt;s.do2();&lt;br /&gt;}&lt;br /&gt;public void do2(){&lt;br /&gt;int x = 4;&lt;br /&gt;do1();&lt;br /&gt;++x;&lt;br /&gt;}&lt;br /&gt;public void do1(){&lt;br /&gt;x++;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;The error which appears is:-&lt;br /&gt;Scopetest&lt;span style="font-style: italic;"&gt;.java:12: cannot find symbol &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;symbol  : variable x &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;location: class &lt;/span&gt;Scopetest&lt;br /&gt;&lt;span style="font-style: italic;"&gt;x++;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;So next time you go to the battlefield(programming) keep yourself armed with better knowledge and strategies of course here is to reduce the bug and make your program more readable.Keep in mind above mentioned errors and be a good programmer,and keep firing on the COMPILER!!!.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Suggested Links:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/07/why-java-not-support-multiple.html"&gt;Why Java does not support Multiple Inheritance&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/06/why-java-classes-are-not-marked-final.html"&gt;Why Java classes are not marked final&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/07/variable-shadowing-complexities-can-you.html"&gt;Variable Shadowing Complexities&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Sponsored Link:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.affiliateharvest.com/click.aspx?adID=25&amp;amp;affID=86"&gt;&lt;span style="color: rgb(0, 153, 0); font-weight: bold;"&gt;Are you Intelligent Check!!&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-1382656200510862084?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/1382656200510862084/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/09/most-common-scoping-errors-commited-by.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/1382656200510862084'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/1382656200510862084'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/09/most-common-scoping-errors-commited-by.html' title='Most Common Scoping errors commited by Novice Java Programmers'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-3649779895629411247</id><published>2009-09-09T01:35:00.005+05:30</published><updated>2009-10-31T23:42:51.305+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Threads'/><title type='text'>Java Thread Basics || Learn Java Threads</title><content type='html'>&lt;div style="text-align: justify;"&gt;Most of the functions in a computer needs various things to be done simultaneously.Like if we are playing a computer game then there are various things going on at the same time,like graphics,sound,gameplay,commands,scoring etc.Do you ever imagine how all this happens? The answer is it is done with the help of Threads.Threads are the sequence of computer instructions which carry out specific tasks.Now you will say that "wait this is the definition of a computer process isn't it".Yes you are absolutely right,but since the Threads are small unit of execution and they also have start and end and they complete a specific task so this definition also applies to Threads.A process is a larger unit of sequence of instructions.A thread is not a process on its own but it exists within a Thread.A Thread has no unique existence.Every process has atleast a Thread called primary Thread,you can create as many as you want.The Microprocessor divides the memory among the processes that we execute.Each process occupies that address space and the Threads within the process share same address space.That is why I said "Thread cannot exist on their own".It is clear from the following figure:-&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_1CvsF-MJpr4/Sqa5w5w6jgI/AAAAAAAAAPQ/s97Lw0WVPgI/s1600-h/Thread+basics.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 194px;" src="http://2.bp.blogspot.com/_1CvsF-MJpr4/Sqa5w5w6jgI/AAAAAAAAAPQ/s97Lw0WVPgI/s320/Thread+basics.jpg" alt="" id="BLOGGER_PHOTO_ID_5379191054731480578" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Threads are very useful when you have large computations at your side.Threads divides the task into multiple threads and each on finishes its task.This way Threads accomplish a faster execution time and complete utilisation of Computer resources.&lt;br /&gt;&lt;br /&gt;The resources like memory,devices and data of program and context of program are also available to the Threads of the program.A Thread is also known as a "Lightweight process" or "execution context".This is because there are fewer overloads on the processor when it switches from one Thread to the other,than when it switches from one Process to the other.The above diagram also shows the relationship between a Process and a Thread.&lt;br /&gt;&lt;br /&gt;SingleThreaded and MultiThreded Application&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;A Process in general are of two types&lt;br /&gt;&lt;br /&gt;1.Single Threaded&lt;br /&gt;2.Multi Threaded&lt;br /&gt;&lt;br /&gt;A process which is made up of single thread is known as single threaded process.It is like performing a task at a particular time.No other simultaneous thread can execute.The next thread can only execute on the completion of previous Threads completion.You can understand more from figure see below.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_1CvsF-MJpr4/Sqa6B_HJKyI/AAAAAAAAAPY/LlfL3p4lkeI/s1600-h/single+thread.jpg"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer; width: 320px; height: 30px;" src="http://1.bp.blogspot.com/_1CvsF-MJpr4/Sqa6B_HJKyI/AAAAAAAAAPY/LlfL3p4lkeI/s320/single+thread.jpg" alt="" id="BLOGGER_PHOTO_ID_5379191348224666402" border="0" /&gt;&lt;/a&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Single Thread within a process which runs serially and perform tasks&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;A Process having more than one thread is known as MultiThreaded Process.In MultiThreaded process multiple threads can run and perform various tasks at the same time for Example:-In a computer game we have a lot of things going on at the same time like Gameplay,Scoring,Sound,Controlling and so on.These all are handled by individual threads which works with each other or execute at the same time to produce the results.More understanding from figure see below.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_1CvsF-MJpr4/Sqa6CSlDZ3I/AAAAAAAAAPg/JvsVGRk5FXI/s1600-h/multithreaded.jpg"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer; width: 320px; height: 106px;" src="http://1.bp.blogspot.com/_1CvsF-MJpr4/Sqa6CSlDZ3I/AAAAAAAAAPg/JvsVGRk5FXI/s320/multithreaded.jpg" alt="" id="BLOGGER_PHOTO_ID_5379191353450391410" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center; font-weight: bold;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Thread Input(two thread running simultaneously within a process independently)&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.affiliateharvest.com/click.aspx?adID=25&amp;amp;affID=86"&gt;&lt;span style="font-weight: bold; color: rgb(0, 153, 0);"&gt;Are you Intelligent Compete with world to prove&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Suggested Reading:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/10/thread-life-cycle.html"&gt;&lt;span style="font-weight: bold;"&gt;Thread Life cycle&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/10/ways-of-creating-threads-in-java.html"&gt;&lt;span style="font-weight: bold;"&gt;Ways to create Threads&lt;/span&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-3649779895629411247?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/3649779895629411247/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/09/java-thread-basics-learn-java-threads.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/3649779895629411247'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/3649779895629411247'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/09/java-thread-basics-learn-java-threads.html' title='Java Thread Basics || Learn Java Threads'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_1CvsF-MJpr4/Sqa5w5w6jgI/AAAAAAAAAPQ/s97Lw0WVPgI/s72-c/Thread+basics.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-2014756774575796141</id><published>2009-09-04T00:16:00.002+05:30</published><updated>2009-09-04T00:33:41.430+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Misc'/><category scheme='http://www.blogger.com/atom/ns#' term='Java utilities'/><title type='text'>Memory Management In Java</title><content type='html'>&lt;div style="text-align: justify;"&gt;Java provides automatic garbage collection,sometimes you will want to know how large the object heap is and how much of it is left.You can use this result to know about the efficiency of your application or program,that is you may come to know how many more objects you can instantiate.To obtain these values use totalMemory() and freeMemory() methods.&lt;br /&gt;&lt;br /&gt;Since Java Garbage Collector runs periodically to check the dangling object references and empty Strings and to recycle these unused objects.However on the other hand we can let the garbage collector run whenever we want.Garbage collector runs on random times ,you never know when will be the next appointment of Garbage Collector.So,if you think you are running out of memory you can enforce Garbage Collector to Sweep unused memory.You can run the Garbage Collector on demand by calling gc() method.gc() is called as "System.gc()".A good practice is to first call gc() method then call freeMemory() to get the base memory usage.Next execute your code and now see how much memory code is occupying by again calling freeMemory() method.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;NOTE:-&lt;/span&gt;The methods gc(),totalMemory(),freeMemory() are part of Runtime class(For more on Runtime refer its Runtime API).The gc() method is also available in System class and is marked static in it.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Lets understand by example:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;public class Memoryusage{&lt;br /&gt;public static void main(String a[]){&lt;br /&gt;Runtime rt = Runtime.getRuntime();&lt;br /&gt;long mem1,mem2;&lt;br /&gt;String toomuch[] = new String[20000];&lt;br /&gt;System.out.println("Total memory is : "+rt.totalMemory());&lt;br /&gt;mem1=rt.freeMemory();&lt;br /&gt;System.out.println("Initial Free Memory : "+mem1);&lt;br /&gt;rt.gc();&lt;br /&gt;mem1=rt.freeMemory();&lt;br /&gt;System.out.println("Memory after Garbage Collection :"+mem1);&lt;br /&gt;for(int i=0;i&lt;20000;i++)&lt;br /&gt;toomuch[i] = new String("String Array");&lt;br /&gt;&lt;br /&gt;mem2=rt.freeMemory();&lt;br /&gt;System.out.println("Memory after allocation :"+mem2);&lt;br /&gt;System.out.println("Memory used by alocation : "+(mem1-mem2));&lt;br /&gt;&lt;br /&gt;for(int i=0;i&lt;1000;i++)&lt;br /&gt;toomuch[i] = null;&lt;br /&gt;rt.gc();&lt;br /&gt;mem2=rt.freeMemory();&lt;br /&gt;System.out.println("Memory after deacllocating memory : "+mem2);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;Output:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Total memory is : 5177344&lt;br /&gt;Initial Free Memory : 4898608&lt;br /&gt;Memory after Garbage Collection :4986512&lt;br /&gt;Memory after allocation :4505976&lt;br /&gt;Memory used by allocation : 480536&lt;br /&gt;Memory after deacllocation memory : 4530512&lt;br /&gt;&lt;br /&gt;Output is Machine specific and may vary on your machine.&lt;br /&gt;&lt;br /&gt;Now you can see that how these methods work gc(),freeMemory() and totalMemory().Runtime class is an abstract class thus it cannot be used to create instances but despite we can all methods to do the same.Like here we have called method getRuntime().&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Other Suggested Reading&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a style="color: rgb(255, 0, 0);" href="http://javatutorialsworld.blogspot.com/2009/05/loading-image-on-jframe-using.html"&gt;Loading Image on JFrame&lt;/a&gt;&lt;br /&gt;&lt;a style="color: rgb(255, 0, 0);" href="http://javatutorialsworld.blogspot.com/2009/05/compute-any-day-in-calendar-using.html"&gt;Compute any day in calendar&lt;/a&gt;&lt;br /&gt;&lt;a style="color: rgb(255, 0, 0);" href="http://javatutorialsworld.blogspot.com/2009/06/how-to-create-pop-up-menus-in-java_19.html"&gt;How to Create Pop Up menus&lt;/a&gt;&lt;br /&gt;&lt;a style="color: rgb(255, 0, 0);" href="http://javatutorialsworld.blogspot.com/2009/05/datetime-in-your-specified-format.html"&gt;Date and Time in your specified Format&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Sponsored Listings&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a style="color: rgb(0, 153, 0);" href="http://www.AffiliateHarvest.com/click.aspx?adID=25&amp;amp;affID=86"&gt;Are you Intelligent!!!&lt;/a&gt;&lt;br /&gt;&lt;a style="color: rgb(0, 153, 0);" href="http://www.ucertify.com/?af=vaibhav"&gt;Get your SCJP Kit free&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-2014756774575796141?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/2014756774575796141/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/09/memory-management-in-java.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/2014756774575796141'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/2014756774575796141'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/09/memory-management-in-java.html' title='Memory Management In Java'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-1692769734512855328</id><published>2009-09-03T01:12:00.003+05:30</published><updated>2009-09-03T01:27:19.532+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Strings'/><title type='text'>Why use StringBuilder instead of StringBuffer?</title><content type='html'>&lt;div style="text-align: justify;"&gt;The String class is just not sufficient to perform all the String related tasks.That is why the classes like StringBuffer and StringBuilder is added.StringBuffer class is added in Java 5 .It has exactly the same API as StringBuffer except (the twist in the story) ,the methods in StringBuilder class are not Thread safe.We can also say that the methods in StringBuilder class are not synchronized.The recommendation of many experienced programmers and Sun itself is that use StringBuilder instead of StringBuffer because the StringBuilder will run faster than StringBuffer.&lt;br /&gt;&lt;br /&gt;Apart from this huge difference between StringBuilder and StringBuffer, everything which is true for StringBuffer holds true for StringBuilder class.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;NOTE:-&lt;/span&gt;If you want to give SCJP examination then you must clearly know the distinction between the String,StringBuffer and StringBuilder class.The questions may be on how well you know the API of these classes and implementation of these classes.So there may be questions on StringBuilder or StringBuffer which may contain some piece of Thread code.Don't be panic by watching the Thread code.Just Rehearse the use of StringBuilder and StringBuffer in Threads.It is not that tough.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Suggested Reading:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a style="color: rgb(255, 0, 0);" href="http://javatutorialsworld.blogspot.com/2009/08/how-jvm-handles-strings-objects-and.html"&gt;How JVM handles Strings&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/08/method-chaining-in-java-strings.html"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;Method Chaining in Java Strings&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/08/important-string-class-methods.html"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;Important String Methods&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/08/simple-twisters-on-java-strings.html"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;Simple twisting questions on Strings&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/09/stringbuffer-class-in-java.html"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;StringBuffer class explained&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Sponsored Listings&lt;/span&gt;&lt;br /&gt;&lt;a href="http://www.ucertify.com/?af=vaibhav"&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;Get your SCJP kit freee&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a style="color: rgb(0, 153, 0);" href="http://www.AffiliateHarvest.com/click.aspx?adID=25&amp;amp;affID=86"&gt;Are you Intelligent!!!!!&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-1692769734512855328?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/1692769734512855328/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/09/why-use-stringbuilder-instead-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/1692769734512855328'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/1692769734512855328'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/09/why-use-stringbuilder-instead-of.html' title='Why use StringBuilder instead of StringBuffer?'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-9133304678996969027</id><published>2009-09-03T00:56:00.003+05:30</published><updated>2009-09-03T01:28:48.056+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Strings'/><title type='text'>StringBuffer class in Java</title><content type='html'>&lt;div style="text-align: justify;"&gt;StringBuffer is the class included in java.lang and is mostly used when we have to make a lot of modifications to Strings of characters.As String class does not support string mutability that is when we use Java Strings class our strings becomes Immutable and can never be changed.It has a crucial impact on the memory of the program.If we use String class we are left with numerous dangling strings in the memory which not only waste the memory but could also cause the memory overflow at some stage.Objects of StringBuffer class can be modified a number of times and even you don't need a reference to the object to assign.Simply use the method on the object and change will reflect on the object.StringBuffer class modifies strings over and over again without leaving behind a great effluence of discarded String objects.&lt;br /&gt;&lt;br /&gt;The main use of StringBuffer class is in File I/O where large stream of data keeps on coming with constantly changing values.Thus making StringBuffer class use handy.Here the loss of memory never happens.In these cases, large block of characters are handled as units ,and StringBuffer objects are the ideal way to handle a block of data,pass it on and then reuse the memory block to handle the next stream of data.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Constructors:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;StringBuffer()   //Creates a StringBuffer with initial capacity of 16 characters.&lt;br /&gt;&lt;br /&gt;StringBuffer(String s)   //Creates StringBuffer which contains same no of characters as in the String argument.&lt;br /&gt;&lt;br /&gt;StringBuffer(int length)  //Creates StringBuffer with specified number of characters.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;lets see an example on StringBuffer&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;// don't forget to import the StringBuffer class(java.lang.StringBuffer.*;)&lt;br /&gt;StringBuffer x = new StringBuffer("ABCDE");&lt;br /&gt;x.append("FGH");&lt;br /&gt;System.out.println(x);&lt;br /&gt;&lt;br /&gt;Output would be :- ABCDEFGH&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;The main feature of StringBuffer methods are as follows :-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The main feature of this StringBuffer class is that all methods are thread safe that is marked as synchronized.With synchronized marking StringBuffer comes with a disadvantage that it works slower that every String API.To overcome the problem of this Thread safe and slow execution we use StringBuilder class.More on StringBuilder Later.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Suggested Reading:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a style="color: rgb(255, 0, 0);" href="http://javatutorialsworld.blogspot.com/2009/08/how-jvm-handles-strings-objects-and.html"&gt;How JVM handles Java Strings&lt;/a&gt;&lt;br /&gt;&lt;a style="color: rgb(255, 0, 0);" href="http://javatutorialsworld.blogspot.com/2009/08/method-chaining-in-java-strings.html"&gt;Method Chaining in Java Strings&lt;/a&gt;&lt;br /&gt;&lt;a style="color: rgb(255, 0, 0);" href="http://javatutorialsworld.blogspot.com/2009/08/important-string-class-methods.html"&gt;Important String Class Methods&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/08/simple-twisters-on-java-strings.html"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;Simple twisting questions on Strings&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a style="color: rgb(255, 0, 0);" href="http://javatutorialsworld.blogspot.com/2009/09/why-use-stringbuilder-instead-of.html"&gt;Why use StringBuilder instead of StringBuffer&lt;/a&gt;?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Sponsored Listings&lt;/span&gt;&lt;br /&gt;&lt;a href="http://www.ucertify.com/?af=vaibhav"&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;Get Your SCJP kit free&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a style="color: rgb(0, 153, 0);" href="http://www.affiliateharvest.com/click.aspx?adID=25&amp;amp;affID=86"&gt;Are you Intelligent!!!!&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-9133304678996969027?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/9133304678996969027/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/09/stringbuffer-class-in-java.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/9133304678996969027'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/9133304678996969027'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/09/stringbuffer-class-in-java.html' title='StringBuffer class in Java'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-753532809705109616</id><published>2009-08-26T23:11:00.002+05:30</published><updated>2009-08-26T23:44:58.340+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Access Control and Declaration'/><category scheme='http://www.blogger.com/atom/ns#' term='Object Oriented'/><title type='text'>How to call constructor of SuperClass</title><content type='html'>&lt;div style="text-align: justify;"&gt;Inheritance is the core concept of Object oriented programing and Java programming Language.Since every subclass has exclusive rights to use the every resource of its superclass.Constructor of superclass holds important position in this regard.There are many functions a subclass can import by calling the constructor of its superclass.The call to the Superclass constructors can be made by using the ' super ' keyword.The main points to remembered in case of using super keyword are as follows:-&lt;br /&gt;&lt;br /&gt;1.The default Constructor of the superclass is invoked even if the super() method is not called in the subclass.It is also invoked if you do not pass any arguments to super().If the default constrictor is not available,compiler generates an error.&lt;br /&gt;&lt;br /&gt;2.You can invoke a special constructor of the superclass by passing arguments to the super method,if the constructor is overloaded in the superclass.&lt;br /&gt;&lt;br /&gt;3.The super() method must be the first statement in the constructor of the subclass.&lt;br /&gt;&lt;br /&gt;Lets take a look at following example:- The example illustrates how you can call a super class constructor.&lt;br /&gt;&lt;br /&gt;The Superclass&lt;br /&gt;&lt;br /&gt;class Car&lt;br /&gt;{&lt;br /&gt; Strring Name;&lt;br /&gt; int seats=4;&lt;br /&gt;&lt;br /&gt;Car(){&lt;br /&gt;.....&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Car(int seats,String Name){&lt;br /&gt;....&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Subclass which invokes the superclass constructor&lt;br /&gt;&lt;br /&gt;public class Subaru extends Car{&lt;br /&gt;int wheels;&lt;br /&gt;&lt;br /&gt;public Subaru(){&lt;br /&gt;super(4,"Subaru Impreza");&lt;br /&gt;wheels=4;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Here the constructor of superclass is invoked by the method call super(4,"Subaru Impreza") and you can call the default constructor by placing your call super().By following the way you can invoke the superclass constructor which can be helpful in many tasks in your application.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Useful Links:-&lt;/span&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/06/why-java-classes-are-not-marked-final.html"&gt;Why Java Classes not marked final&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/07/why-code-reuse-is-exclusive-feature-of.html"&gt;Why code reuse is exclusive feature of Java&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/07/polymorphismcore-of-object-oriented.html"&gt;Polymorphism in Java&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/07/why-java-not-support-multiple.html"&gt;Why Java not support multiple inheritance&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/07/inheritance-complete-explanation.html"&gt;Inheritance Complete explanation&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/07/is-and-has-relationship-every-thing.html"&gt;Is a and Has-a relationship&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Sponsored Links:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a style="color: rgb(0, 153, 0);" href="http://www.AffiliateHarvest.com/click.aspx?adID=25&amp;amp;affID=86"&gt;&lt;span style="font-weight: bold;"&gt;Are you Intelligent Check here&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.ucertify.com/?af=vaibhav"&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;Get your Copy of SCJP kit Free !!!!!&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-753532809705109616?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/753532809705109616/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/08/how-to-call-constructor-of-superclass.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/753532809705109616'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/753532809705109616'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/08/how-to-call-constructor-of-superclass.html' title='How to call constructor of SuperClass'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-2129545175750227086</id><published>2009-08-25T23:53:00.004+05:30</published><updated>2009-08-26T23:37:54.924+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Interview Questions'/><category scheme='http://www.blogger.com/atom/ns#' term='Strings'/><title type='text'>Simple Twisters on Java Strings</title><content type='html'>&lt;div style="text-align: justify;"&gt;Java Stings is a relatively easy topic in Java to understand.But until you master any topic you cannot answer even the simplest questions on that topic.These twisters are interesting and will test your Strings knowledge.In the previous tutorials on Java Strings you have learned following topics:-&lt;br /&gt;&lt;br /&gt;1.&lt;a href="http://javatutorialsworld.blogspot.com/2009/08/how-jvm-handles-strings-objects-and.html"&gt;How JVM Handles Strings&lt;/a&gt;&lt;br /&gt;2.&lt;a href="http://javatutorialsworld.blogspot.com/2009/08/important-string-class-methods.html"&gt;Important Java Strings methods&lt;/a&gt;&lt;br /&gt;3.&lt;a href="http://javatutorialsworld.blogspot.com/2009/08/method-chaining-in-java-strings.html"&gt;Method Chaining in Strings&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;if you wish to answer the following questions i recommend you to look back the previous tutorials to make your Java String Concepts more strong.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;Get Java Books Free&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;!!!!!&lt;/span&gt; Hurry answer these questions correctly and you can win a chance to download Java books for free.Just answer these questions and mail me&lt;span style="font-weight: bold;"&gt; javatute@gmail.com&lt;/span&gt; within 2 days of its publish.First five winner will get exclusive Java ebooks for free.Hurry !!!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;1.In Java Strings are immutable and Cannot be changed&lt;/span&gt;&lt;br /&gt;a)True&lt;br /&gt;b)False&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;2.What would be the output of following code:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;String a="abcdefgh";&lt;br /&gt;a.concat(" i don't know buddy!!");&lt;br /&gt;System.out.println(a);&lt;br /&gt;&lt;br /&gt;a)abcdefgh i don't know buddy!!&lt;br /&gt;b)abcdefgh&lt;br /&gt;c)Compilation fails&lt;br /&gt;d)Runtime Exception&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;3.How many Strings are created in the String constant pool upon compilation of following code segment:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;String a="abcdefgh";&lt;br /&gt;a=a.concat(" i don't know buddy!!");&lt;br /&gt;System.out.println(a);&lt;br /&gt;&lt;br /&gt;a) 1&lt;br /&gt;b) 2&lt;br /&gt;c) 3&lt;br /&gt;d) 4&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;4.What would be the output of following code:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;String a="abcdefgh";&lt;br /&gt;a=a.concat(" i don't know buddy!!");&lt;br /&gt;System.out.println(a);&lt;br /&gt;&lt;br /&gt;a)abcdefgh i don't know buddy!!&lt;br /&gt;b)abcdefgh&lt;br /&gt;c)Compilation fails&lt;br /&gt;d)Runtime Exception&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;5.What would be the output of following code segment:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;String a ="abcdefgh";&lt;br /&gt;a.toString();&lt;br /&gt;a.concat("Its not a joke dude!!!");&lt;br /&gt;System.out.println(a.concat("Its amazing"));&lt;br /&gt;System.out.println(b.toUpperCase());&lt;br /&gt;&lt;br /&gt;a)abcdefgh Its amazing&lt;br /&gt;ABCDEFGH&lt;br /&gt;&lt;br /&gt;b)abcdefgh&lt;br /&gt;ABCDEFGH&lt;br /&gt;&lt;br /&gt;c)ABCDEFGH&lt;br /&gt;d)Compilation fails&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;6.What would be the output of following code segment:&lt;/span&gt;-&lt;br /&gt;&lt;br /&gt;String s="abcdefgh";&lt;br /&gt;System.out.println(s.length);&lt;br /&gt;System.out.print(s+="ijk");&lt;br /&gt;&lt;br /&gt;a) 8abcdefgh&lt;br /&gt;b) 8abcdefghijk&lt;br /&gt;c) Compilation fails&lt;br /&gt;d) Rintime Exception&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;7.What would be the output of following code segment:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;String s="abcd";&lt;br /&gt;String r=s.toUpperCase().concat("efgh").replace('A','Z');&lt;br /&gt;System.out.println(r);&lt;br /&gt;&lt;br /&gt;a)abcdefgh&lt;br /&gt;b)ABCDEFGH&lt;br /&gt;c)Zabcdefgh&lt;br /&gt;d)ZBCDEFGH&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;8.What happens when Strings having no reference reside in String constant pool?&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;(select all that apply)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;a)JVM repeatedly search for Strings with no reference and sweeps them to recollect the memory in String Constant pool.&lt;br /&gt;b)String continues to reside in the memory and JVM doesnot do anything.&lt;br /&gt;c)JVM keeps them in constant pool for some time then eliminates them.&lt;br /&gt;d)The String Constant pool memory Overflows.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Useful Links:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/08/java-interview-questions-utilities-and.html"&gt;Java Interview questions on Utilities and Strings&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/02/java-inerview-questions.html"&gt;Java Interview Questions&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/02/best-java-interview-questions.html"&gt;Best Java Interview Questions&lt;/a&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Sponsored Links:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a style="color: rgb(51, 51, 255);" href="http://www.ucertify.com/?af=vaibhav"&gt;Get your SCJP kit free!!!!!&lt;/a&gt;&lt;br /&gt;&lt;a style="color: rgb(0, 153, 0);" href="http://www.affiliateharvest.com/click.aspx?adID=25&amp;amp;affID=86"&gt;Check your Intelligence here&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-2129545175750227086?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/2129545175750227086/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/08/simple-twisters-on-java-strings.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/2129545175750227086'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/2129545175750227086'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/08/simple-twisters-on-java-strings.html' title='Simple Twisters on Java Strings'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-7418647605951776797</id><published>2009-08-21T00:20:00.003+05:30</published><updated>2009-08-21T02:06:51.283+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Strings'/><title type='text'>Method chaining in Java Strings</title><content type='html'>&lt;div style="text-align: justify;"&gt;Method chaining in Strings is an exceptional and tricky concept in Java Programming.Method chaining in Strings can be widely used as it can perform various and multiple string operations in single statement.Chained methods may contain all the methods of String class.For more on methods &lt;a href="http://javatutorialsworld.blogspot.com/2009/08/important-string-class-methods.html"&gt;click here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;The general form or Syntax of Chained methods is given as follows:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 153);"&gt;result = method1().method2(). ........ method n()&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;There are theories that you can chain as many method you want but in practice not more than three methods are chained.&lt;br /&gt;&lt;br /&gt;So what you are supposed to do when you want to use the chained methods.There are certain rules to follow.Let us take an example :-&lt;br /&gt;&lt;br /&gt;You wish to concat a string in the end if give string then convert it to uppercase and then replace a character in the resulting string.&lt;br /&gt;&lt;br /&gt;First of all Accomplish first task.&lt;br /&gt;&lt;br /&gt;suppose our string is ' s ' and we have to append " World" in the end then we would write&lt;br /&gt;String s="Java";&lt;br /&gt;s.concat(" World");&lt;br /&gt;&lt;br /&gt;Then Convert to uppercase,remember we are in continuation.That is we have to apply the method on the result of previous step thus we would write&lt;br /&gt;&lt;br /&gt;s.concat(" World").toUpperCase();&lt;br /&gt;&lt;br /&gt;Similarly now add the replace method in the chain we will get something like this&lt;br /&gt;&lt;br /&gt;s.concat(" World").toUpperCase().replace('V','W');&lt;br /&gt;&lt;br /&gt;and when you assign the result you will have to write&lt;br /&gt;&lt;br /&gt;s = s.concat(" World").toUpperCase().replace('V','W');&lt;br /&gt;&lt;br /&gt;The output would be&lt;br /&gt;"JAWA WORLD"&lt;br /&gt;&lt;br /&gt;In Java examination the question on String methods chaining is frequently asked.What you need to know is the reverse process in deciphering the chained methods.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;There are few rules too you must keep in your mind.&lt;/span&gt;&lt;br /&gt;1.Determine what the leftmost method call will return.(Call it x)&lt;br /&gt;2.Use this x as the invoking object on the method.If it is the last method then the result of this method call will be the result otherwise repeat the process as in step 1.&lt;br /&gt;&lt;br /&gt;Take an example:-&lt;br /&gt;&lt;br /&gt;s = s.concat(" World").toUpperCase().replace('V','W');&lt;br /&gt;&lt;br /&gt;First consider only concat method whose output would be "Java World".&lt;br /&gt;Now let it be x and invoke uppercase method on x,output would be "JAVA WORLD".&lt;br /&gt;Then the last call made on new x and final output is "JAWA WORLD".&lt;br /&gt;&lt;br /&gt;That is how it works I thinks it would be clear now and if you have any query dont hesitate to ask me.My mail id is given below in the box.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Useful links:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/08/how-jvm-handles-strings-objects-and.html"&gt;How JVM handles string objects&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/08/important-string-class-methods.html"&gt;Important String class methods&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Sponsored Links :-&lt;/span&gt;&lt;br /&gt;&lt;a style="font-weight: bold; color: rgb(255, 0, 0);" href="http://www.AffiliateHarvest.com/click.aspx?adID=25&amp;amp;affID=86"&gt;Check your General Knowledge&lt;/a&gt;&lt;br /&gt;&lt;a style="font-weight: bold; color: rgb(0, 153, 0);" href="http://www.ucertify.com/?af=vaibhav"&gt;Get Your SCJP Exam Kit for Free&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-7418647605951776797?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/7418647605951776797/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/08/method-chaining-in-java-strings.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/7418647605951776797'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/7418647605951776797'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/08/method-chaining-in-java-strings.html' title='Method chaining in Java Strings'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-7335802971504839219</id><published>2009-08-20T00:13:00.003+05:30</published><updated>2009-08-21T02:10:24.749+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Strings'/><title type='text'>Important String class methods explained</title><content type='html'>Strings are very important part of any programming language.Same is the case with Java.There are so many String methods in String class and it will become difficult to explain all of them.I am mainly focusing on some methods which are worthful to beginners.I will also explain some basics about Strings here which makes Strings easy to understand.So, lets begin.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;Basics about Strings in Java&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;1.&lt;/span&gt;You can create Strings in various ways:-&lt;br /&gt;  a) By Creating a String Object&lt;br /&gt;      String s=new String("abcdef");&lt;br /&gt;&lt;br /&gt;  b) By just creating object and then referring to string&lt;br /&gt;      String a=new String();&lt;br /&gt;      a="abcdef";&lt;br /&gt;&lt;br /&gt;   c) By simply creating a reference variable&lt;br /&gt;      String a="abcdef";&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;2.&lt;/span&gt;All the strings gets collected in a special memory are for Strings called " String constant pool".&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;3.&lt;/span&gt;JVM does all string related tasks to avoid the memory wastage for more info on this refer "How JVM Handles strings".&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;4.&lt;/span&gt;Every String is considered as a string literal.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;5.&lt;/span&gt;Strings are immutable only reference changes string never changes.New string literals are referenced when there is any manipulation.The old string gets lost in the preceding.look below&lt;br /&gt;&lt;br /&gt;     &lt;span style="color: rgb(0, 0, 153);"&gt; String s="abcd";&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;       s=s+"efgh";&lt;/span&gt;&lt;br /&gt;   &lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;Important String Methods&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;Following are most commonly used methods in the String class.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;1.public String concat(String s)&lt;/span&gt;&lt;br /&gt;  This method returns a string with the value of string passed in to the method appended to the end of String which used to invoke the method.&lt;br /&gt;&lt;br /&gt;String s="abcdefg";&lt;br /&gt;System.out.println(s.concat("hijlk"));&lt;br /&gt;&lt;br /&gt;Note:-Always use assignment operator in case of concat operator otherwise concat will be unreferenced and you will get old String.example&lt;br /&gt;&lt;br /&gt;s.concat("hijkl");&lt;br /&gt;System.out.println(s);&lt;br /&gt;&lt;br /&gt;It will present output as " abcdefg "  different than what we have expected.So always be careful in using the assignment operator in String method calls.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;2.public charAt(int index)&lt;/span&gt;&lt;br /&gt;This method returns a specific character located at the String's specific index.Remember,String indexes are zero based.Example&lt;br /&gt;&lt;br /&gt;String s="Alfanso Mango";&lt;br /&gt;System.out.println(s.charAt(0));&lt;br /&gt;&lt;br /&gt;The output is 'A'&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;3.public int length()&lt;/span&gt;&lt;br /&gt;This method returns the length of the String used to invoke the method.example:-&lt;br /&gt;&lt;br /&gt;String s="name";&lt;br /&gt;System.out.println(s.length());&lt;br /&gt;&lt;br /&gt;The output is 4&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;4.public String replace(char old,char new)&lt;/span&gt;&lt;br /&gt;This method return a String whose value is that of the String to invoke the method ,updated so that any occurrence of the char in the first argument is replaced by the char in the second argument .Example:-&lt;br /&gt;&lt;br /&gt;String s="VaVavavav";&lt;br /&gt;System.out.println(s.replace('v','V'));&lt;br /&gt;&lt;br /&gt;The output is VaVaVaVaV&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;5.public boolean equalsIgnoreCase(String s)&lt;/span&gt;&lt;br /&gt;This method returns a boolean value depending on whether the value of the string in the argument is the same as the String used to invoke the method.This method will return true even when character in the string object being compared have different cases.Example:-&lt;br /&gt;&lt;br /&gt;String s="Vaibhav";&lt;br /&gt;System.out.println(s.equalsIgnoreCase("VAIBHAV"));&lt;br /&gt;&lt;br /&gt;The output is true&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;6.public String substring(int begin) / public String substring(int begin,int end)&lt;/span&gt;&lt;br /&gt;substring method is used to return a part or substring of the String used to invoke the method.The first argument represents the starting location of the substring.Remember the indexes are zero based.example:-&lt;br /&gt;&lt;br /&gt;String s="abcdefghi";&lt;br /&gt;System.out.println(s.substring(5));&lt;br /&gt;System.out.println(s.substring(5,8));&lt;br /&gt;&lt;br /&gt;The output would be&lt;br /&gt;" fghi "&lt;br /&gt;" fg "&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;7.public String toLowerCase()&lt;/span&gt;&lt;br /&gt;This method returns a string whose value is the String used to invoke the method,but with any uppercase converted to lowercase.:-&lt;br /&gt;&lt;br /&gt;String s="AbcdefghiJ";&lt;br /&gt;System.out.println(s.toLowerCase());&lt;br /&gt;&lt;br /&gt;Output is " abcdefghij "&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;8.public String trim()&lt;/span&gt;&lt;br /&gt;This method returns a String whose value is the String used to invoke the method ,but with any leading or trailing blank spaces removed.Example:-&lt;br /&gt;&lt;br /&gt;String s="hey here is the blank space    ";&lt;br /&gt;System.out.println(s.trim())&lt;br /&gt;&lt;br /&gt;The output is " heyhereistheblankspace"&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;9.public String toUpperCase()&lt;/span&gt;&lt;br /&gt;This method returns a String whose value is String used to invoke the method ,but with any lowercase character converted to uppercase.Example:-&lt;br /&gt;&lt;br /&gt;String s="AAAAbbbbb";&lt;br /&gt;System.out.println(s.to UpperCase());&lt;br /&gt;&lt;br /&gt;The output is " aaaabbbbb "&lt;br /&gt;&lt;br /&gt;Above mentioned String methods are most commonly used in String class.Do remember them or otherwise I am always up for you and of course you can refer this site every time you need something.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Useful Links &lt;/span&gt;:-&lt;br /&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/08/how-jvm-handles-strings-objects-and.html"&gt;How JVM Handles Strings&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/08/method-chaining-in-java-strings.html"&gt;Method Chaining in Java Strings&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Sponsored Links :-&lt;/span&gt;&lt;br /&gt;&lt;a href="http://www.ucertify.com/certifications/SUN/scjp-5-0.html?af=vaibhav"&gt;Get Your SCJP preparation Kit free!!!!!!!&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.ucertify.com/certifications/SUN/scwcd.html?af=vaibhav"&gt;Get Your SCWCD preparation Kit free!!!&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.affiliateharvest.com/click.aspx?adID=25&amp;amp;affID=86"&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;Are you Intelligent check here&lt;/span&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-7335802971504839219?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/7335802971504839219/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/08/important-string-class-methods.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/7335802971504839219'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/7335802971504839219'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/08/important-string-class-methods.html' title='Important String class methods explained'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-5112121321353127804</id><published>2009-08-19T02:07:00.006+05:30</published><updated>2009-09-10T23:28:03.719+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Authors Update'/><category scheme='http://www.blogger.com/atom/ns#' term='EBooks'/><title type='text'>SCWCD best ebook free download</title><content type='html'>&lt;div style="text-align: justify;"&gt;SCWCD Sun Certified web Component Developer examination is a high level sun certification.After being certified as SCWCD you are assumed to have master in web development which involves Java technology.If you are striving to become a SCWCD holder then you must refer to the Head  first servlet and JSP written by Kathy Sierra,her yet another great creation.She  is master in writing Sun Certification ebooks.Head first servlet and JSP doesn't  give you a bunch of facts to memorize but it will drive knowledge straight into  your brain.Head first servlet and JSP let you interact servlets and JSP so that  you can grasp the concepts easily.This book also contains few brand new mock  exams which will test your skills at the end of the book.Download Head first  servlet and JSP free.To download click on the following links:-&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a style="font-weight: bold;" href="http://free-books-world.blogspot.com/2009/07/scwcd-best-ebook-head-first-servlet-and.html"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;SCWCD Best ebook Head first servlet and JSP second edition free download&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_CuxuvopiG0M/SnBL-qXqaEI/AAAAAAAAAL0/Fg5YM8eKii0/s1600-h/head+first+servlet+and+JSP.jpg"&gt;&lt;img id="BLOGGER_PHOTO_ID_5363870696095770690" style="margin: 0px auto 10px; display: block; width: 277px; cursor: pointer; height: 320px; text-align: center;" alt="" src="http://3.bp.blogspot.com/_CuxuvopiG0M/SnBL-qXqaEI/AAAAAAAAAL0/Fg5YM8eKii0/s320/head+first+servlet+and+JSP.jpg" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a href="http://free-books-world.blogspot.com/2009/07/scwcd-best-ebook-head-first-servlet-and.html"&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;SCWCD Best ebook Head first servlet and JSP second edition free download&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;span style="font-size:78%;"&gt;Note:-The link is taken from web and author is not liable for it&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Related links:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.ucertify.com/certifications/SUN/scwcd.html?af=vaibhav"&gt;Get Your SCWCD preparation Kit free!!!&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.blogger.com/SCJP%20Sun%20Certified%20Java%20Programmer%20best%20Ebook%20Free%20Download"&gt;SCJP Free ebook download&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/07/scjp-best-exam-preperation-kitbest-scjp.html"&gt;SCJP Exam preperation Kit&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/07/untold-truths-about-sun-certified-java.html"&gt;Truths about SCJP&lt;/a&gt;&lt;br /&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/2124855005622377541-5112121321353127804?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/5112121321353127804/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/08/scwcd-best-ebook-free-download.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/5112121321353127804'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/5112121321353127804'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/08/scwcd-best-ebook-free-download.html' title='SCWCD best ebook free download'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_CuxuvopiG0M/SnBL-qXqaEI/AAAAAAAAAL0/Fg5YM8eKii0/s72-c/head+first+servlet+and+JSP.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-6770270384791027845</id><published>2009-08-18T02:16:00.004+05:30</published><updated>2009-08-21T02:09:51.724+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Misc'/><category scheme='http://www.blogger.com/atom/ns#' term='Strings'/><title type='text'>How JVM Handles Strings Objects and literals</title><content type='html'>&lt;div style="text-align: justify;"&gt;Strings are undoubtedly the most important part of any programming language.The same is the case with Java programming Language.Handling String objects in memory is a demanding task.One of the key goals of any good programming language is to make efficient use of available memory.As the size of our application grows the size that string literals occupy also becomes larger.Sometime memory may overflow due to high number of string literals used.There may be literal redundancy in the memory.In case of Java programming Language JVM does all memory related tasks specially related with Strings.&lt;br /&gt;&lt;br /&gt;In Java JVM sets up a special Sting memory area called " String Constant Pool ".Whenever Compiler encounters a String literal it checks to see if there is an identical String already exists.If the String exists then the reference is directed towards existing literal else new String literal object is created.&lt;br /&gt;&lt;br /&gt;The important property of Strings is that they are immutable.Yes,you cannot change them.Once you have created a string its unchangeable.You can only assign a new value to the existing String reference,and what happened to previous string as usual it is lost.Lets see what actually happens consider following program:-&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;String s="abcd";&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;s=s+"efgh";&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;System.out.println(s);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In this case the output would be ' abcdefgh '.In the process of getting this value the JVM has actually 3 string literals&lt;br /&gt;&lt;br /&gt;1.abcd&lt;br /&gt;2.efgh&lt;br /&gt;3.abcdefgh&lt;br /&gt;&lt;br /&gt;In order to get the result abcdefgh we have lost the two strings.But point to be noted here is that they remain in memory because the reference is now pointing to some other string and it is considered as lost.There is no way we can refer this string in practical.&lt;br /&gt;&lt;br /&gt;Now we can start to see why making string objects immutable is such a good idea.If several reference variables refer to the same string without even knowing it,it would be very bad if any of them could change the strings value.&lt;br /&gt;&lt;br /&gt;You might say if somebody overrides the String class functionality then what will happen,couldn't that cause problem in the pool??? Well the language designers were well aware about it and that is why they marked String class as ' final '.Means nobody cannot ever override the String class functionality.So that you can assure yourself about String objects because they are immutable.&lt;br /&gt;&lt;br /&gt;JVM on the other hand does garbage collection that is it periodically checks for dangling references on the string literals and on other constants.Whenever one is encountered JVM sweeps it from the memory pool.You have methods to force JVM  for garbage collection but mind you it is not a human its a die hard computing machine the JVM thus it does garbage collection when it suits otherwise it keeps mum.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Useful Link :-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/08/important-string-class-methods.html"&gt;String class Useful Methods&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/08/method-chaining-in-java-strings.html"&gt;Method Chaining in Java Strings&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Sponsored Links :-&lt;/span&gt;&lt;br /&gt;&lt;a href="http://www.ucertify.com/certifications/SUN/scjp-5-0.html?af=vaibhav"&gt;Get Your SCJP preparation Kit free!!!!!!!&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.ucertify.com/certifications/SUN/scwcd.html?af=vaibhav"&gt;Get Your SCWCD preparation Kit free!!!&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.affiliateharvest.com/click.aspx?adID=25&amp;amp;affID=86"&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;Are you Intelligent check here&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-6770270384791027845?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/6770270384791027845/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/08/how-jvm-handles-strings-objects-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/6770270384791027845'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/6770270384791027845'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/08/how-jvm-handles-strings-objects-and.html' title='How JVM Handles Strings Objects and literals'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-7769133358247511254</id><published>2009-08-15T17:39:00.003+05:30</published><updated>2009-08-15T17:55:44.354+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Interview Questions'/><title type='text'>Java Interview questions Utilities and Threads</title><content type='html'>&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:trackmoves/&gt;   &lt;w:trackformatting/&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:donotpromoteqf/&gt;   &lt;w:lidthemeother&gt;EN-US&lt;/w:LidThemeOther&gt;   &lt;w:lidthemeasian&gt;X-NONE&lt;/w:LidThemeAsian&gt;   &lt;w:lidthemecomplexscript&gt;X-NONE&lt;/w:LidThemeComplexScript&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;    &lt;w:splitpgbreakandparamark/&gt;    &lt;w:dontvertaligncellwithsp/&gt;    &lt;w:dontbreakconstrainedforcedtables/&gt;    &lt;w:dontvertalignintxbx/&gt;    &lt;w:word11kerningpairs/&gt;    &lt;w:cachedcolbalance/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;   &lt;m:mathpr&gt;    &lt;m:mathfont val="Cambria Math"&gt;    &lt;m:brkbin val="before"&gt;    &lt;m:brkbinsub val="--"&gt;    &lt;m:smallfrac val="off"&gt;    &lt;m:dispdef/&gt;    &lt;m:lmargin val="0"&gt;    &lt;m:rmargin val="0"&gt;    &lt;m:defjc val="centerGroup"&gt;    &lt;m:wrapindent val="1440"&gt;    &lt;m:intlim val="subSup"&gt;    &lt;m:narylim val="undOvr"&gt;   &lt;/m:mathPr&gt;&lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" defunhidewhenused="true" defsemihidden="true" defqformat="false" defpriority="99" latentstylecount="267"&gt;   &lt;w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Normal"&gt;   &lt;w:lsdexception locked="false" priority="9" semihidden="false" unhidewhenused="false" qformat="true" name="heading 1"&gt;   &lt;w:lsdexception locked="false" priority="9" qformat="true" name="heading 2"&gt;   &lt;w:lsdexception locked="false" priority="9" qformat="true" name="heading 3"&gt;   &lt;w:lsdexception locked="false" priority="9" qformat="true" name="heading 4"&gt;   &lt;w:lsdexception locked="false" priority="9" qformat="true" name="heading 5"&gt;   &lt;w:lsdexception locked="false" priority="9" qformat="true" name="heading 6"&gt;   &lt;w:lsdexception locked="false" priority="9" qformat="true" name="heading 7"&gt;   &lt;w:lsdexception locked="false" priority="9" qformat="true" name="heading 8"&gt;   &lt;w:lsdexception locked="false" priority="9" qformat="true" name="heading 9"&gt;   &lt;w:lsdexception locked="false" priority="39" name="toc 1"&gt;   &lt;w:lsdexception locked="false" priority="39" name="toc 2"&gt;   &lt;w:lsdexception locked="false" priority="39" name="toc 3"&gt;   &lt;w:lsdexception locked="false" priority="39" name="toc 4"&gt;   &lt;w:lsdexception locked="false" priority="39" name="toc 5"&gt;   &lt;w:lsdexception locked="false" priority="39" name="toc 6"&gt;   &lt;w:lsdexception locked="false" priority="39" name="toc 7"&gt;   &lt;w:lsdexception locked="false" priority="39" name="toc 8"&gt;   &lt;w:lsdexception locked="false" priority="39" name="toc 9"&gt;   &lt;w:lsdexception locked="false" priority="35" qformat="true" name="caption"&gt;   &lt;w:lsdexception locked="false" priority="10" semihidden="false" unhidewhenused="false" qformat="true" name="Title"&gt;   &lt;w:lsdexception locked="false" priority="1" name="Default Paragraph Font"&gt;   &lt;w:lsdexception locked="false" priority="11" semihidden="false" unhidewhenused="false" qformat="true" name="Subtitle"&gt;   &lt;w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Strong"&gt;   &lt;w:lsdexception locked="false" priority="20" semihidden="false" unhidewhenused="false" qformat="true" name="Emphasis"&gt;   &lt;w:lsdexception locked="false" priority="59" semihidden="false" unhidewhenused="false" name="Table Grid"&gt;   &lt;w:lsdexception locked="false" unhidewhenused="false" name="Placeholder Text"&gt;   &lt;w:lsdexception locked="false" priority="1" semihidden="false" unhidewhenused="false" qformat="true" name="No Spacing"&gt;   &lt;w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading"&gt;   &lt;w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List"&gt;   &lt;w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid"&gt;   &lt;w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1"&gt;   &lt;w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2"&gt;   &lt;w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1"&gt;   &lt;w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2"&gt;   &lt;w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1"&gt;   &lt;w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2"&gt;   &lt;w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3"&gt;   &lt;w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List"&gt;   &lt;w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading"&gt;   &lt;w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List"&gt;   &lt;w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid"&gt;   &lt;w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 1"&gt;   &lt;w:lsdexception locked="false" unhidewhenused="false" name="Revision"&gt;   &lt;w:lsdexception locked="false" priority="34" semihidden="false" unhidewhenused="false" qformat="true" name="List Paragraph"&gt;   &lt;w:lsdexception locked="false" priority="29" semihidden="false" unhidewhenused="false" qformat="true" name="Quote"&gt;   &lt;w:lsdexception locked="false" priority="30" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Quote"&gt;   &lt;w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 1"&gt;   &lt;w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 2"&gt;   &lt;w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 3"&gt;   &lt;w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 4"&gt;   &lt;w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 5"&gt;   &lt;w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 6"&gt;   &lt;w:lsdexception locked="false" priority="19" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Emphasis"&gt;   &lt;w:lsdexception locked="false" priority="21" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Emphasis"&gt;   &lt;w:lsdexception locked="false" priority="31" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Reference"&gt;   &lt;w:lsdexception locked="false" priority="32" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Reference"&gt;   &lt;w:lsdexception locked="false" priority="33" semihidden="false" unhidewhenused="false" qformat="true" name="Book Title"&gt;   &lt;w:lsdexception locked="false" priority="37" name="Bibliography"&gt;   &lt;w:lsdexception locked="false" priority="39" qformat="true" name="TOC Heading"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Font Definitions */  @font-face  {font-family:"Cambria Math";  panose-1:0 0 0 0 0 0 0 0 0 0;  mso-font-charset:1;  mso-generic-font-family:roman;  mso-font-format:other;  mso-font-pitch:variable;  mso-font-signature:0 0 0 0 0 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal  {mso-style-unhide:no;  mso-style-qformat:yes;  mso-style-parent:"";  margin:0in;  margin-bottom:.0001pt;  mso-pagination:widow-orphan;  font-size:12.0pt;  font-family:"Times New Roman","serif";  mso-fareast-font-family:"Times New Roman";} .MsoChpDefault  {mso-style-type:export-only;  mso-default-props:yes;  font-size:10.0pt;  mso-ansi-font-size:10.0pt;  mso-bidi-font-size:10.0pt;} @page Section1  {size:8.5in 11.0in;  margin:1.0in 1.25in 1.0in 1.25in;  mso-header-margin:.5in;  mso-footer-margin:.5in;  mso-paper-source:0;} div.Section1  {page:Section1;}  /* List Definitions */  @list l0  {mso-list-id:238490871;  mso-list-template-ids:2796016;} @list l0:level1  {mso-level-tab-stop:.5in;  mso-level-number-position:left;  text-indent:-.25in;} ol  {margin-bottom:0in;} ul  {margin-bottom:0in;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable  {mso-style-name:"Table Normal";  mso-tstyle-rowband-size:0;  mso-tstyle-colband-size:0;  mso-style-noshow:yes;  mso-style-priority:99;  mso-style-qformat:yes;  mso-style-parent:"";  mso-padding-alt:0in 5.4pt 0in 5.4pt;  mso-para-margin:0in;  mso-para-margin-bottom:.0001pt;  mso-pagination:widow-orphan;  font-size:10.0pt;  font-family:"Times New Roman","serif";} &lt;/style&gt; &lt;![endif]--&gt;&lt;span style="font-family: arial;font-size:100%;" &gt;&lt;span style="font-size: 10pt;"&gt;If &lt;/span&gt;&lt;span style="font-size: 10pt;"&gt;&lt;/span&gt;&lt;span style="font-size: 10pt;"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt;"&gt;You are appearing for any technical job's interview specially for software and system development you must know the language Java it is considered as the strongest language present in recent times.To make you aware of Java Util class and Thread class there are few frequently asked questions just go through.&lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);font-size:130%;" &gt;Java Interview questions&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;ol start="1" type="1"&gt;&lt;li class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;What is the List interface?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt; - The List      interface provides support for ordered collections of objects.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;What is the Vector class?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt; - The Vector      class provides the capability to implement a growable array of objects &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;What is an Iterator interface?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt; - The Iterator      interface is used to step through the elements of a Collection &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;Which java.util classes and interfaces      support event handling?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt; - The EventObject class and the      EventListener interface support event processing &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;What is the GregorianCalendar      class?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;      - The GregorianCalendar provides support for traditional Western calendars      &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;What is the Locale class?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt; - The Locale      class is used to tailor program output to the conventions of a particular      geographic, political, or cultural region &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;What is the SimpleTimeZone class?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt; - The      SimpleTimeZone class provides support for a Gregorian calendar &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;What is the Map interface?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt; - The Map      interface replaces the JDK 1.1 Dictionary class and is used associate keys      with values &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;What is the highest-level event      class of the event-delegation model?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt; - The java.util.EventObject      class is the highest-level class in the event-delegation class hierarchy &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;What is the Collection interface?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt; - The      Collection interface provides support for the implementation of a      mathematical bag - an unordered collection of objects that may contain      duplicates &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;What is the Set interface?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt; - The Set      interface provides methods for accessing the elements of a finite      mathematical set. Sets do not allow duplicate elements &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;What is the purpose of the      enableEvents() method?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt; - The enableEvents() method is used to enable an      event for a particular object. Normally, an event is enabled when a      listener is added to an object for a particular event. The enableEvents()      method is used by objects that handle events by overriding their      event-dispatch methods. &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;What is the ResourceBundle class?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt; - The      ResourceBundle class is used to store locale-specific resources that can      be loaded by a program to tailor the program’s appearance to the      particular locale in which it is being run.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;What is the difference between      yielding and sleeping?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&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;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;When a thread blocks on I/O, what      state does it enter?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt; - A thread enters the waiting state when it blocks      on I/O. &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;When a thread is created and      started, what is its initial state?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt; - A thread is in the ready state after      it has been created and started. &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;What invokes a thread’s run()      method?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;      - After a thread is started, via its start() method or that of the Thread      class, the JVM invokes the thread’s run() method when the thread is      initially executed. &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;What method is invoked to cause      an object to begin executing as a separate thread?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt; - The start()      method of the Thread class is invoked to cause an object to begin      executing as a separate thread. &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;What is the purpose of the      wait(), notify(), and notifyAll() methods?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt; - The      wait(),notify(), and notifyAll() methods are used to provide an efficient      way for threads to wait for a shared resource. When a thread executes an      object’s wait() method, it enters the waiting state. It only enters the      ready state after another thread invokes the object’s notify() or      notifyAll() methods. &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;What are the high-level thread      states?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;      - The high-level thread states are ready, running, waiting, and dead &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;What happens when a thread cannot      acquire a lock on an object?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt; - If a thread attempts to execute a      synchronized method or synchronized statement and is unable to acquire an      object’s lock, it enters the waiting state until the lock becomes      available. &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;How does multithreading take      place on a computer with a single CPU?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt; - The operating system’s task      scheduler allocates execution time to multiple tasks. By quickly switching      between executing tasks, it creates the impression that tasks execute      sequentially. &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;What happens when you invoke a      thread’s interrupt method while it is sleeping or waiting?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt; - When a task’s      interrupt() method is executed, the task enters the ready state. The next      time the task enters the running state, an InterruptedException is thrown.      &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="margin-bottom: 12pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;What state is a thread in when it      is executing?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;      - An executing thread is in the running state &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;What are three ways in which a      thread can enter the waiting state?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt; - A thread can enter the waiting state      by invoking its sleep() method, by blocking on I/O, by unsuccessfully      attempting to acquire an object’s lock, or by invoking an object’s wait()      method. It can also enter the waiting state by invoking its (deprecated)      suspend() method. &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="color: rgb(51, 51, 255);" class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;o:p&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;Suggested Reading:-&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="color: rgb(51, 51, 255);" class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;o:p&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="color: rgb(51, 51, 255);" class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;o:p&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/05/java-basic-questionscontrol-statements.html"&gt;Java Basic Questions Control statements&lt;/a&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="color: rgb(51, 51, 255);" class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;o:p&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/05/simple-java-twisters.html"&gt;Simple Java Twisters&lt;/a&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;o:p&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;&lt;a href="http://javatutorialsworld.blogspot.com/search/label/Interview%20Questions"&gt;All Interview questions&lt;/a&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-7769133358247511254?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/7769133358247511254/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/08/java-interview-questions-utilities-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/7769133358247511254'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/7769133358247511254'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/08/java-interview-questions-utilities-and.html' title='Java Interview questions Utilities and Threads'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-2064845459454501596</id><published>2009-07-30T16:24:00.005+05:30</published><updated>2009-07-30T17:05:59.058+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Authors Update'/><title type='text'>Microsoft and Google JV to Target Google search Market</title><content type='html'>&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_1CvsF-MJpr4/SnGEq80g-5I/AAAAAAAAAOw/yN1AzYLxrF8/s1600-h/microsoft_logo.jpg"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 320px; height: 202px;" src="http://3.bp.blogspot.com/_1CvsF-MJpr4/SnGEq80g-5I/AAAAAAAAAOw/yN1AzYLxrF8/s320/microsoft_logo.jpg" alt="" id="BLOGGER_PHOTO_ID_5364214504590736274" border="0" /&gt;&lt;/a&gt;Microsoft and Yahoo signed a 10 year pact to outsource the search technologies to beat the search engine market leader Google.Under this pact Microsoft will provide the underlying search technology on Yahoo's popular websites.The deal provides a lift for the recent overhaul of its search engine Bing.Bing has already won praises and favourable reviews after falling behind Google.Running such a search system proves expensive ,and Microsoft can now filter more searches through the Bing technology infrastructure.Bing expects to deliver better answers by learning through a series of user queries.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The term of 10 years agreement calls for Microsoft to license the Yahoo's search technologies in return Yahoo will receive a lucrative 88% of search generated revenue initially.The workload for advertising will be split.Yahoo on one hand will focus on premium advertisers whereas on the other hand Microsoft will focus on medium and small advertisers.The decision of advertising rates will be solely through the auction.&lt;br /&gt;&lt;br /&gt;Based on study the fact came out that Google own's 78% marketshare in search engines.Combining both Yahoo and Microsoft will never be close to it.But they can aim at that to increase the share by providing accurate searches.The revenue is completely monopolised by the Google and no match between them.&lt;br /&gt;&lt;br /&gt;In a statement the Microsoft CEO Steven A Ballmer said,"Through this agreement with Yahoo ,we will create more innovation in search ,better value for advertisers and real consumer choice in the market currently dominated by single comp[any".&lt;br /&gt;&lt;br /&gt;Even united,Microsoft and Yahoo will continue to be dwarfed by Google in search.Yet the combination of Microsoft and Yahoo in online search creates a far powerful counterweight to Google,one that will be welcomed by many in the advertising industry,which has watched Google rapidly becoming the world's largest seller for advertising.For Microsoft the combination with Yahoo is the quickest way to increase use of its nearly revamped and restructured search engine Bing.&lt;br /&gt;&lt;br /&gt;&lt;a style="font-weight: bold; color: rgb(255, 0, 0);" href="http://www.AffiliateHarvest.com/click.aspx?adID=25&amp;amp;affID=86"&gt;Are you Intelligent!!!! Check&lt;/a&gt;&lt;br /&gt;&lt;a style="font-weight: bold; color: rgb(255, 0, 0);" href="http://www.ucertify.com/?af=vaibhav"&gt;Get your SCJP kit now free!!!&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-2064845459454501596?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/2064845459454501596/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/07/microsoft-and-google-jv-to-target.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/2064845459454501596'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/2064845459454501596'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/07/microsoft-and-google-jv-to-target.html' title='Microsoft and Google JV to Target Google search Market'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_1CvsF-MJpr4/SnGEq80g-5I/AAAAAAAAAOw/yN1AzYLxrF8/s72-c/microsoft_logo.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-7678992503076877986</id><published>2009-07-28T00:11:00.005+05:30</published><updated>2009-07-28T15:14:34.064+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='SCJP'/><category scheme='http://www.blogger.com/atom/ns#' term='Authors Update'/><title type='text'>Untold truths about Sun Certified Java Programmer(SCJP)</title><content type='html'>&lt;div style="text-align: justify;"&gt;Being a Sun Certified Java Programmer(SCJP) is undoubtedly a matter a proud,But due to immense increase in qualified Human Resource especially in IT/ITES sector, it is no more a matter of proud.Once upon a time(2-3 years back) we know that if anyone is Sun Certified or holds a Sun Certification he will surely get a good job which will give him opportunity to earn as well as learn and grow in person.There are many types of certifications are provided by Sun likewise SCJP,SCJA,SCWCD and so on.Which are developed to test one's knowledge and skills in particular field of specialization. What I clearly want to mention is if you do something do it as nobody else can do.That is if you are preparing for SCJP then you must qualify the exam with atleast 80% marks.Otherwise it will be useless.I have a case for you, I know a guy who is SUN Certified (SCJP) he works in a private firm and only gets Rs. 12,000/- Per Month ($ 600).You may think it is too less but it is reality here in India.He scored only 64% marks in SCJP exam.In current economic scenario and increasing competition take such students to work for less and that's pity about India.&lt;br /&gt;&lt;br /&gt;Now come to the Examination part.Most of guys must know that India is a corrupt country.Let me tell you it is not the whole reality it is framed by media and persons who cannot see India grow.Still it is major factor.I also heard somewhere that here you can pass the exam by spending some extra money.You will get whole bunch of papers and questions will be asked from that.I tried to find out and it was around the cost of the coupon that you buy for the exam.This is pathetic and true injustice with the hardworking students.This way the peoples are just degrading the value of the Sun Certificate,nothing else.&lt;br /&gt;&lt;br /&gt;You might be living in any part of the world but the silly thing is that you will never get a value for your thing.Like you will never get a expected job according to your qualifications.&lt;br /&gt;&lt;br /&gt;I have another case for you that one of my friend knows nothing about programming and still managed to get a job in a giant IT company @ Rs. 21,000/- per month($ 1,050),almost 1.75 times the person who has qualified the SCJP.when I look at them I need to think well its luck or may be something else,maybe he's not able to show up his skills or anything.In terms of qualification its really unfair.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;If you are outside India you may find yourself lucky that there are not that much Sun Certified programmers but India is a place full of certified programmers.It doesn't matter whether you are an Indian or not ,but looking forward to SCJP.Then keep pulling weights even more,otherwise you will be just another SCJP.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Most important thing never get out of touch.That is keep revising and testing your concepts with new ideas and codes.This way you will keep away from being rusted and at the same time when you will get a call for interview you will turn up positively,full of confidence.Big boys know how important confidence is in Interviews.&lt;br /&gt;&lt;br /&gt;I am not discouraging you from giving SCJP but I want you to know the ground reality of SCJP.It would be better if you try for Cisco Certification ,Oracle Certification etc.Their demand is much higher than SCJP.It is the market trend.SCJP is a bit saturated field.You have to be a bit different that other Sun certification holders.&lt;br /&gt;All the best ;-]&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;SCJP Resources:-&lt;/span&gt;&lt;br /&gt;&lt;a href="http://www.ucertify.com/?af=vaibhav"&gt;&lt;br /&gt;Get your SCJP preparation kit now!!!!&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/07/scjp-sun-certified-java-programmer-best.html"&gt;SCJP best ebook download&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/07/scjp-best-exam-preperation-kitbest-scjp.html"&gt;SCJP best exam preparation kit download&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/05/tips-to-crack-scjp.html"&gt;SCJP exam passing tips and tricks&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/05/scjp310-065-exam-objectives.html"&gt;SCJP exam objective.&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-7678992503076877986?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/7678992503076877986/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/07/untold-truths-about-sun-certified-java.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/7678992503076877986'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/7678992503076877986'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/07/untold-truths-about-sun-certified-java.html' title='Untold truths about Sun Certified Java Programmer(SCJP)'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-234603321786726067</id><published>2009-07-23T15:54:00.007+05:30</published><updated>2009-08-19T02:29:24.801+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='SCJP'/><category scheme='http://www.blogger.com/atom/ns#' term='EBooks'/><title type='text'>SCJP Sun Certified Java Programmer best Ebook Free Download</title><content type='html'>&lt;div style="text-align: justify;"&gt;Download SCJP5 ebook for free.The chapters listed here are taken from the latest book of SCJP 5 written by Catherine Sierra and Bert Bates.This book is considered as best book for the preparation of SCJP.Catherine Sierra has been a renowned author who has written many books in Java including the most selling Big Java.This ebook is regarded as best in world for the preparation of SCJP Sun Certified Java Programmer.This is No.1 selling in Amazon.com.I am providing these links because I want study should be of low cost  in fact free. It is a good book for those who has some basic knowledge of Java but want to learn other core concepts.To download the SCJP5 ebook Catherine Sierra and Bert Bates click on following Links.The links are given in Chapter wise order as it makes easy to study,and download.You can bookmark this page and come back when you need particular chapter for study.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Free Download Links:-&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;ul style="text-align: justify; color: rgb(51, 51, 255);"&gt;&lt;li&gt;&lt;a href="http://www.easy-share.com/1906877548/chap1.pdf"&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Chapter 1&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;&lt;a href="http://www.easy-share.com/1906877587/chap2.pdf"&gt;Chapter 2&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;&lt;a href="http://www.easy-share.com/1906877651/chap3.pdf"&gt;Chapter 3&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;&lt;a href="http://www.easy-share.com/1906877666/chap4.pdf"&gt;Chapter 4&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;&lt;a href="http://www.easy-share.com/1906877688/chap5.pdf"&gt;Chapter 5&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;&lt;a href="http://www.easy-share.com/1906877714/chap6.pdf"&gt;Chapter 6&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;&lt;a href="http://www.easy-share.com/1906877733/chap7.pdf"&gt;Chapter 7&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.easy-share.com/1906877751/chap8.pdf"&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Chapter 8&lt;br /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;&lt;a href="http://www.easy-share.com/1906877763/chap9.pdf"&gt;Chapter 9&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.easy-share.com/1906877772/chap10.pdf"&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Chapter 10&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Suggested Links:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/08/scwcd-best-ebook-free-download.html"&gt;SCWCD Free ebook download&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.ucertify.com/?af=vaibhav"&gt;Get you SCJP preparation kit now!!!!&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/07/scjp-best-exam-preperation-kitbest-scjp.html"&gt;SCJP best exam preperation Kit free download&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/05/tips-to-crack-scjp.html"&gt;Tips to Crack SCJP&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/05/scjp310-065-exam-objectives.html"&gt;SCJP 310-065 Exam Objectives&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;*&lt;span style="font-weight: bold;font-size:85%;" &gt;Disclaimer these links does not belong to the author.These are found over Internet and author is not responsible for them.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-234603321786726067?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/234603321786726067/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/07/scjp-sun-certified-java-programmer-best.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/234603321786726067'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/234603321786726067'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/07/scjp-sun-certified-java-programmer-best.html' title='SCJP Sun Certified Java Programmer best Ebook Free Download'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-697986669506136617</id><published>2009-07-23T15:25:00.002+05:30</published><updated>2009-07-23T15:28:49.278+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Access Control and Declaration'/><category scheme='http://www.blogger.com/atom/ns#' term='Object Oriented'/><title type='text'>Variable Shadowing Complexities Can you figure out??</title><content type='html'>&lt;div style="text-align: justify;"&gt;There are many ways so that we can shadow our variables.One way is to hide an instance variable by shadowing it by local variable.Shadowing happens when we redecalre a variable that has already been declared somewhere else in the program.The effect of shadowing is to hide certain variables in such a way that it may look as though you are using the hidden variable,but you are actually using shadowed variable.&lt;br /&gt;&lt;br /&gt;Typically it happens by accidents which returns some hard to find bugs,and there are reasons where you wish to use variable shadowing.&lt;br /&gt;&lt;br /&gt;I assume you have no knowledge of Shadowing previously that's why here is one example followed by a practice question but it will be in different may:-&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Example:-&lt;/span&gt;Shadowing instance variable with a local variable.&lt;br /&gt;&lt;br /&gt;class dimensions{&lt;br /&gt;static int height=20;&lt;br /&gt;static void changeHeight(int height){&lt;br /&gt;height=height+400;&lt;br /&gt;System.out.println("height in changeHeight  "+height);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public static void main(String a[]){&lt;br /&gt;dimension dim=new dimension();&lt;br /&gt;System.out.println("height before changeHeight"+height);&lt;br /&gt;changeHeight(height);&lt;br /&gt;System.out.println("height after changeHeight"+height);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;When you will execute the above code the output would be:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;height before changeHeight  20&lt;br /&gt;height in changeHeight  420&lt;br /&gt;height after changeHeight  20&lt;br /&gt;&lt;br /&gt;It is quite simple to understand since this is a call by value method call we call method changeHeight() by passing the copy of height instance variable.Since call by value passes value in bits thus local variable gets all the value of instance variable and thus all the operations are done on local variable rather than instance variable and instance variable remains untouched.&lt;br /&gt;&lt;br /&gt;That was quite simple though but solve the following its quite messy.&lt;span style="font-weight: bold;"&gt;I&lt;/span&gt;&lt;span style="font-weight: bold;"&gt; will appreciate if you solve this and write the solution as a comment.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;class MyNumber{&lt;br /&gt;int number=44;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class ChangeNumber{&lt;br /&gt;MyNumber mynum=MyNumber();&lt;br /&gt;void changeNumber(MyNumber mynum){&lt;br /&gt;mynum.number=88;&lt;br /&gt;System.out.println("mynum.number in changeNumber is  "+mynum.number);&lt;br /&gt;mynum=new MyNumber();&lt;br /&gt;mynum.number=99;&lt;br /&gt;System.out.println("mynum.number in changeNumber is now  "+mynum.number);&lt;br /&gt;}&lt;br /&gt;public static void main(String a[]){&lt;br /&gt;ChangeNumber chgnum=new ChangeNumber();&lt;br /&gt;System.out.println("chgnum.mynum.number in changeNumber is  "+chgnum.mynum.number);&lt;br /&gt;chgnum.changeNumber(chgnum.mynum);&lt;br /&gt;System.out.println("chgnum.mynum.number after changeNumber is  "+chgnum.mynum.number);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;What would be its output???&lt;/span&gt;&lt;br /&gt;Think and answer.Post answer in comments section.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-697986669506136617?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/697986669506136617/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/07/variable-shadowing-complexities-can-you.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/697986669506136617'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/697986669506136617'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/07/variable-shadowing-complexities-can-you.html' title='Variable Shadowing Complexities Can you figure out??'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-6644667423435834177</id><published>2009-07-21T13:13:00.003+05:30</published><updated>2009-07-21T13:22:32.432+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Object Oriented'/><title type='text'>Interface legal declaration rules and issues</title><content type='html'>&lt;div style="text-align: justify;"&gt;Interfaces follow certain rules which you need to know in order to become an Java expert.There are two rules mainly for interfaces implementation and declaration.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;1.A class can implement more than one interface.That is the following declaration is perfectly legal:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;public class Subaru implements Colorable,speedable{// Horrible code here}&lt;br /&gt;&lt;br /&gt;It is evident that you can extend only one class ,but you can implement many interfaces.The implemented interface describes the role the class will play.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;2.An Interface can extend other Interfaces,but never implement anything.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Following is perfectly legal:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;interface Colorable extends Paintable{ ... }&lt;br /&gt;&lt;br /&gt;This requires some thinking from you for a moment.Ok,lets see what happens in this case,here the first concrete (non abstract) implementation class of Colorable must implement all the methods from Colorable and also we have to implement all the buck of Paintable interface.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;IMPORTANT:-&lt;/span&gt;An Interface can extend more than one Interface.&lt;br /&gt;&lt;br /&gt;whoa!! this is strange we have never seen a class who can extend more than one class but what a mess Interface does this.It needs severe attention ...&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;For example :-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;interface Colorable extends Paintable,Sprayble,Movable{ ... }  // Perfectly legal&lt;br /&gt;&lt;br /&gt;public class Subaru implements Colorable { ... }&lt;br /&gt;&lt;br /&gt;The more interfaces the implemented interface will extend more messy it will for first concrete implementation of the interface.That is it has to implement all the methods of Colorable and also of all other extended interfaces.In this case of Paintable,Movable,Sprayble.&lt;br /&gt;&lt;br /&gt;It doesn't matter whether you provide some thing inside implemented methods.You can left the implemented methods empty.&lt;br /&gt;&lt;br /&gt;If the first implementation is an abstract class then the first concrete subclass of abstract class has to do all the work,implementation of all the methods.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Other Interface tutorials:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/04/interface-declaration.html"&gt;Interface declaration rules&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/07/interfacesrules-and-explanations.html"&gt;Interface rules and explanations&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/07/why-java-not-support-multiple.html"&gt;Why Java not support multiple inheritance&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-6644667423435834177?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/6644667423435834177/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/07/interface-legal-declaration-rules-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/6644667423435834177'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/6644667423435834177'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/07/interface-legal-declaration-rules-and.html' title='Interface legal declaration rules and issues'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-5553059462910548245</id><published>2009-07-20T22:44:00.005+05:30</published><updated>2009-07-21T13:21:56.229+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Access Control and Declaration'/><category scheme='http://www.blogger.com/atom/ns#' term='Object Oriented'/><title type='text'>Interfaces:rules and explanations</title><content type='html'>&lt;div style="text-align: justify;"&gt;Interfaces are indeed the most important part of the Java OO paradigm.It enables Java to indirectly implement Multiple inheritance.In order to implement an Interface you have to adhere to certain rules defined for its implementation.Interfaces are implemented using "implements" keyword.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Example:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;interface Car_attributes{&lt;br /&gt;void accelerate();&lt;br /&gt;void color();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;The main point to note here is that whenever you implement an interface you have to implement all the methods described in the interface.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Example:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;public class Subaru implements Car_attributes{&lt;br /&gt;public void accelerate(){// Code}&lt;br /&gt;public void color(){// Code}&lt;br /&gt;public void gears(){// Code}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Here in above example Subaru class implements Car_attributes interface then Subaru has to mention all methods of Car_attributes interface.Otherwise compiler will not hesitate in slapping you with an error.But still world is full of exceptions and Interfaces are not a superhero(I hope you have watched Superhero Movie).We will look at those exceptions in a few moments.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;The implementation classes must adhere to the some rules and these applies to the non abstract&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;implementation:-&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;1.Provide non abstract(concrete) implementation for all the methods of the interface.&lt;br /&gt;2.Follow all rules of legal overriding.&lt;br /&gt;3.Maintain the signature of the interface method,and also maintain the same return types.&lt;br /&gt;4.You need not declare the exceptions declared in the interface method declaration.&lt;br /&gt;5.Declare no checked exception on implementation methods other than those declared by the interface method ,or subclass of those declared by the interface method.&lt;br /&gt;&lt;br /&gt;Wait wait!! there comes the exception that is "if implementation class is abstract class then the abstract class will pass all its work to its first concrete subclass ".&lt;br /&gt;Lets take a look at following example:-&lt;br /&gt;&lt;br /&gt;**Suppose bounceable interface has a method bounce()&lt;br /&gt;&lt;br /&gt;abstract class ball implements bounceable{}&lt;br /&gt;&lt;br /&gt;class Football extends bounceable{&lt;br /&gt;public void bounce(){// Code}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;That is since Ball the implementing an interface and it is an abstract class then the sub class of Ball will implement all the methods declared in bounceable interface.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Interface Other Tutorials:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/04/interface-declaration.html"&gt;Interface declaration rules&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/07/interface-legal-declaration-rules-and.html"&gt;Interface legal declaration rules and issues&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/07/why-java-not-support-multiple.html"&gt;Why Java not support multiple inheritance&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-5553059462910548245?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/5553059462910548245/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/07/interfacesrules-and-explanations.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/5553059462910548245'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/5553059462910548245'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/07/interfacesrules-and-explanations.html' title='Interfaces:rules and explanations'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-3235684352193006745</id><published>2009-07-15T15:28:00.005+05:30</published><updated>2009-07-15T16:15:11.443+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='JDBC'/><title type='text'>Adding Records in database JDBC</title><content type='html'>&lt;div style="text-align: justify;"&gt;In our applications most of the times we need to store the records and values in our database.Java provides ways to add records and data in database through JDBC.First of all you need to know the basics of Java.There are &lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;two types of JDBC Statements&lt;/span&gt; that can be used for addition of record in database.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;1.Statement&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;2.PreparedStatement&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;We will see how we can add records in database through both Statement types.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;1.Through Statement object:-&lt;/span&gt;using Statement class object we can run our static queries.Suppose if we want to add a fixed record in database each time query is processed,then only we can use Statement object.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;For Example:-&lt;/span&gt;&lt;br /&gt;public void addRecord(){&lt;br /&gt;try{&lt;br /&gt;stat.executeUpdate("insert employee values('X',20,2000)");&lt;br /&gt;}catch(Exception e){}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Here in this case we are bound to use one query time the method add Record() is executed.This results in addition of same record in the database.This can prove to be a restriction on any application's functionality.&lt;br /&gt;For solving above problem we use &lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;PreparedStatement object&lt;/span&gt;.Through PreparedStatement object we can pass values during runtime and make our application dynamic.This method also uses concept of &lt;a href="http://javatutorialsworld.blogspot.com/2009/03/using-prepared-statement.html"&gt;Placeholders&lt;/a&gt; on which the value is being passed.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Example:-&lt;/span&gt;&lt;br /&gt;*&lt;span style="font-size:78%;"&gt;assumptions required&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;public void addRecord(){&lt;br /&gt;try{&lt;br /&gt;Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");&lt;br /&gt;Connection con=DriverManager.getConnection("Jdbc:Odbc:MyData","","");&lt;br /&gt;PreparedStatement pstat=con.createStatement("insert employee value(?,?,?)");&lt;br /&gt;pstat.setInt(1,20);&lt;br /&gt;pstat.setInt(1,200);&lt;br /&gt;pstat.setInt(1,2000);&lt;br /&gt;pstat.executeUpdate();&lt;br /&gt;}catch(Exception e){}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;NOTE:-&lt;/span&gt;you can set values by taking input from text boxes dynamically like following:-&lt;br /&gt;                             //pstat.setInt(1,text1.getText());&lt;br /&gt;&lt;br /&gt;Suggested Reading and Links:-&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/07/how-to-delete-record-in-database.html"&gt;JDBC:how to delete a record&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/03/using-prepared-statement.html"&gt;JDBC:PreparedStatement Object&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/03/detailed-jdbc-example-statement-object.html"&gt;JDBC:Statement Object&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/03/jdbc-resultset-object.html"&gt;JDBC:ResultSet Object&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/03/database-querying.html"&gt;querying database&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/03/connecting-to-database.html"&gt;connecting to database&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/03/configuring-odbc-data-source-for-jdbc.html"&gt;Configuring data source&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/03/jdbcintroduction.html"&gt;JDBC :Introduction&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-3235684352193006745?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/3235684352193006745/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/07/adding-records-in-database-jdbc.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/3235684352193006745'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/3235684352193006745'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/07/adding-records-in-database-jdbc.html' title='Adding Records in database JDBC'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-8762862190420902002</id><published>2009-07-14T13:29:00.002+05:30</published><updated>2009-07-14T13:34:12.996+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='SCJP'/><category scheme='http://www.blogger.com/atom/ns#' term='Authors Update'/><title type='text'>SCJP best Exam preperation kit,Best SCJP quiz engine for free Download</title><content type='html'>&lt;div style="text-align: justify;"&gt;The SCJP 310-065 exam is not easy to crack.I have an experience of using the UCertify's SCJP 310-065 exam preparation kit for quite a long time,and it is needed the best exam preparation kit available.I have also tried several other SCJP preparations kits buts they never worth money I have spent on them.UCertify offers a great SCJP 310-065 exam preparations kit which has a lot of features to consider and also as nothing is perfect a few drawbacks lets take a look:-&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Features of UCertify SCJP exam preparation kit:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;1.Very good collection of qulaity questions.which you can expect in the exam.&lt;br /&gt;2.Tests in the preparation kit are timed tests.&lt;br /&gt;3.Clearly mentioned exam objectives.&lt;br /&gt;4.Exajm specific notes.&lt;br /&gt;5.Practice questions with every exam objective notes.&lt;br /&gt;6.You can create your own custom tests timed or not.&lt;br /&gt;7.There is also an interactive tests which adds interactivity in testing your skills.&lt;br /&gt;8.Nine high quality timed tests to test your caliber.&lt;br /&gt;9.Tips to success small little tips but are beneficial in huge way.&lt;br /&gt;10.Articles present to make basic concepts very clear.&lt;br /&gt;11.There is a final test which you can take finally if you think you studied enough to take the exam.&lt;br /&gt;12.The quiz engine is a learning machine which keeps on storing your past scores and let you compare your previous performances to the current one.&lt;br /&gt;13.You can check out if you are ready for the exam by checking the exam readiness report.&lt;br /&gt;14.UCertify exam preparation is available for free.&lt;br /&gt;15.About 700 high quality certification questions covering all objectives.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Shortcomings of UCertify SCJP exam preparation kit:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;1.The detailed description is not given in the notes.For that you have to refer some book.&lt;br /&gt;2.Study notes which includes objective specific questions are too simple.&lt;br /&gt;&lt;br /&gt;All the above features I think are good enough to try out the UCertify SCJP exam preparation guide.The advantages clearly outweighs the shortcomings.&lt;br /&gt;There is much more You can try the quiz engine for free to download click below:-&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a href="http://www.ucertify.com/download/CX310-065.html"&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;UCertify SCJP 310-065 exam preparation kit free download Trail&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Limited Period Offer&lt;/span&gt;:-&lt;br /&gt;&lt;br /&gt;Special offer for Java World Readers&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt; get 10% off &lt;/span&gt; on every product you buy from the UCertify By just mentioning the &lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Coupon Code "UCPREP"&lt;/span&gt;.What's more all products of UCertify comes with a money back guarantee.If you think that the product is not good enough to let you crack the exam you can take your money back.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-weight: bold; color: rgb(255, 0, 0); text-align: center;"&gt;&lt;a style="color: rgb(255, 0, 0);" href="http://www.ucertify.com/download/CX310-065.html"&gt;UCertify SCJP preparation kit :best SCJP exam preparation Kit download now for free!!!&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-8762862190420902002?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/8762862190420902002/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/07/scjp-best-exam-preperation-kitbest-scjp.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/8762862190420902002'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/8762862190420902002'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/07/scjp-best-exam-preperation-kitbest-scjp.html' title='SCJP best Exam preperation kit,Best SCJP quiz engine for free Download'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-4143716317784233389</id><published>2009-07-12T15:01:00.006+05:30</published><updated>2009-07-12T15:24:51.183+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Object Oriented'/><title type='text'>IS-A and HAS-A relationship :Every thing JAVA is in Relationship</title><content type='html'>Java represents two types of relationships:-&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;1.IS-A relationship&lt;br /&gt;2.HAS-A relationship&lt;br /&gt;&lt;br /&gt;&lt;font style="font-weight: bold; color: rgb(0, 0, 0);"&gt;IS-A Relationship:-&lt;/font&gt;In object oriented programming,the concept of IS-A is a totally based on Inheritance(extends) and Interface implementation(implements).It is just like saying "A is a B type of thing".For example ,5-Star is a chocolate,Subaru Impreza is a car etc.&lt;br /&gt;It is key point to note that you can easily identify the IS-A relationship .Wherever you see an extends keyword or implements keyword in a class declaration,then this class is said to be passed IS-A relationship.&lt;br /&gt;&lt;br /&gt;&lt;font style="font-weight: bold; color: rgb(51, 51, 255);"&gt;For Example:-&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;class Car{&lt;br /&gt;// lots of complex work&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class Impreza extends Car{&lt;br /&gt;//Impreza extends and thus inherit all methods from Car (except final and static)&lt;br /&gt;//Impreza can also define all his specific functionality&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;From the above code we can say "Car is a Vehicle","Impreza is a Car", this in turn reflects a transitive relationship that "Impreza is a Vehicle".&lt;br /&gt;&lt;br /&gt;&lt;font style="font-weight: bold; color: rgb(0, 0, 0);"&gt;The relationship can be shown as below:-&lt;/font&gt;&lt;br /&gt;Arrow direction from subclass to super class&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_1CvsF-MJpr4/SlmxXWdHcWI/AAAAAAAAAOQ/F55fqwO9BfU/s1600-h/isa+hasa.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 201px; height: 193px;" src="http://4.bp.blogspot.com/_1CvsF-MJpr4/SlmxXWdHcWI/AAAAAAAAAOQ/F55fqwO9BfU/s400/isa+hasa.jpg" alt="" id="BLOGGER_PHOTO_ID_5357508246456725858" border="0"&gt;&lt;/a&gt;&lt;br /&gt;&lt;font style="font-weight: bold; color: rgb(0, 0, 0);"&gt;HAS-A Relationship:-&lt;/font&gt;HAS-A relationship has nothing to do with Inheritance rather it is based on the usage of various variables and methods of other class.We can say "A HAS-A B if the code in class A has reference to an instance of B".Make it more clear look at following example:-&lt;br /&gt;&lt;br /&gt;public class Car{}&lt;br /&gt;&lt;br /&gt;class Impreza extends Car{&lt;br /&gt;private Subaru_feature subaru_features;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;As you can see Impreza HAS-A instance variable of type Subaru.That is we can say "Impreza HAS-A Subaru_feature ".Simply here Impreza has a reference type of Subaru_feature.Impreza can use the reference variable to invoke the subaru features without caring about the Subaru_feature code.HAS-A relationship is indicated by following figure:-&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_1CvsF-MJpr4/SlmxXjntvSI/AAAAAAAAAOY/5pvFnXpp8G8/s1600-h/isa+hasa2.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 189px;" src="http://3.bp.blogspot.com/_1CvsF-MJpr4/SlmxXjntvSI/AAAAAAAAAOY/5pvFnXpp8G8/s400/isa+hasa2.jpg" alt="" id="BLOGGER_PHOTO_ID_5357508249990839586" border="0"&gt;&lt;/a&gt;&lt;br /&gt;HAS-A relationship makes each and every class a specialist class.Making specialists classes has numerous benefits including reduction in bugs,easily tractable errors,Less complex code,reduction in code redundancy and most of code is easily understandable.The more specialist a class is the &lt;a href="http://javatutorialsworld.blogspot.com/2009/07/why-code-reuse-is-exclusive-feature-of.html"&gt;code reuse&lt;/a&gt; is even better.Its a good Object Oriented practice to use HAS-A relationship.&lt;br /&gt;&lt;br /&gt;&lt;font style="font-weight: bold; color: rgb(255, 0, 0);"&gt;Suggested links:-&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/"&gt;Home&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/search/label/Object%20Oriented"&gt;complete OO tutorials&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/07/inheritance-complete-explanation.html"&gt;Inheritance complete explanation&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/07/why-java-not-support-multiple.html"&gt;Why Java not support multiple Inheritance?&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/07/why-code-reuse-is-exclusive-feature-of.html"&gt;Why code reuse is an exclusive feature of Inheritance&lt;/a&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/07/why-code-reuse-is-exclusive-feature-of.html"&gt;.&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/07/polymorphismcore-of-object-oriented.html"&gt;Polymorphism:Core of Object Oriented Programming&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-4143716317784233389?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/4143716317784233389/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/07/is-and-has-relationship-every-thing.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/4143716317784233389'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/4143716317784233389'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/07/is-and-has-relationship-every-thing.html' title='IS-A and HAS-A relationship :Every thing JAVA is in Relationship'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_1CvsF-MJpr4/SlmxXWdHcWI/AAAAAAAAAOQ/F55fqwO9BfU/s72-c/isa+hasa.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-5298142438289039207</id><published>2009-07-11T17:01:00.003+05:30</published><updated>2009-07-11T17:13:25.866+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Object Oriented'/><title type='text'>Inheritance complete explanation</title><content type='html'>Inheritance is key concept in Java.It is almost everywhere in Java.It is nearly impossible to write the tiniest Java program without Inheritance.We all create classes in Java programs.Whenever we create a Java class we automatically inherit all of class object methods.&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Inheritance has two key concepts:-&lt;/span&gt;&lt;br /&gt;1&lt;a href="http://javatutorialsworld.blogspot.com/2009/07/why-code-reuse-is-exclusive-feature-of.html"&gt;.Code Reuse&lt;/a&gt;&lt;br /&gt;2.&lt;a href="http://javatutorialsworld.blogspot.com/2009/07/polymorphismcore-of-object-oriented.html"&gt;Polymorphism&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Inheritance means someone or something derives a set of attributes and properties from someone or something else,like lucky inherited diabetes from his father,Craig inherited his father's business.&lt;br /&gt;&lt;br /&gt;Inheritance is one of the ways of implementing abstraction.As we know that abstraction is all about describing the essential detail and ignoring non-essential details.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Note:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;1.When a class inherits a set of attributes and behaviours from another class ,then class that inherits is called subclass and class from which attributes and behaviours are inherited is called super class.&lt;br /&gt;&lt;br /&gt;2.An abstract superclass is a conceptual class which does not contain any code in particular but acts as a base from which other class inherits properties.&lt;br /&gt;&lt;br /&gt;3.When a class inherits from two or more superclasses then it is be showing multiple inheritance.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Complete Example:-&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_1CvsF-MJpr4/Slh52HHuAiI/AAAAAAAAAOI/jMoVL6gYtIk/s1600-h/inheritance.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 168px;" src="http://1.bp.blogspot.com/_1CvsF-MJpr4/Slh52HHuAiI/AAAAAAAAAOI/jMoVL6gYtIk/s400/inheritance.png" alt="" id="BLOGGER_PHOTO_ID_5357165727288525346" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Look at above figure ,In the given hierarchy,we have classes named Mammals,Dogs,Humans,Cats,Lions,Tigers,Leopards .Mammals class has following properties:-&lt;br /&gt;1.They are vertebrates&lt;br /&gt;2.They are warm blooded&lt;br /&gt;3.They have hairs on their body&lt;br /&gt;&lt;br /&gt;From the hierarchy it is clear that Dogs,Cats and Humans also have these characteristics too.In technical terms we can say that above mentioned classes have inherited these attributes from Mammal class.&lt;br /&gt;&lt;br /&gt;The description given above does not contain any vertebral nature of skeletal system,it being warm blooded,its ears,hairs on the body and other features have already been described for the class Mammals and since cats inherit these features from Mammals,only the details specific to the cats need to mentioned in its class.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Suggested Links:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/search/label/Object%20Oriented"&gt;Object Oriented Concepts&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/07/why-java-not-support-multiple.html"&gt;Why Java Not support multiple Inheritance&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-5298142438289039207?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/5298142438289039207/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/07/inheritance-complete-explanation.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/5298142438289039207'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/5298142438289039207'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/07/inheritance-complete-explanation.html' title='Inheritance complete explanation'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_1CvsF-MJpr4/Slh52HHuAiI/AAAAAAAAAOI/jMoVL6gYtIk/s72-c/inheritance.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-6772541732270475525</id><published>2009-07-09T15:04:00.001+05:30</published><updated>2009-07-09T15:08:40.101+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java Swings'/><title type='text'>Using Tabbed Panes in Java Swings</title><content type='html'>&lt;div style="text-align: justify;"&gt;Tabbed panes are just like property sheets in windows environment.Using tabbed pane you can create multiple panels that are visible in a single area.A Tabbed pane consist of series of Tabs.These tabs are present on the basis of categories of information or application they contain.A tabbed pane enables you to display information in a small area in a more effective manner.The JTabbedPane class of javax.swing package is used to create Tabbed panes.Tabbed panes are effective way to use the window area.Tabbed Panes looks like following:-&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_1CvsF-MJpr4/SlW6I1_xCxI/AAAAAAAAAN4/9qYKrlKXBes/s1600-h/tabbedpane.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 201px; height: 200px;" src="http://4.bp.blogspot.com/_1CvsF-MJpr4/SlW6I1_xCxI/AAAAAAAAAN4/9qYKrlKXBes/s400/tabbedpane.jpg" alt="" id="BLOGGER_PHOTO_ID_5356391992923327250" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_1CvsF-MJpr4/SlW6JHHhYFI/AAAAAAAAAOA/ZxgVH01s_us/s1600-h/tabbedpane1.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 203px; height: 200px;" src="http://1.bp.blogspot.com/_1CvsF-MJpr4/SlW6JHHhYFI/AAAAAAAAAOA/ZxgVH01s_us/s400/tabbedpane1.jpg" alt="" id="BLOGGER_PHOTO_ID_5356391997519257682" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Tabbed Pane source code:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;import javax.swing.*;&lt;br /&gt;import java.awt.*;&lt;br /&gt;&lt;br /&gt;public class Tabbedpane extends JFrame{&lt;br /&gt;public static void main(String a[]){&lt;br /&gt;&lt;br /&gt;//creating a container JFrame&lt;br /&gt;JFrame frm=new JFrame("Tabbed Pane");&lt;br /&gt;&lt;br /&gt;//Creating Tabbedpane&lt;br /&gt;JTabbedPane jtpn=new JTabbedPane();&lt;br /&gt;JPanel color=new JPanel();&lt;br /&gt;&lt;br /&gt;//adding panel to a tabbed pane&lt;br /&gt;jtpn.addTab("Color",null,color,"Color info");&lt;br /&gt;color.add(new JLabel("The color is not set yet"));&lt;br /&gt;JPanel sound=new JPanel();&lt;br /&gt;&lt;br /&gt;//adding panel to a tabbed pane&lt;br /&gt;jtpn.addTab("Sound",null,sound,"Sound info");&lt;br /&gt;sound.add(new JLabel("The sound is off"));&lt;br /&gt;&lt;br /&gt;//adding component to the container&lt;br /&gt;frm.getContentPane().add(jtpn);&lt;br /&gt;frm.setBounds(200,200,200,200);&lt;br /&gt;frm.show();&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;JTabbedPane class is used to ceate JTabbedPane oblect.&lt;br /&gt;For adding a JPanel to a JTabbedPane method named addTab() is used.&lt;br /&gt;Four parameters of addTab() method are:-&lt;br /&gt;&lt;br /&gt;1.Label for Tab.&lt;br /&gt;2.Image(if any otherwise null).&lt;br /&gt;3.Component to be added to the Tabbed pane.&lt;br /&gt;4.ToolTip for the tab.&lt;br /&gt;&lt;br /&gt;&lt;a style="font-weight: bold;" href="http://javatutorialsworld.blogspot.com/"&gt;Home&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-6772541732270475525?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/6772541732270475525/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/07/using-tabbed-panes-in-java-swings.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/6772541732270475525'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/6772541732270475525'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/07/using-tabbed-panes-in-java-swings.html' title='Using Tabbed Panes in Java Swings'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_1CvsF-MJpr4/SlW6I1_xCxI/AAAAAAAAAN4/9qYKrlKXBes/s72-c/tabbedpane.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-2523595341432020134</id><published>2009-07-08T10:14:00.004+05:30</published><updated>2009-07-08T10:30:41.825+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java Swings'/><title type='text'>Adding Border in Swing Application componenets</title><content type='html'>The &lt;span style="font-style: italic; font-weight: bold;"&gt;Border&lt;/span&gt; class is in &lt;span style="font-style: italic;"&gt;javax.swing.border&lt;/span&gt; package.Make sure you have imported the package before using &lt;span style="font-style: italic;"&gt;borders&lt;/span&gt; in your application.You can add &lt;span style="font-style: italic;"&gt;borders&lt;/span&gt; to components by using &lt;span style="font-style: italic;"&gt;setBorder()&lt;/span&gt; method.This method has been declared in JComponent class and is available for all the components.Method &lt;span style="font-style: italic;"&gt;getBorder()&lt;/span&gt; gives the name of border for the component.&lt;span style="font-style: italic; font-weight: bold;"&gt;Borders&lt;/span&gt; add look and feel in your components.&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;BorderFactory&lt;/span&gt; class is used to create borders for a component.&lt;span style="font-style: italic;"&gt;Border&lt;/span&gt;&lt;span style="font-style: italic;"&gt;Factory&lt;/span&gt; class has been declared in &lt;span style="font-style: italic;"&gt;javax.swing&lt;/span&gt; package and contains method for creating various types of borders.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;You can use following borders:-&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;ul style="text-align: justify;"&gt;&lt;li&gt;Line Border&lt;/li&gt;&lt;li&gt;Etched Border&lt;/li&gt;&lt;li&gt;Bevel Border&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Example for Line Border:-&lt;/span&gt;&lt;br /&gt;import java.awt.*;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_1CvsF-MJpr4/SlQnGQjqZRI/AAAAAAAAANY/X1fX0B6Xmqg/s1600-h/line+border.jpg"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer; width: 201px; height: 101px;" src="http://2.bp.blogspot.com/_1CvsF-MJpr4/SlQnGQjqZRI/AAAAAAAAANY/X1fX0B6Xmqg/s400/line+border.jpg" alt="" id="BLOGGER_PHOTO_ID_5355948845327607058" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;import javax.swing.*;&lt;br /&gt;import javax.swing.border.*;&lt;br /&gt;import javax.swing.BorderFactory.*;&lt;br /&gt;&lt;br /&gt;public class bordertest extends JFrame{&lt;br /&gt;&lt;br /&gt;public bordertest(){&lt;br /&gt;&lt;br /&gt;JFrame frm=new JFrame("Border Test");&lt;br /&gt;JButton button=new JButton("Line Border");&lt;br /&gt;Border line=BorderFactory.createLineBorder(new Color(0,0,0),3);&lt;br /&gt;button.setBorder(line);&lt;br /&gt;frm.getContentPane().add(button);&lt;br /&gt;frm.show();&lt;br /&gt;frm.setSize(200,100);&lt;br /&gt;}&lt;br /&gt;public static void main(String a[]){&lt;br /&gt;new bordertest();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;createLineBorder()&lt;/span&gt; method is used to create a black line border that is three pixels wide.The &lt;span style="font-style: italic;"&gt;setBorder() &lt;/span&gt;method is used to  set the line border for the button.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Etched Border:-&lt;/span&gt;Replace the above code by following code from line 6.&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt;JButton button=new JButton("Etched Border");&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_1CvsF-MJpr4/SlQnGj2ODWI/AAAAAAAAANg/pNRIWMx71Pc/s1600-h/etched+border.jpg"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer; width: 201px; height: 100px;" src="http://3.bp.blogspot.com/_1CvsF-MJpr4/SlQnGj2ODWI/AAAAAAAAANg/pNRIWMx71Pc/s400/etched+border.jpg" alt="" id="BLOGGER_PHOTO_ID_5355948850505715042" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Border etched=BorderFactory.createEtchedBorder();&lt;br /&gt;button.setBorder(etched);&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;createEtchedBorder() &lt;/span&gt;method is used to create Etched Border.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Bevel Border:-&lt;/span&gt;Bevel Border are of two types raised and lowered.You need to specify in the method &lt;span style="font-style: italic;"&gt;createBevelBorder() &lt;/span&gt;which border you want.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_1CvsF-MJpr4/SlQnGwyUJ9I/AAAAAAAAANo/_p44yXEQ_Qo/s1600-h/bevel+lowered.jpg"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer; width: 201px; height: 100px;" src="http://2.bp.blogspot.com/_1CvsF-MJpr4/SlQnGwyUJ9I/AAAAAAAAANo/_p44yXEQ_Qo/s400/bevel+lowered.jpg" alt="" id="BLOGGER_PHOTO_ID_5355948853978998738" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Bevel Border Lowered:-&lt;/span&gt;Replace the line Border code by following code from line 6.&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt;JButton button=new JButton("Bevel Border");&lt;br /&gt;Border bevellower=BorderFactory.createBevelBorder(BevelBorder.LOWERED);&lt;br /&gt;button.setBorder(bevellower);&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_1CvsF-MJpr4/SlQnHJ68W4I/AAAAAAAAANw/iCznlU-w530/s1600-h/bevel+raised+border.jpg"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer; width: 201px; height: 100px;" src="http://3.bp.blogspot.com/_1CvsF-MJpr4/SlQnHJ68W4I/AAAAAAAAANw/iCznlU-w530/s400/bevel+raised+border.jpg" alt="" id="BLOGGER_PHOTO_ID_5355948860726074242" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Bevel Border Raised:-&lt;/span&gt;Replace the line Border code by following code from line 6.&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt;JButton button=new JButton("Bevel Border");&lt;br /&gt;Border bevelraised=BorderFactory.createBevelBorder(BevelBorder.RAISED);&lt;br /&gt;button.setBorder(bevelraised);&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;Note:-Remove Comments from all the code before use.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-2523595341432020134?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/2523595341432020134/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/07/adding-border-in-swing-application.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/2523595341432020134'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/2523595341432020134'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/07/adding-border-in-swing-application.html' title='Adding Border in Swing Application componenets'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_1CvsF-MJpr4/SlQnGQjqZRI/AAAAAAAAANY/X1fX0B6Xmqg/s72-c/line+border.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-1233999853826928969</id><published>2009-07-07T19:08:00.003+05:30</published><updated>2009-07-07T19:22:51.840+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='JDBC'/><title type='text'>How to delete a record in database through JDBC</title><content type='html'>&lt;div style="text-align: justify;"&gt;There is a straight forward syntax which can be used to delete the rows in a record set or database.In JDBC you can use &lt;span style="font-style: italic;"&gt;executeUpdate(String query)&lt;/span&gt; here argument query indicates the complete query for the deletion of records.&lt;br /&gt;&lt;br /&gt;stmt.executeUpdate("delete employee where empid=0000");&lt;br /&gt;//stmt is the Reference variable for &lt;a href="http://javatutorialsworld.blogspot.com/2009/03/using-prepared-statement.html"&gt;PreparedStatement&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;executeUpdate()&lt;/span&gt; returns the number of queries affected.&lt;br /&gt;&lt;br /&gt;In case if you want to delete the record at runtime say in employee table which is used in above example.You may wish to give empid at runtime.Thus in that case you have to use placeholders.&lt;br /&gt;&lt;br /&gt;That is previous example may now be&lt;br /&gt;&lt;br /&gt;stmt.executeUpdate("delete employee where empid=?");&lt;br /&gt;&lt;br /&gt;but here in this case you have to provide the value for placeholder by using &lt;span style="font-style: italic;"&gt;setString()&lt;/span&gt; or &lt;span style="font-style: italic;"&gt;setInt()&lt;/span&gt; method according to your need.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Code Snippet:-&lt;/span&gt;&lt;br /&gt;Following example &lt;a href="http://javatutorialsworld.blogspot.com/2009/03/using-prepared-statement.html"&gt;uses placeholders&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;public void deleterecord(){&lt;br /&gt;int val=1002;&lt;br /&gt;try{&lt;br /&gt;stmt.setInt(1,val);&lt;br /&gt;stmt.executeUpdate("delete employee where empid=?");&lt;br /&gt;}catch(Exception e){}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;For More on JDBC goto:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/03/using-prepared-statement.html"&gt;JDBC:PreparedStatement Object&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/03/detailed-jdbc-example-statement-object.html"&gt;JDBC:Statement Object&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/03/jdbc-resultset-object.html"&gt;JDBC:ResultSet Object&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/03/database-querying.html"&gt;querying database&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/03/connecting-to-database.html"&gt;connecting to database&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/03/configuring-odbc-data-source-for-jdbc.html"&gt;Configuring data source&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/03/jdbcintroduction.html"&gt;JDBC :Introduction&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-1233999853826928969?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/1233999853826928969/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/07/how-to-delete-record-in-database.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/1233999853826928969'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/1233999853826928969'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/07/how-to-delete-record-in-database.html' title='How to delete a record in database through JDBC'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-266936506876679862</id><published>2009-07-04T16:45:00.002+05:30</published><updated>2009-07-04T16:48:42.499+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Object Oriented'/><title type='text'>Why Java not support multiple Inheritance?</title><content type='html'>&lt;div style="text-align: justify;"&gt;One can always think of extending multiple classes to inherit the multiple features in the form of methods.Like following:-&lt;br /&gt;&lt;br /&gt;class Car extends Accelerate,Color{ //interesting code}&lt;br /&gt;&lt;br /&gt;but the above declaration is not legal in terms if Java.A class cannot extend more than one class.This exactly implies that only one parent class per class.But a class can have multiple ancestors such that if class A extends class B and class B extends class C then class A has two ancestors class B and C .A class can have multiple ancestors up the inheritance tree but it is not possible by direct declaration of extending classes.&lt;br /&gt;&lt;br /&gt;In C++ ,One can extend multiple classes simultaneously that is the declaration we have done for class Car is correct in case of C++.Capability of extending multiple classes is called as "Multiple Inheritance".Java creators thought a lot about allowing the multiple inheritance,but they were messed up after using the multiple inheritance.Like in this case ,if a class extended two classes and if both classes has method(s) in common then how the methods will be inherited and how we will come to know that which method is called of which class.That is why they excluded the multiple inheritance in Java.There is a famous problem which is faced during the multiple inheritance application called as "Deadly Diamond of Death".This is named so because the shape of class diagram which is formed after multiple inheritance implementation.The diamond is formed when classes B and C extend A ,and both B and C inherit methods from A.If class D extends both B and C,and both B and C have overridden the methods in class A,class D in theory has inherited the two different implementations of same method.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_1CvsF-MJpr4/Sk86P6GZCOI/AAAAAAAAANQ/E26WpF0ylTk/s1600-h/multiple+inheritance.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 376px; height: 278px;" src="http://2.bp.blogspot.com/_1CvsF-MJpr4/Sk86P6GZCOI/AAAAAAAAANQ/E26WpF0ylTk/s400/multiple+inheritance.jpg" alt="" id="BLOGGER_PHOTO_ID_5354562526935320802" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;There is an indirect way by which you can implement the multiple inheritance in Java and this is through extending a class and implementing an interface just like following:-&lt;br /&gt;&lt;br /&gt;class Car extends Accelerate implements Movable{&lt;br /&gt;//  implement all Movable methods&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;In this way you can get methods from both class and interface and you can override them according to your use.Remember all methods of interface needs to be overridden in implementing class.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-266936506876679862?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/266936506876679862/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/07/why-java-not-support-multiple.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/266936506876679862'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/266936506876679862'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/07/why-java-not-support-multiple.html' title='Why Java not support multiple Inheritance?'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_1CvsF-MJpr4/Sk86P6GZCOI/AAAAAAAAANQ/E26WpF0ylTk/s72-c/multiple+inheritance.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-6791360849232207536</id><published>2009-07-02T22:31:00.004+05:30</published><updated>2009-07-02T23:32:46.484+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Object Oriented'/><title type='text'>Polymorphism:Core of Object Oriented Programming</title><content type='html'>&lt;div style="text-align: justify;"&gt;Java is an Object Oriented Language and Polymorphism is its core concept.Nobody can program efficiently without knowing the core programming techniques like Polymorphism,Code Reuse etc.The genuine meaning of polymorphism is "many forms".In Java this meaning is rightly justified.Polymorphism in Java means a method can have various versions.It may be in A super class and it can also be in sub class.There are ways to invoke the methods from either super class or the sub class.As you are familiar with Java you must know that a sub class in Java inherits all the methods of its super class(except methods are declared private in super class).Every sub class can provide its own functionality to every super class method.That is in simpler terms the method is overridden in sub class.We can invoke the super class method using both reference variable types either as of super class or of sub class.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Following Example make things clear for you.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;class Shape{&lt;br /&gt;      public void imageShape(){&lt;br /&gt;      System.out.println("Image Shape Printed");&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class Square extends Shape{&lt;br /&gt;&lt;br /&gt;public void imageShape(){&lt;br /&gt;      super.imageShape();&lt;br /&gt;      System.out.println("Square Shape Printed");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void shape_square(){&lt;br /&gt;System.out.println("The Shape is square");&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class TestShape{&lt;br /&gt;public static void main(String a[]){&lt;br /&gt;Square sqr=new Square();&lt;br /&gt;Shape shp=new Shape();&lt;br /&gt;sqr.imageShape();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Output:-&lt;/span&gt;&lt;br /&gt;The output of above program is&lt;br /&gt;Image Shape Printed&lt;br /&gt;Square Shape Printed&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Explanation:-&lt;/span&gt;&lt;br /&gt;There are certain you must have noticed in the code.First of all starting from our super class Shape it has one method imageShape().The sub class Square inherits the method imageShape() from its parent Shape.Square class provides square specific functionality to this method.&lt;br /&gt;Note:-super keyword can be used to refer to the super class version of imageShape() method.&lt;br /&gt; never use super outside method body.If you do so compiler don't hesitate to slap you.You can also add your additional methods to your more specific classes as we did here.&lt;br /&gt;TestShape class makes object of the Square class and invokes method imageShape().This reference cause the sub class version of  imageShape() which results in the presented output.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-weight: bold;"&gt;The story is not as you like there are some problems for you I know you can solve them,if possible let me know the answers with proper explanations:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;1.What would be the output of following:-&lt;br /&gt;&lt;br /&gt;class Shape{&lt;br /&gt;      public void imageShape(){&lt;br /&gt;      System.out.println("Image Shape Printed");&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class Square extends Shape{&lt;br /&gt;&lt;br /&gt;public void imageShape(){&lt;br /&gt;      System.out.println("Square Shape Printed");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void shape_square(){&lt;br /&gt;imageShape();&lt;br /&gt;System.out.println("The Shape is square");&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class TestShape{&lt;br /&gt;public static void main(String a[]){&lt;br /&gt;Square sqr=new Square();&lt;br /&gt;sqr.imageShape();&lt;br /&gt;sqr.shape_square();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;--------------------------------------------------------------------&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;2.What would be the output of following code:-&lt;br /&gt;&lt;br /&gt;class Shape{&lt;br /&gt;      public void imageShape(){&lt;br /&gt;      System.out.println("Image Shape Printed");&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class Square extends Shape{&lt;br /&gt;&lt;br /&gt;public void imageShape(){&lt;br /&gt;    super.imageShape();&lt;br /&gt;      System.out.println("Square Shape Printed");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;imageShape();&lt;br /&gt;public void shape_square(){&lt;br /&gt;imageShape();&lt;br /&gt;System.out.println("The Shape is square");&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class TestShape{&lt;br /&gt;public static void main(String a[]){&lt;br /&gt;Square sqr=new Square();&lt;br /&gt;sqr.imageShape();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-6791360849232207536?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/6791360849232207536/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/07/polymorphismcore-of-object-oriented.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/6791360849232207536'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/6791360849232207536'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/07/polymorphismcore-of-object-oriented.html' title='Polymorphism:Core of Object Oriented Programming'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-4567173446643410383</id><published>2009-07-01T15:37:00.001+05:30</published><updated>2009-07-01T15:41:04.741+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Access Control and Declaration'/><category scheme='http://www.blogger.com/atom/ns#' term='Object Oriented'/><title type='text'>Why code reuse is an exclusive feature of Inheritance??</title><content type='html'>&lt;div style="text-align: justify;"&gt;The Inheritance in Java can have two ways of implementation:-&lt;br /&gt;&lt;br /&gt;1.Code Reuse&lt;br /&gt;2.Polymorphism&lt;br /&gt;&lt;br /&gt;Since Inheritance is the core concept of OO programming ,thus it is must to understand "Code Reuse".Code Reuse lets a programmer to use the code of more generic super-class into subclasses.You need not write extra code for any of your method if the behaviour is common to both super class and subclass.As we know Super classes are more general whereas the subclasses are more of a special kind,that is why the general methods and variables are defined in super classes.Whereas a subclass can either extend the functionality or use whatever given in super class.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Code Reuse Example:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;class Car{&lt;br /&gt;   public void color(){&lt;br /&gt;     &lt;br /&gt;       System.out.println("Color of your car is: Black");&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Public class Subaru extends Car{&lt;br /&gt;   public void accelerate(){&lt;br /&gt; &lt;br /&gt;       System.out.println("Top speed of Subaru is 120 mph");&lt;br /&gt;   }&lt;br /&gt;   public static void main(String a[]){&lt;br /&gt;       Subaru sbr=new Subaru();&lt;br /&gt;       sbr.color();&lt;br /&gt;       sbr.accelerate();&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Output :-&lt;/span&gt;&lt;br /&gt;Color of your car is: Black&lt;br /&gt;Top speed of Subaru is 120 mph&lt;br /&gt;&lt;br /&gt;Here you can see that class Subaru extends Car thus it Inherits the color() method of Subaru.Also it can also add its own method as accelerate() which is only Subaru specific that its top speed is 120mph.That is every can have its own color and its generic for every car thus every car extending the Car class need not reimplement the color() method.&lt;br /&gt;&lt;br /&gt;&lt;a style="color: rgb(255, 0, 0);" href="http://javatutorialsworld.blogspot.com/"&gt;&lt;span style="font-weight: bold;"&gt;Home&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-4567173446643410383?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/4567173446643410383/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/07/why-code-reuse-is-exclusive-feature-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/4567173446643410383'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/4567173446643410383'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/07/why-code-reuse-is-exclusive-feature-of.html' title='Why code reuse is an exclusive feature of Inheritance??'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-8352137302365190813</id><published>2009-06-26T11:04:00.005+05:30</published><updated>2009-06-26T11:39:36.319+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Authors Update'/><title type='text'>India IT giants to bid for MultiBillion UIC Project</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_1CvsF-MJpr4/SkRkSJcIFQI/AAAAAAAAANI/mzmAZ7n4Rg0/s1600-h/infosys_technologies_logo.jpg"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 200px; height: 78px;" src="http://3.bp.blogspot.com/_1CvsF-MJpr4/SkRkSJcIFQI/AAAAAAAAANI/mzmAZ7n4Rg0/s200/infosys_technologies_logo.jpg" alt="" id="BLOGGER_PHOTO_ID_5351512520157304066" border="0" /&gt;&lt;/a&gt;Indian IT companies are gearing up to bid for Multi Billion UIC(Unique Identification Card) project after government decided to put it on the fast track.In response to The Supreme Court ruling Yesterday Planning commission of India appointed Nandan Nilekani as the project chief and put it on a fast track to complete within 3 years.Nandan co-founder of Infosys is known for his entrepreneurship.The post he is given will be equivalent to that of a cabinet minister.&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;As soon as he is appointed as project chief he resigned from the co-chairman of Infosys as to avoid any conflict of interest.This project would cost around 10,000 crore rupees and will lift the Indian economy.There was a little pressure from the IT companies too as they were pressing government for restarting such public projects to get some work.Infosys and TCS already have confirmed that they would bid for this project.This project is expected to create almost 1,00,000 jobs in the industry and hence result in more recruitment.This is a combined project for many companies like card manufacturers,printing,chip designing,programmers,network specialists etc.This will all impact the Indian IT scenario and will help make it better.Infosys made it clear that the whole process would be transparent including deals and negotiations after some suspect that Nilekani's presence might give an edge to Infosys to grab the project.&lt;br /&gt;&lt;br /&gt;Peoples across the country expressed happiness after they heard about UIC project.This card will include all their details .Now they need to keep just one card despite carrying many.It will have record of your all bank accounts and transactions,your citizen ID,your biometric data and much more.It will contain a chip which will store all your information.After launch of this card their would be no use of ration,PAN and other card.The main benefit is that the poor will be benefited directly.&lt;br /&gt;&lt;br /&gt;Although issuing cards to a billion peoples will take time but with the leadership of Mr. Nandan Nilekani we hope it will be completed soon because it is matter of national security that is why it is being given such priority by government.It is a major step towards preventing terrorism.&lt;br /&gt;&lt;br /&gt;There is a hope for me too.I have got offer of employment from Infosys.I think the news came just at the right time and I hope Infosys to grab the project because it will make my job safe in such economic downturn.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-8352137302365190813?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/8352137302365190813/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/06/india-it-giants-to-bid-for-multibillion.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/8352137302365190813'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/8352137302365190813'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/06/india-it-giants-to-bid-for-multibillion.html' title='India IT giants to bid for MultiBillion UIC Project'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_1CvsF-MJpr4/SkRkSJcIFQI/AAAAAAAAANI/mzmAZ7n4Rg0/s72-c/infosys_technologies_logo.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-7347814033978258236</id><published>2009-06-25T14:44:00.002+05:30</published><updated>2009-06-25T14:47:33.934+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Access Control and Declaration'/><title type='text'>All about enums:How to create ,How to use -- part 3</title><content type='html'>We have seen the basics of enum in &lt;a href="http://javatutorialsworld.blogspot.com/2009/06/all-about-enumshow-to-create-how-to-use.html"&gt;part 1&lt;/a&gt; and &lt;a href="http://javatutorialsworld.blogspot.com/2009/06/all-about-enumshow-to-create-how-to-use_25.html"&gt;part 2&lt;/a&gt;.Now we will see the advanced aspect that how can you use the enum to declare and use the methods,variables within it.&lt;br /&gt;&lt;br /&gt;The question is why we need to declare and use methods and variables in enums?&lt;br /&gt;The answer is to specify the functionality of the enum.All the logical code and selection logic must remain within the enum.This is done for increasing the understandability and performance of program.enum is just like a look up table from which the values are fetched based on certain conditions.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Following is the example how we can use methods and variables within enum:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;enum RAM{ BATTERING_RAM(20),CAPPED_RAM(30),SIEGE_RAM(40) };&lt;br /&gt;&lt;br /&gt;RAM(int hitpoints){&lt;br /&gt;this.hitpoints=hitpoints;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;private int hitpoints;&lt;br /&gt;public int getHitpoints(){&lt;br /&gt;return hitpoints;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class TestRam{&lt;br /&gt;RAM ramName;&lt;br /&gt;public static void main(String a[]){&lt;br /&gt;TestRam ram1=new TestRam();&lt;br /&gt;ram1.ramName=RAM.SIEGE_RAM;&lt;br /&gt;Syatem.out.println(ram1.ramName.getHitpoints());&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;The above example prints output as the hitpoints of SIEGE_RAM as 40.That is how you can use the methods and variables within an enum.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Suggested Links:-&lt;/span&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/"&gt;Home&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/06/all-about-enumshow-to-create-how-to-use.html"&gt;All about enums:How to create ,How to use -- part 1&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/06/all-about-enumshow-to-create-how-to-use_25.html"&gt;All about enums:How to create ,How to use -- part 2&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/06/why-java-classes-are-not-marked-final.html"&gt;Why java classes are not marked "final"&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-7347814033978258236?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/7347814033978258236/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/06/all-about-enumshow-to-create-how-to-use_823.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/7347814033978258236'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/7347814033978258236'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/06/all-about-enumshow-to-create-how-to-use_823.html' title='All about enums:How to create ,How to use -- part 3'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-7540855143600115217</id><published>2009-06-25T14:18:00.005+05:30</published><updated>2009-06-25T14:48:06.664+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Access Control and Declaration'/><title type='text'>All about enums:How to create ,How to use -- part 2</title><content type='html'>&lt;div style="text-align: justify;"&gt;In&lt;a href="http://javatutorialsworld.blogspot.com/2009/06/all-about-enumshow-to-create-how-to-use.html"&gt; part 1 &lt;/a&gt;we have see we can use the enums in two ways&lt;br /&gt;1.As own class.&lt;br /&gt;2.Within other class.&lt;br /&gt;&lt;br /&gt;You can understand the usage in followin examples:-&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;=&gt;Declaring enum as own class and outside the class:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;enum Processor{ P4,DUALCORE,COREDUO};&lt;br /&gt;&lt;br /&gt;class Processorvalue{&lt;br /&gt;Processor process;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public class Processortest{&lt;br /&gt;public static void main(String a[]){&lt;br /&gt;Processorvalue pval=new Processorvalue();&lt;br /&gt;pval.process=Processor.P4;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;=&gt;enum declared within a class&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;class Processorvalue{&lt;br /&gt;enum Processor{P4,DUALCORE,COREDUO};&lt;br /&gt;Processor process;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public class Processtest{&lt;br /&gt;public static void main(String a[]){&lt;br /&gt;Processorvalue pval= new Processorvalue();&lt;br /&gt;pval.process=Processorvalue.Processor.P4;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;Note:-&lt;/span&gt;Access methods and  syntax pattern depend on the way of implementation of enum.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/06/all-about-enumshow-to-create-how-to-use_823.html"&gt;How to use methods and variables within an enum -Part 3&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Useful links:-&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/"&gt;Home&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/06/all-about-enumshow-to-create-how-to-use.html"&gt;All about enums:How to create ,How to use -- part 1&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/06/why-java-classes-are-not-marked-final.html"&gt;Why java classes are not marked "final"&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-7540855143600115217?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/7540855143600115217/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/06/all-about-enumshow-to-create-how-to-use_25.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/7540855143600115217'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/7540855143600115217'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/06/all-about-enumshow-to-create-how-to-use_25.html' title='All about enums:How to create ,How to use -- part 2'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-655815902137119882</id><published>2009-06-25T14:15:00.002+05:30</published><updated>2009-06-25T14:23:00.880+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Access Control and Declaration'/><title type='text'>All about enums:How to create ,How to use -- part 1</title><content type='html'>&lt;div style="text-align: justify;"&gt;enum is a special kind of class in which we can list enumaerated constant values.We can add constants,methods and instance variables and a brand new stranger called constant specific class body.&lt;br /&gt;&lt;br /&gt;enums lets you choose a variable to having one of a few pre-defined set of values.That is selecting one value from an enumerated list.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Simple declaration for an enum is as follows:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;enum Processor{P4,DUALCORE,COREDUO }&lt;br /&gt;&lt;br /&gt;to fetch a value from an enum you must use following syntax:-&lt;br /&gt;&lt;br /&gt;Processor process=Processor.P4;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;Note:-&lt;/span&gt;You can put semicolon at the end of curly braces in declaration because they are optional.So whenever you see an enum declaration ending with semicolon never get confused.Remember semicolon is optional.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Rules regarding enums:-&lt;/span&gt;&lt;br /&gt;There are some rules while using enums&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Rule 1:-&lt;/span&gt;enums can be declared as their own seperate class.&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Rule 2:-&lt;/span&gt;enums can also be a class member.&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Rule 3:-&lt;/span&gt;enums must not be declared within a method.&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Rule 4:-&lt;/span&gt;enums can have only to access modifiers&lt;br /&gt;1.defult(which is by default no need to specify)&lt;br /&gt;2.public&lt;br /&gt;&lt;br /&gt;There are two ways of using enums&lt;br /&gt;1.As own class.&lt;br /&gt;2.Within a class.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/06/all-about-enumshow-to-create-how-to-use_25.html"&gt;To view examples Proceed to part 2&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Suggested Links:-&lt;/span&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/"&gt;Home&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/06/why-java-classes-are-not-marked-final.html"&gt;Why public class not marked "final"&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/06/local-variable-instance-variable-and.html"&gt;Variables&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-655815902137119882?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/655815902137119882/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/06/all-about-enumshow-to-create-how-to-use.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/655815902137119882'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/655815902137119882'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/06/all-about-enumshow-to-create-how-to-use.html' title='All about enums:How to create ,How to use -- part 1'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-8641233053573918450</id><published>2009-06-23T15:43:00.003+05:30</published><updated>2009-06-23T23:51:04.402+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Access Control and Declaration'/><title type='text'>Local Variable , Instance Variable and Shadowing</title><content type='html'>&lt;div style="text-align: justify;"&gt;Instance variables and local variables are two types of variables based on variable declaration.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Instance variables &lt;/span&gt;are those variables which are declared just below class declaration and are available to all member methods.These are outside any method body.Instance variable are data fields which are unique to each and every object.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;For Example:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;public class test{&lt;br /&gt;&lt;br /&gt;//Following both are Instance variable of class test ,whenever the class is instantiated these are also initialized&lt;br /&gt; private String name;&lt;br /&gt; private String address;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Main points about Instance variables:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;1.We can use any of four access modifiers(public,private,protected,default).&lt;br /&gt;2.Instance variables cannot be either static or abstract.&lt;br /&gt;3.Instance variables can be marked final or transient.&lt;br /&gt;4.Instance variables cannot be marked strictfp,native and synchronized.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Local variables&lt;/span&gt; are variables which are declared within a method.This means the variable is initialized within method and also declared within method.Local variable has its scope and lifetime limited to the method.Local variable gets initialized when a method is loaded and destroyed when a method completes.The important thing to remember is that the local variable itself can be passed as argument in other method calls but its scope is limited to its method.Local variables during declaration must be assigned a value otherwise compiler will slap a error that variable not initialized.Local variables life goes inside a stack not on heap.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;Note:-&lt;/span&gt;Local variables can't ever be referenced in any code outside the method in which it is declared.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 102, 255);"&gt;For Example:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;//myvalue inside mymethod is a local variable.&lt;br /&gt;public class testlocal{&lt;br /&gt;  public void mymethod(){&lt;br /&gt;       int myvalue=21;&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Variable Shadowing:-&lt;/span&gt;We can declare local variable with the same name as Instance variable.It is known as variable shadowing.These came in often where the local variable is an argument and you wish to assign a value of Instance variable to the local variable.Sometimes you get confused in this(see following):-&lt;br /&gt;&lt;br /&gt;public class shadowconfusion{&lt;br /&gt;int age=21;&lt;br /&gt;public void yourage(int age){&lt;br /&gt;   age=age;                     // In this case it becomes difficult to know which value is assigned to which one&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;To remove this confusion we use this keyword.this keyword always refers to the object currently running.That is previously written code can be modified as following:-&lt;br /&gt;&lt;br /&gt;public class shadowconfusion{&lt;br /&gt;int age=21;&lt;br /&gt;public void yourage(int age){&lt;br /&gt;   this.age=age;                  //Instance variable is assigned a value from parameter.&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Links:-&lt;/span&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/"&gt;Home&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/06/why-java-classes-are-not-marked-final.html"&gt;Why Java Classes are not marked "final"&lt;/a&gt;&lt;br /&gt;&lt;a href="http://indiaisonline.blogspot.com/"&gt;India Online Latest From India&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-8641233053573918450?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/8641233053573918450/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/06/local-variable-instance-variable-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/8641233053573918450'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/8641233053573918450'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/06/local-variable-instance-variable-and.html' title='Local Variable , Instance Variable and Shadowing'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-7723940143455500025</id><published>2009-06-20T16:10:00.005+05:30</published><updated>2009-07-29T23:35:56.991+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Access Control and Declaration'/><category scheme='http://www.blogger.com/atom/ns#' term='Object Oriented'/><title type='text'>Why Java Classes are not marked "final"</title><content type='html'>&lt;div style="text-align: justify;"&gt;&lt;span style="font-weight: bold;"&gt;final&lt;/span&gt; keyword is a main feature of Java language.It is mostly used to define the constant values.Since it is  a non-access modifier ,then question arises can &lt;span style="font-weight: bold;"&gt;final &lt;/span&gt;keyword be used with the Java classes.The answer simply is no,we can never ever use a &lt;span style="font-weight: bold;"&gt;final&lt;/span&gt; modifier before a Java class but Important thing here is to remember(REALLY IMPORTANT) that if you wish, methods of your class must not be overridden then only use&lt;span style="font-weight: bold;"&gt; final &lt;/span&gt;keyword before class declaration.Declaring a Java class as&lt;span style="font-weight: bold;"&gt; final &lt;/span&gt;means you can never subclass or extend the final class.That is it is strictly against the inheritance property.So does it  violate the Object Oriented property of Java?So why we should use it?You should make a&lt;span style="font-weight: bold;"&gt; final &lt;/span&gt;class only if you need an absolute guarantee that none of your methods in that class will ever be overridden.&lt;br /&gt;&lt;br /&gt;If you want security of your code and don't want any body to change it ,mark your class as &lt;span style="font-weight: bold;"&gt;final &lt;/span&gt;thus your implementation will remain secret and can never be changed.&lt;br /&gt;&lt;br /&gt;The main example here is that the main Java core libraries are also marked as &lt;span style="font-weight: bold;"&gt;final.&lt;/span&gt;Assume a situation where we cannot guarantee that how String class going to work on any system your application is running on.&lt;br /&gt;&lt;br /&gt;Use &lt;span style="font-weight: bold;"&gt;final &lt;/span&gt;modifier only when you think that you need no improvements in future because once declared as &lt;span style="font-weight: bold;"&gt;final&lt;/span&gt; a class cannot be subclassed and improved.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Example:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;public final class test{&lt;br /&gt;     public void myMethod(){  //your code   }&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;class testingtest extends test{  //your code  }&lt;br /&gt;&lt;br /&gt;Compiling above code snippet would give output like following:-&lt;br /&gt;Can't subclass &lt;span style="font-weight: bold;"&gt;final&lt;/span&gt; classes:class test class testingtest extends test&lt;br /&gt;1 error&lt;br /&gt;&lt;br /&gt;As told earlier use&lt;span style="font-weight: bold;"&gt; final&lt;/span&gt; in the extreme conditions where you require quite a lot of safety and security.If your class needs an improvement and you don't have source code, you now better what you have to do!!!!!&lt;br /&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/"&gt;Home&lt;/a&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/06/local-variable-instance-variable-and.html"&gt;Local Variable , Instance Variable and Shadowing&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;a href="http://indiaisonline.blogspot.com"&gt;India Online all Indian Stuff&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-7723940143455500025?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/7723940143455500025/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/06/why-java-classes-are-not-marked-final.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/7723940143455500025'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/7723940143455500025'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/06/why-java-classes-are-not-marked-final.html' title='Why Java Classes are not marked &quot;final&quot;'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-4228432890013284121</id><published>2009-06-19T16:56:00.004+05:30</published><updated>2009-06-19T17:05:22.773+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java Swings'/><category scheme='http://www.blogger.com/atom/ns#' term='Java utilities'/><title type='text'>How to create pop-up menus in Java</title><content type='html'>&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;&lt;span style="font-weight: bold;"&gt;PopUp Menus&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Pop-up menus are the menus that are displayed when a user clicks the right mouse button.They are sometimes also known as short-cut menus.&lt;br /&gt;Short cut menus are very handy in cases where some functionality you want to provide like adding a help menu to all controls on right click.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step for creating Pop-up menus:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;1.Create an object of the JPopupMenu class.&lt;br /&gt;2.Create object of the Menu class for each menu you want to add on the menu bar.&lt;br /&gt;3.Call the add() method of the JPopupMenu class to add each menu object to the pop-up menu.&lt;br /&gt;4.Create objects of the JMenuItem or CheckboxMenuItem class for each item that you want to in the menu.&lt;br /&gt;5.Call the add() method of the Menu class to add each item to its appropriate menu.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_1CvsF-MJpr4/Sjt2xd4ItPI/AAAAAAAAAM4/lCpHS4KUmso/s1600-h/popup.JPG"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer; width: 287px; height: 208px;" src="http://3.bp.blogspot.com/_1CvsF-MJpr4/Sjt2xd4ItPI/AAAAAAAAAM4/lCpHS4KUmso/s400/popup.JPG" alt="" id="BLOGGER_PHOTO_ID_5348999574638343410" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Example Source code:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;//PopUpColorMenu.java&lt;br /&gt;import java.awt.*;&lt;br /&gt;import java.awt.event.*;&lt;br /&gt;import javax.swing.*;&lt;br /&gt;&lt;br /&gt;public class PopUpColorMenu&lt;br /&gt;{&lt;br /&gt; Component selectedComponent;&lt;br /&gt;&lt;br /&gt; public PopUpColorMenu(  ) {&lt;br /&gt;   JFrame frame = new JFrame("PopUpColorMenu v1.0");&lt;br /&gt;&lt;br /&gt;   final JPopupMenu colorMenu = new JPopupMenu("Color");&lt;br /&gt;   colorMenu.add(makeMenuItem("Red"));&lt;br /&gt;   colorMenu.add(makeMenuItem("Green"));&lt;br /&gt;   colorMenu.add(makeMenuItem("Blue"));&lt;br /&gt;&lt;br /&gt;   MouseListener mouseListener = new MouseAdapter(  ) {&lt;br /&gt;     public void mousePressed(MouseEvent e) { checkPopup(e); }&lt;br /&gt;     public void mouseClicked(MouseEvent e) { checkPopup(e); }&lt;br /&gt;     public void mouseReleased(MouseEvent e) { checkPopup(e); }&lt;br /&gt;     private void checkPopup(MouseEvent e) {&lt;br /&gt;       if (e.isPopupTrigger(  )) {&lt;br /&gt;         selectedComponent = e.getComponent(  );&lt;br /&gt;         colorMenu.show(e.getComponent(), e.getX(  ), e.getY(  ));&lt;br /&gt;       }&lt;br /&gt;     }&lt;br /&gt;   };&lt;br /&gt;frame.getContentPane(  ).addMouseListener(mouseListener);&lt;br /&gt;&lt;br /&gt;   frame.setSize(200,50);&lt;br /&gt;   frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );&lt;br /&gt;   frame.setVisible(true);&lt;br /&gt; }&lt;br /&gt;private JMenuItem makeMenuItem(String label) {&lt;br /&gt;   JMenuItem item = new JMenuItem(label);&lt;br /&gt;   return item;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; public static void main(String[] args) {&lt;br /&gt;    new PopUpColorMenu(  );&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Useful Links:-&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/"&gt;Home&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/05/menus-in-java-swings.html"&gt;Menus&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/05/how-to-create-menubar-steps.html"&gt;MenuBars&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-4228432890013284121?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/4228432890013284121/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/06/how-to-create-pop-up-menus-in-java_19.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/4228432890013284121'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/4228432890013284121'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/06/how-to-create-pop-up-menus-in-java_19.html' title='How to create pop-up menus in Java'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_1CvsF-MJpr4/Sjt2xd4ItPI/AAAAAAAAAM4/lCpHS4KUmso/s72-c/popup.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-5502038583680953858</id><published>2009-06-19T10:23:00.001+05:30</published><updated>2009-06-19T10:26:37.048+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Access Control and Declaration'/><title type='text'>Java Source File Declaration Rules</title><content type='html'>&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;&lt;span style="font-weight: bold;"&gt;Declaration Rules&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Before doing the hardcore programming one has to be familiar with the rules which govern the source file declaration in Java.Sun Microsystems has provided the guidelines for the naming and declaration.Here we will look the rules which are associated with declaring classes,import statements etc.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Rule 1:-&lt;/span&gt; There can be only one public class per source code file(e.g. a Java File).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Rule 2:-&lt;/span&gt;If there is a public class in a file then the name of the java file must match the name of public class.For example if you declared public class Man{ }  then it must be stored in a file which is also named as Man.java.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Rule 3:-&lt;/span&gt;Comments can appear at the beginning or end of any line of code of source code file.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Rule 4:-&lt;/span&gt;A source file can have more than one non-public classes.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Rule 5:-&lt;/span&gt;If a class is a part of a package,then the package statement must be first line of code,irrespective of any import statement present.&lt;br /&gt;           For example:-&lt;br /&gt;                                package cert;&lt;br /&gt;                                import java.lang.*;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Rule 6:-&lt;/span&gt;If there are import statements then they must go between package and class declarations.If there are no package statements then import statement must be first line of code and if import is also absent then class declaration will be first statement in source file.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Rule 7:-&lt;/span&gt;import and package statement apply to all classes within a source file.In other words there in no way to declare multiple classes in a file which have them in different packages and using different imports.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Rule 8:-&lt;/span&gt;Files with no public classes can have a name which may or may not match the name of any constituent class.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/"&gt;Home&lt;/a&gt;&lt;br /&gt;&lt;a href="http://indiaisonline.blogspot.com"&gt;India Online&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-5502038583680953858?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/5502038583680953858/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/06/java-source-file-declaration-rules.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/5502038583680953858'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/5502038583680953858'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/06/java-source-file-declaration-rules.html' title='Java Source File Declaration Rules'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-4558898693545143306</id><published>2009-06-08T10:27:00.003+05:30</published><updated>2009-06-08T10:38:43.245+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Authors Update'/><title type='text'>Last Day at College</title><content type='html'>&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;Hii&lt;/span&gt; friends!!&lt;br /&gt;.&lt;br /&gt;Its a very bad feeling that you are no more with your friends and &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_1"&gt;colleagues&lt;/span&gt; .All the joy and laughs is just about to vanish.Today is the final year project presentation,and most probably its the last day at college.I despite getting job offers felling a little scared about my future.Most of my friends got jobs in various firms but some how few missed out on their &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_2"&gt;opportunities&lt;/span&gt;.Today everywhere scribbling on college uniform is on you can see the shirts and suits scribbled with funny and serious quotes.Everyone gives a nice feeling.Friends told me that when they left the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;ppt&lt;/span&gt;. hall they were felling joy but after few hours of laughter they were start thinking what is next.I most you have this experience before but still you can know what I am feeling right now.I am also &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;vey&lt;/span&gt; much optimistic about my future ,I am in search of some short term job.(&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;coz&lt;/span&gt; India is little affect of global meltdown) Which can fetch me some money.So that I can buy myself a Laptop(or a PS3).This job might be of teaching.But I will continue writing Java tutorials as I am writing now.Sorry for being late but I was busy in preparing my project.I know you will forgive me &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;coz&lt;/span&gt; it is for right &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;coz&lt;/span&gt;.Today I will leave my hostel and go to my home.See you there.&lt;br /&gt;&lt;br /&gt;with Regards&lt;br /&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;Vaibhav&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-4558898693545143306?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/4558898693545143306/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/06/last-day-at-college.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/4558898693545143306'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/4558898693545143306'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/06/last-day-at-college.html' title='Last Day at College'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-7307181931588225089</id><published>2009-05-30T13:21:00.005+05:30</published><updated>2009-05-31T19:22:22.393+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java Swings'/><title type='text'>How to create MenuBar Steps</title><content type='html'>How to create Menu and &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;MenuBars&lt;/span&gt; Step wise procedure&lt;br /&gt;&lt;br /&gt;1.Create an object of &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;MenuBar&lt;/span&gt; class:&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;MenuBar&lt;/span&gt; can be attached a Frame and it will be displayed just below the title bar.&lt;br /&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;MenuBar&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;mb&lt;/span&gt;=new &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;MenuBar&lt;/span&gt;();&lt;br /&gt;&lt;br /&gt;2.Call the method &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;setMenuBar&lt;/span&gt;(&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;MenuBar&lt;/span&gt;):-This method is used to attach the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;MenuBar&lt;/span&gt; to a Frame.&lt;br /&gt;            &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;setMenuBar&lt;/span&gt;(&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;mb&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;3.Create objects of the Menu class for each menu you want to add on menu bar.&lt;br /&gt;&lt;br /&gt;       Menu file=new Menu("File");&lt;br /&gt;       Menu edit=new Menu("Edit");&lt;br /&gt;Menu help=new Menu("Help");&lt;br /&gt;&lt;br /&gt;4.Call add() method of &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;MenuBar&lt;/span&gt; class to add each menu object to the menu.&lt;br /&gt;&lt;br /&gt;       &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_12"&gt;mb&lt;/span&gt;.add(file);&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_1CvsF-MJpr4/SiDmXLCAtDI/AAAAAAAAAMc/qI-EUjA3AJg/s1600-h/menu+initial.JPG"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer; width: 246px; height: 237px;" src="http://3.bp.blogspot.com/_1CvsF-MJpr4/SiDmXLCAtDI/AAAAAAAAAMc/qI-EUjA3AJg/s400/menu+initial.JPG" alt="" id="BLOGGER_PHOTO_ID_5341522443834012722" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;       &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_13"&gt;mb&lt;/span&gt;.add(edit);&lt;br /&gt;       &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_14"&gt;mb&lt;/span&gt;.add(help);&lt;br /&gt;&lt;br /&gt;5.Create object of &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_15"&gt;MenuItem&lt;/span&gt; or &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_16"&gt;CheckboxMenuItem&lt;/span&gt; class for each sub menu item.&lt;br /&gt;&lt;br /&gt;       &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_17"&gt;MenuItem&lt;/span&gt; save =new &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_18"&gt;MenuItem&lt;/span&gt;("Save");&lt;br /&gt;       &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_19"&gt;MenuItem&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_20"&gt;newf&lt;/span&gt; =new &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_21"&gt;MenuItem&lt;/span&gt;("New");&lt;br /&gt;       &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_22"&gt;MenuItem&lt;/span&gt; open =new &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_23"&gt;MenuItem&lt;/span&gt;("Open");&lt;br /&gt;       &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_24"&gt;CheckboxMenuItem&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_25"&gt;cbm&lt;/span&gt;=new &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_26"&gt;CheckboxMenuItem&lt;/span&gt;("check");&lt;br /&gt;&lt;br /&gt;6.Call add() method of Menu class to add each menu item to its appropriate menu.&lt;br /&gt;&lt;br /&gt;        file.add(&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_27"&gt;newf&lt;/span&gt;);&lt;br /&gt;        file.add(open);&lt;br /&gt;        file.add(save);&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Complete Example :-&lt;/span&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_1CvsF-MJpr4/SiDmXcm0ikI/AAAAAAAAAMk/908wpOleSS8/s1600-h/menu+selected.JPG"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer; width: 248px; height: 262px;" src="http://4.bp.blogspot.com/_1CvsF-MJpr4/SiDmXcm0ikI/AAAAAAAAAMk/908wpOleSS8/s400/menu+selected.JPG" alt="" id="BLOGGER_PHOTO_ID_5341522448551807554" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);" class="blsp-spelling-corrected" id="SPELLING_ERROR_28"&gt;Source&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt; Code:-&lt;/span&gt;&lt;br /&gt;//&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_29"&gt;MyMenubar&lt;/span&gt;.java&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;import java.awt.*;&lt;br /&gt;public class &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_30"&gt;MyMenubar&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;public static void main(String a[])&lt;br /&gt;{&lt;br /&gt;   Frame frame=new Frame("&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_31"&gt;MenuBar&lt;/span&gt; Demo");&lt;br /&gt;   &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_32"&gt;MenuBar&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_33"&gt;mb&lt;/span&gt;=new &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_34"&gt;MenuBar&lt;/span&gt;();&lt;br /&gt;   frame.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_35"&gt;setMenuBar&lt;/span&gt;(&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_36"&gt;mb&lt;/span&gt;);&lt;br /&gt;   Menu file=new Menu("File");&lt;br /&gt;   Menu edit=new Menu("Edit");&lt;br /&gt;   Menu help=new Menu("Help");&lt;br /&gt;   Menu options=new Menu("Options");&lt;br /&gt;   &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_37"&gt;mb&lt;/span&gt;.add(file);&lt;br /&gt;   &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_38"&gt;mb&lt;/span&gt;.add(edit);&lt;br /&gt;   &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_39"&gt;mb&lt;/span&gt;.add(help);&lt;br /&gt;   &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_40"&gt;MenuItem&lt;/span&gt; save =new &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_41"&gt;MenuItem&lt;/span&gt;("Save");&lt;br /&gt;   &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_42"&gt;MenuItem&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_43"&gt;newf&lt;/span&gt; =new &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_44"&gt;MenuItem&lt;/span&gt;("New");&lt;br /&gt;   &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_45"&gt;MenuItem&lt;/span&gt; open =new &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_46"&gt;MenuItem&lt;/span&gt;("Open");&lt;br /&gt;   &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_47"&gt;CheckboxMenuItem&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_48"&gt;cbm&lt;/span&gt;=new &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_49"&gt;CheckboxMenuItem&lt;/span&gt;("check");&lt;br /&gt;   file.add(&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_50"&gt;newf&lt;/span&gt;);&lt;br /&gt;   file.add(open);&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_1CvsF-MJpr4/SiDmXA4m4WI/AAAAAAAAAMU/4YJbNB2bGlo/s1600-h/checkboxmenuitem.JPG"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer; width: 243px; height: 239px;" src="http://1.bp.blogspot.com/_1CvsF-MJpr4/SiDmXA4m4WI/AAAAAAAAAMU/4YJbNB2bGlo/s400/checkboxmenuitem.JPG" alt="" id="BLOGGER_PHOTO_ID_5341522441110217058" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;   file.add(save);&lt;br /&gt;   file.add(options);&lt;br /&gt;   options.add(new &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_51"&gt;MenuItem&lt;/span&gt;("Font"));&lt;br /&gt;   options.add(new &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_52"&gt;MenuItem&lt;/span&gt;("Size"));&lt;br /&gt;   options.add(new &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_53"&gt;MenuItem&lt;/span&gt;("Color"));&lt;br /&gt;   edit.add(&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_54"&gt;cbm&lt;/span&gt;);&lt;br /&gt;   &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_55"&gt;cbm&lt;/span&gt;.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_56"&gt;setState&lt;/span&gt;(true);&lt;br /&gt;   &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_57"&gt;cbm&lt;/span&gt;.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_58"&gt;setEnabled&lt;/span&gt;(false);&lt;br /&gt;   open.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_59"&gt;setEnabled&lt;/span&gt;(false);&lt;br /&gt;   frame.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_60"&gt;setVisible&lt;/span&gt;(true);&lt;br /&gt;   frame.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_61"&gt;setSize&lt;/span&gt;(300,300);&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/2124855005622377541-7307181931588225089?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/7307181931588225089/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/05/how-to-create-menubar-steps.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/7307181931588225089'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/7307181931588225089'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/05/how-to-create-menubar-steps.html' title='How to create MenuBar Steps'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_1CvsF-MJpr4/SiDmXLCAtDI/AAAAAAAAAMc/qI-EUjA3AJg/s72-c/menu+initial.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-2483250675746279483</id><published>2009-05-30T13:17:00.003+05:30</published><updated>2009-05-31T19:19:01.903+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java Swings'/><title type='text'>Menus In Java Swings</title><content type='html'>Every window can have a menu associated with it.Menu Bars basic function is to provide a list of choices.Each choice has its own drop-down menu(is provided otherwise none).This is implemented in Java by using following classes:-&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;MenuBar&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Menu&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;MenuItem&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;CheckboxMenuItem&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;A menu bar can contains many menu objects.Each menu object may contain many MenuItem objects.In this implementation it is also possible to include checkable menu items.These can be implemented by CheckboxMenuItem class and will place a check mark next to them when they get selected.&lt;br /&gt;&lt;br /&gt;First look at the constructors involved in creation of a menubar application.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;1. MenuBar:-&lt;/span&gt;MenuBar is the highest class in this application and it will contain all the menu's inside it.It has only default constructor.&lt;br /&gt;&lt;br /&gt;                //MenuBar ()  only default constructor&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;2.Menu:-&lt;/span&gt;The constructors for Menu is as following.Menu's object will hold menu item's in them.&lt;br /&gt;&lt;br /&gt;          //Menu()&lt;br /&gt;//Menu(String optionName)&lt;br /&gt;//Menu(String optionName,boolean Removable)&lt;br /&gt;&lt;br /&gt;         In this case optionName provides the name of menu selection.If removable are set to true then menu can be removed and allowed to roam free.Otherwise it will remain with the menu bar.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;3.MenuItem:-&lt;/span&gt;The Individual menuitems are of type MenuItem .These controls are to be placed on Menu object.&lt;br /&gt;&lt;br /&gt;//MenuItem()&lt;br /&gt;//MenuItem(String itemName)&lt;br /&gt;//MenuItem(String itemName,MenuShortcut key)&lt;br /&gt;&lt;br /&gt;         here itemName is the name of item shown on menu and key is the menu shortcut for this item.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;4.CheckboxMenuItem:-&lt;/span&gt;CheckboxMenuItem creates the checkboxes which can be placed as a menu and show their state by checked or unchecked.&lt;br /&gt;&lt;br /&gt;//CheckboxMenuItem()&lt;br /&gt;//CheckboxMenuItem(String itemName)&lt;br /&gt;//CheckboxMenuItem(String itemName,boolean on)&lt;br /&gt;&lt;br /&gt;         itemName refers to the name of checkbox displayed on menu and on refers its state checked or unchecked.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Important Methods:-&lt;/span&gt;There are methods with various functionality lets see&lt;br /&gt;&lt;br /&gt;1.void setEnabled(boolean flagvalue):-This method sets any menuitem to enabled or disabled state.Which specifies whether the menuitem is active or not(Click works or not).&lt;br /&gt;&lt;br /&gt;2.boolean isEnabled():-This method returns the value whether the menuitem is active or inactive.That is either true or false.&lt;br /&gt;&lt;br /&gt;3.void setLabel(String newName):-This method changes the name of  a menuitem.&lt;br /&gt;&lt;br /&gt;4.String getLabel():-It returns the name of the menuitem.&lt;br /&gt;&lt;br /&gt;5.boolean getState():-This method returns the value (checked or unchecked) of&lt;br /&gt;CheckboxMenuItem object.&lt;br /&gt;&lt;br /&gt;6.void setState(boolean checked):-You can set the value of CheckboxMenuItem to true or false using this method.&lt;br /&gt;&lt;br /&gt;For learning an example click below:-&lt;br /&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/05/how-to-create-menubar-steps.html"&gt;How Menu is created step wise step procedure&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-2483250675746279483?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/2483250675746279483/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/05/menus-in-java-swings.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/2483250675746279483'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/2483250675746279483'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/05/menus-in-java-swings.html' title='Menus In Java Swings'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-211510615547104460</id><published>2009-05-16T17:11:00.005+05:30</published><updated>2009-05-16T17:49:11.084+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Access Control and Declaration'/><category scheme='http://www.blogger.com/atom/ns#' term='Misc'/><title type='text'>Java Class Loader Architecture</title><content type='html'>Class loader is one of the main components of the JVM implementation.Since a JVM can have many class loaders and are thus used to provide security and network mobility to Java programs.&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-weight: bold;"&gt;The JVM has two types of Class loaders:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;1.Primordial Class Loader:-&lt;/span&gt;A Primordial Class loader is the part of JVM implementation.It loads only the Java API classes(not other classes) when we execute our Java programs.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;2.Class Loader Objects:-&lt;/span&gt;An application can create many class loaders at runtime for loading each and every class which is used in the program.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-weight: bold;"&gt;Following diagram depicts how the Class loader is implemented in JVM.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_1CvsF-MJpr4/Sg6rFtaPr-I/AAAAAAAAAMM/FLXqL6X2ChU/s1600-h/class+loader+arch.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 178px;" src="http://2.bp.blogspot.com/_1CvsF-MJpr4/Sg6rFtaPr-I/AAAAAAAAAMM/FLXqL6X2ChU/s400/class+loader+arch.bmp" alt="" id="BLOGGER_PHOTO_ID_5336390723057987554" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The classes in the primordial class loader are trusted since they are a part of JVM and Java API.The class loaded in the class loader object are not trusted .&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;Important:-&lt;/span&gt;Trusted classes are more authorized to use the resources of a local machine than untrusted classes.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;A class loader is just another object in Java.There is no difference in simple Java objects and class loader object.Since it is a part of Java program you can extend the Java program dynamically at runtime.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;How it works??&lt;/span&gt;&lt;br /&gt;When a class A refers to a class B,the class B is loaded into the same class loader as class A.Therefore,each class can only see the classes that are in the same name space.A name space has a list of classes loaded in the class loader.This is what we call default access(within same package).The classes loaded by different class loaders cannot access each other unless the application explicitly allows the access.In your program,You can load classes from different sources into class loaders and restrict the interaction between the code loaded from different sources.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Suggested Reading Links:-&lt;/span&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/05/java-architecture.html"&gt;Java Architecture&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/05/java-architecture-features-and.html"&gt;Java Architecture Features and tradeoff's&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Other Links:-&lt;/span&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/"&gt;Home&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.zlio.com/signup?r=351090"&gt;Open Your online shop Today for free!!!&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-211510615547104460?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/211510615547104460/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/05/java-class-loader-architecture.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/211510615547104460'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/211510615547104460'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/05/java-class-loader-architecture.html' title='Java Class Loader Architecture'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_1CvsF-MJpr4/Sg6rFtaPr-I/AAAAAAAAAMM/FLXqL6X2ChU/s72-c/class+loader+arch.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-2791850384574738249</id><published>2009-05-16T11:07:00.002+05:30</published><updated>2009-05-16T11:18:19.449+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Interview Questions'/><category scheme='http://www.blogger.com/atom/ns#' term='Control Statements'/><title type='text'>Java Basic questions:Control Statements</title><content type='html'>Following are some good basic questions of Control statements read them and make your fundamentals strong&lt;br /&gt;&lt;br /&gt;1) What are the programming constructs?&lt;br /&gt;Ans: a) Sequential&lt;br /&gt;b) Selection -- if and switch statements&lt;br /&gt;c) Iteration -- for loop, while loop and do-while loop&lt;br /&gt;&lt;br /&gt;2) class conditional {&lt;br /&gt;public static void main(String args[]) {&lt;br /&gt;int i = 20;&lt;br /&gt;int j = 55;&lt;br /&gt;int z = 0;&lt;br /&gt;z = i &lt; j ? i : j; // ternary operator&lt;br /&gt;System.out.println("The value assigned is " + z);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;What is output of the above program?&lt;br /&gt;Ans: The value assigned is 20&lt;br /&gt;&lt;br /&gt;3) The switch statement does not require a break.&lt;br /&gt;a)True&lt;br /&gt;b)False&lt;br /&gt;Ans: b.&lt;br /&gt;&lt;br /&gt;4) The conditional operator is otherwise known as the ternary operator.&lt;br /&gt;a)True&lt;br /&gt;b)False&lt;br /&gt;Ans: a.&lt;br /&gt;&lt;br /&gt;5) The while loop repeats a set of code while the condition is false.&lt;br /&gt;a)True&lt;br /&gt;b)False&lt;br /&gt;Ans: b.&lt;br /&gt;&lt;br /&gt;6) The do-while loop repeats a set of code atleast once before the condition is tested.&lt;br /&gt;a)True&lt;br /&gt;b)False&lt;br /&gt;Ans: a.&lt;br /&gt;&lt;br /&gt;7) What are difference between break and continue?&lt;br /&gt;Ans: The break keyword halts the execution of the current loop and forces control out of the loop.&lt;br /&gt;The continue is similar to break, except that instead of halting the execution of the loop, it starts the next iteration.&lt;br /&gt;&lt;br /&gt;8) The for loop repeats a set of statements a certain number of times until a condition is matched.&lt;br /&gt;a)True&lt;br /&gt;b)False&lt;br /&gt;Ans: a.&lt;br /&gt;&lt;br /&gt;9) Can a for statement loop indefintely?&lt;br /&gt;Ans : Yes.&lt;br /&gt;&lt;br /&gt;10) What is the difference between while statement and a do statement/&lt;br /&gt;Ans : A while statement checks at the beginning of a loop to see whether the next loop iteration should occur.&lt;br /&gt;A do statement checks at the end of a loop to see whether the next iteration of a loop should occur. The do statement will always execute the body of a loop at least once.&lt;br /&gt;&lt;br /&gt;Links:-&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/"&gt;Home&lt;/a&gt;&lt;br /&gt;&lt;a href="http://indiaisonline.blogspot.com"&gt;India Online&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/search/label/Interview%20Questions"&gt;Other Java Questions&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.zlio.com/signup?r=351090"&gt;Open Your Online Store for free!!!&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-2791850384574738249?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/2791850384574738249/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/05/java-basic-questionscontrol-statements.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/2791850384574738249'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/2791850384574738249'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/05/java-basic-questionscontrol-statements.html' title='Java Basic questions:Control Statements'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-5855450532114188030</id><published>2009-05-13T02:28:00.005+05:30</published><updated>2009-05-13T04:01:58.773+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Access Control and Declaration'/><category scheme='http://www.blogger.com/atom/ns#' term='Misc'/><title type='text'>Java Architecture Features and TradeOff's</title><content type='html'>&lt;div style="text-align: justify;"&gt;Java has become a very popular programming language due to its capability of executing the program on any machine irrespective of where its compilation is being done.There are three main features offered by Java Architecture.&lt;br /&gt;&lt;br /&gt;&lt;ul style="color: rgb(0, 0, 0);"&gt;&lt;li&gt;Platform Independence.&lt;/li&gt;&lt;li&gt;Security.&lt;/li&gt;&lt;li&gt;Network Mobility.&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-size:100%;"&gt; &lt;span style="font-weight: bold;"&gt;Platform Independence:-&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The support for platform Independence is spread across all four components of the Java architecture.All these components were told in &lt;a href="http://javatutorialsworld.blogspot.com/2009/05/java-architecture.html"&gt;previous tutorial&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt; The Java platform:-&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; &lt;/span&gt;The Java platform insulates the Java program from the hardware and operating system on the target machine.Java program are compiled to execute on the JVM.The Java API enables programs to use system resources.All Java program can only interact with the JVM,that is why it can be executed on any machine that hosts JVM.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;The Java Language:- &lt;/span&gt;The Java Language defines the range and behaviour of primitive data types.For example in C and C++ ,the target machine platform determines the size of the data types.For Example int in C and C++ may occupy 2 bytes in one platform and 4 bytes in the other.This results in unpredictable results across the various platforms.But in Java ,the primitive data type are the same across all platforms.This is all due to the JVM.Since JVM uses the data types defined by the language and therefore,the data type behaviour remains same on all platforms .&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;The Java class file:-&lt;/span&gt;The Java class file is a binary standard for files that can be executed by the JVM.The bytecode(class file) which is produced after compilation is platform independent.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;NOTE:-&lt;/span&gt;There are specifications that you can use native libraries in Java but using Native methods affects the platform independence of Java.If a Java program invokes a native method,the program becomes platform specific.Native methods are used when the certain conditions are there:-&lt;br /&gt;&lt;br /&gt;&lt;ul style="color: rgb(0, 0, 0);"&gt;&lt;li&gt;The resources of the machine cannot be accessed through Java API.&lt;/li&gt;&lt;li&gt;A set of methods exists in non-Java API.&lt;/li&gt;&lt;li&gt;The speed of the program needs to be increased.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Security:-&lt;/span&gt;&lt;/span&gt;Java is perfect language for networks.Any network-oriented software must deal with security.Java's security model makes it appropriate for network-oriented programming.Java code  is loaded, for example an applet loaded by a browser may contain a virus or malicious code.Java protects its end users from such threats by using a sandbox model.&lt;br /&gt;&lt;br /&gt;There are some restrictions imposed on untrusted code(applet)&lt;br /&gt;&lt;br /&gt;&lt;ul style="color: rgb(0, 0, 0);"&gt;&lt;li&gt;It cannot neither read nor write the local files.&lt;/li&gt;&lt;li&gt;It can make a connection only to the machine from where it was downloaded.&lt;/li&gt;&lt;li&gt;It cannot load new dynamic linked libraries.&lt;/li&gt;&lt;li&gt;It cannot call a native method.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;The Java Sandbox:- &lt;/span&gt; The sandbox allows code to be downloaded from any source but imposing some restrictions on it.A Java sandbox is an area in memory outside which the Java programs cannot make calls .This prevents Java programs from being able to call low level system functions that may cause data corruption or other damages.The Java&lt;br /&gt;Sandbox has three components:-&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;1.The ByteCode Verifier:-&lt;/span&gt;The first level of Java security is Bytecode verifier.The bytecode is verified before it is allowed to run on the users machine.It is checked to authenticate its creation by a Java compiler.ByteCode verifier make sure that the format of the bytecode fragment is correct.A algorithm is applied to chck that the bytecode does not violate access restrictions or try to access object using incorrect or bad information.The bytecode verification is done in two phases .In first phase the verifier checks for the validity of the bytecode when it is loaded,this is done by checking the structure of the .class file.In second phase verifier checks for the validity of the classes,the variables,and the methods used in the program.This is done because Java programs are dynamically linked.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;2.The Applet Class Loader :-&lt;/span&gt;The second level of security is in the applet call loader.All java objects belong to classes and the applet class loader determines how and when an applet is allowed to add classes to a running Java environment.It also makes sure that important parts of JRE are not replaced by any applet code.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;3.The Security Manager:-&lt;/span&gt;The third and most important level of Java sandbox,is security manager.The security manager defines the boundary of a sandbox.The Java API refers to the security manager before it allows any access to resource.While loading classes ,the class loaded always follow the security managers decisions.Built-in classes are given preferences over classes loaded over the Network.This sandbox can be used to run untrusted code on the user's machine.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;NOTE:&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;-&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Java Protected Domain:- &lt;/span&gt; It is an extension of Java sandbox in a file system.Java protected domains enable use of permissions for providing access to function calls outside the sandbox.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Network mobility:-&lt;/span&gt;Java  offers platform independence and security two essential parameters that make a program network-oriented.One program can serve the entire network that comprises of machines using different operating systems.&lt;br /&gt;Another issue in network mobility is amount of time it take to download a program for the network.As Java is dynamically linked,you need not wait for all the .class files to be loaded before you execute a program.The .class file is compact and travels quickly across the network.Only classes that are used in the course of the program execution are downloaded.Class loaders also help in extending the program dynamically.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-size:130%;" &gt;&lt;span style="font-weight: bold;"&gt; Java Architecture Trade off&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Java offers many features for a networked programmer.The price paid for these feature is a trade off on the execution speed of Java programs.It is well known that C++ programs are faster than Java programs due to following reasons:-&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Interpreting bytecode is slower than executing the machine code for C++.&lt;/li&gt;&lt;li&gt;Checks on array bounds are made for each and every array.&lt;/li&gt;&lt;li&gt;The garbage collector needs to be more efficient and faster than it is at present.&lt;/li&gt;&lt;li&gt;Java programs are dynamically linked and therefore,the programs has to wait for bytecode to get downloaded.&lt;/li&gt;&lt;li&gt;All the variables are checked for types at runtime.&lt;/li&gt;&lt;/ul&gt;Links:-&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/"&gt;&lt;&lt;home&gt;&lt;/home&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/05/java-architecture.html"&gt;Java Architecture&lt;/a&gt;&lt;br /&gt;&lt;a href="http://bux.to/?r=va28"&gt;Earn money Quick&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.zlio.com/signup?r=351090"&gt;Open your Online Store now!!!!&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-5855450532114188030?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/5855450532114188030/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/05/java-architecture-features-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/5855450532114188030'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/5855450532114188030'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/05/java-architecture-features-and.html' title='Java Architecture Features and TradeOff&apos;s'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-2129623201985509824</id><published>2009-05-12T11:55:00.004+05:30</published><updated>2009-05-12T12:47:14.152+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Misc'/><title type='text'>I have Opened My Own Shop</title><content type='html'>Wow!!! Today I have created my first online store.It sounds great to have your own.My store has everything a person would like.It is not as big but I will work on it and add as many products I can .You can visit my store &lt;a href="http://vaibhav.zlio.net/"&gt;here&lt;/a&gt;.It currently contains the gaming products like gaming consoles including Nintendo Wii,XBOX,Sony playstation etc.The games according to each console is also provided.&lt;br /&gt;&lt;br /&gt;&lt;a style="font-weight: bold; color: rgb(255, 0, 0);" href="http://vaibhav.zlio.net/"&gt;My Store&lt;/a&gt;&lt;a style="color: rgb(255, 0, 0);" href="http://vaibhav.zlio.net/"&gt;!!!!!&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I have one more thing to tell that you can also create your own shop in few clicks and you can also earn upto 10% commission on each sale you have made.They have a very interesting referral program too in which you will get 10% commission on your first level referrals and 5% commission on your second level referrals.&lt;br /&gt;&lt;br /&gt;But what you have to do that you have to frequently update your shop according to need otherwise your shop will be closed.You can check this program by clicking &lt;a href="http://www.zlio.com/signup?r=351090"&gt;here&lt;/a&gt;.You can get your thematic shops that belongs to only one theme like if you are interested in computers you can open your computer shop.You are just a few clicks away from earning a good sound income.The best part is they pay through PAYPAL and you don't have to bother about the shipping of product bought.Its great check it out:-&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.zlio.com/signup?r=351090"&gt;&lt;span style="font-weight: bold;"&gt;Open your shop here&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_1CvsF-MJpr4/SgkfEpcdu_I/AAAAAAAAAME/966Qvuw5JNk/s1600-h/PUBDM-US.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 300px; height: 250px;" src="http://3.bp.blogspot.com/_1CvsF-MJpr4/SgkfEpcdu_I/AAAAAAAAAME/966Qvuw5JNk/s400/PUBDM-US.gif" alt="" id="BLOGGER_PHOTO_ID_5334829398302243826" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-2129623201985509824?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/2129623201985509824/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/05/i-have-opened-my-own-shop.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/2129623201985509824'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/2129623201985509824'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/05/i-have-opened-my-own-shop.html' title='I have Opened My Own Shop'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_1CvsF-MJpr4/SgkfEpcdu_I/AAAAAAAAAME/966Qvuw5JNk/s72-c/PUBDM-US.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-1051086014823804135</id><published>2009-05-12T11:09:00.003+05:30</published><updated>2009-05-12T11:22:21.998+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Access Control and Declaration'/><category scheme='http://www.blogger.com/atom/ns#' term='Misc'/><title type='text'>Java Architecture</title><content type='html'>According to Sun Microsystems the Java architecture comprises of four components.Each of them is defined by Sun Microsystems.&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;The Components are:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;ul style="text-align: justify;"&gt;&lt;li&gt;1.Java Programming Language&lt;/li&gt;&lt;li&gt;2.Java class file format&lt;/li&gt;&lt;li&gt;3.Java Virtual Machine&lt;/li&gt;&lt;li&gt;4.Java (API) Application Programming Interface.&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Every Java program uses features of all the four components.They are used in following sequence:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;ol style="text-align: justify;"&gt;&lt;li&gt;We write code in Java programming Language.&lt;/li&gt;&lt;li&gt;When we compile the .java file it creates a new file which is called as the class file(also called  bytecode).&lt;/li&gt;&lt;li&gt;The .class file(or class file) is executed by the JVM.&lt;/li&gt;&lt;li&gt;When we execute the program the method calls are made through the Java API.The above &lt;/li&gt;&lt;/ol&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Sequence may be represented as following block diagram:-&lt;/span&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_1CvsF-MJpr4/SgkNPrhrDbI/AAAAAAAAAL8/mOweD9Jrhcw/s1600-h/architecture.bmp"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 118px;" src="http://1.bp.blogspot.com/_1CvsF-MJpr4/SgkNPrhrDbI/AAAAAAAAAL8/mOweD9Jrhcw/s400/architecture.bmp" alt="" id="BLOGGER_PHOTO_ID_5334809796630220210" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;The JVM and the Java API forms the basic Java runtime system and is must to execute any java program.The specification provided by the Sun Microsystems only lists the components features but this specification lacks the way how these features to be implemented.The implementation is always left to the designers.The JVM is provided by many vendors, mostly it comes along with the Operating System.All the JVM's must have some unique features that is why it is said that "Threads are JVM  behaviour dependent".So its important to figure out how your JVM performs internal task of scheduling,memory related issues and other performance matrices.Although the JVM vendors and JVM functioning is a bit different but still all of them follow the Sun Microsystems Specification for Java Architecture.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;Links:-&lt;/span&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com"&gt;Home&lt;/a&gt;&lt;br /&gt;&lt;a href="http://bux.to/?r=va28"&gt;Earn Money Quick&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-1051086014823804135?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/1051086014823804135/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/05/java-architecture.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/1051086014823804135'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/1051086014823804135'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/05/java-architecture.html' title='Java Architecture'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_1CvsF-MJpr4/SgkNPrhrDbI/AAAAAAAAAL8/mOweD9Jrhcw/s72-c/architecture.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-4956936985012069747</id><published>2009-05-11T15:30:00.003+05:30</published><updated>2009-05-11T15:49:48.426+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Operators'/><category scheme='http://www.blogger.com/atom/ns#' term='Interview Questions'/><title type='text'>Simple Java Twisters</title><content type='html'>Hi guys I am back after giving away the so called tough exam "The advanced computer architecture".That was fine but I am not enjoyed it at all.But here are some twisters you guys must enjoy, at first sight they seem simple but mind you they are very simple to twist you.Check them out.These twisters surely gonna test your program understanding capabilities, so be prepared.If you think you got the answers right then check on your own ,just copy this code and try to run it on your system.If you got answers matched with yours then you are not twisted by them else no worries just try to make your basics strong.Some guys will find these questions really easy but I must say these are just for guys who want some fun from programming.&lt;br /&gt;&lt;br /&gt;Here they come:-&lt;br /&gt;&lt;br /&gt;1.What would be the output of following code segment&lt;br /&gt;&lt;br /&gt;public class test&lt;br /&gt;{&lt;br /&gt;    public static void main(String a[])&lt;br /&gt;    {&lt;br /&gt;        boolean x;&lt;br /&gt;        if(x=true)&lt;br /&gt;        System.out.println("This is true");   &lt;br /&gt;        else&lt;br /&gt;        System.out.println("This is false");   &lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;2.What would be the output of following code:-&lt;br /&gt;&lt;br /&gt;public class maintest&lt;br /&gt;{&lt;br /&gt;    public static int main(String a[])&lt;br /&gt;    {&lt;br /&gt;        int x=10;&lt;br /&gt;        if(x++)&lt;br /&gt;            System.out.println(x++);&lt;br /&gt;        else&lt;br /&gt;            System.out.println(++x);   &lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;3.What would be the output of following code:-&lt;br /&gt;&lt;br /&gt;public class inttest&lt;br /&gt;{&lt;br /&gt;    public static void main(String a[])&lt;br /&gt;    {&lt;br /&gt;        int x=20;&lt;br /&gt;        if(x==x++)&lt;br /&gt;        System.out.println("This is true");   &lt;br /&gt;        else&lt;br /&gt;        System.out.println("This is false");   &lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;4.What would be the output of following code:-&lt;br /&gt;&lt;br /&gt;public class inttest4&lt;br /&gt;{&lt;br /&gt;    public static void main(String a[])&lt;br /&gt;    {&lt;br /&gt;        int x=20;&lt;br /&gt;        if(x+1 ==((x++ + ++x)/2))&lt;br /&gt;        System.out.println("This is true");   &lt;br /&gt;        else&lt;br /&gt;        System.out.println("This is false");   &lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;5.What  would be the output of following code:-&lt;br /&gt;&lt;br /&gt;public class inttest3&lt;br /&gt;{&lt;br /&gt;    public static void main(String a[])&lt;br /&gt;    {&lt;br /&gt;        int x=20;&lt;br /&gt;        if(x+1 ==((++x + x++)/2))&lt;br /&gt;        System.out.println("This is true");   &lt;br /&gt;        else&lt;br /&gt;        System.out.println("This is false");   &lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;6.what would be the output of following code:-&lt;br /&gt;&lt;br /&gt;public class inttest2&lt;br /&gt;{&lt;br /&gt;    public static void main(String a[])&lt;br /&gt;    {&lt;br /&gt;        int x=20;&lt;br /&gt;        if(x==++x)&lt;br /&gt;        System.out.println("This is true");   &lt;br /&gt;        else&lt;br /&gt;        System.out.println("This is false");   &lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Links:-&lt;br /&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com"&gt;Home&lt;/a&gt;&lt;br /&gt;&lt;a href="http://bux.to/?r=va28"&gt;Earn money Quick&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-4956936985012069747?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/4956936985012069747/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/05/simple-java-twisters.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/4956936985012069747'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/4956936985012069747'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/05/simple-java-twisters.html' title='Simple Java Twisters'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-7880871271473270215</id><published>2009-05-09T15:07:00.004+05:30</published><updated>2009-05-09T15:22:57.487+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Operators'/><category scheme='http://www.blogger.com/atom/ns#' term='Interview Questions'/><category scheme='http://www.blogger.com/atom/ns#' term='Control Statements'/><title type='text'>Java Practice and Interview Questions:Operators</title><content type='html'>&lt;span style="color: rgb(0, 0, 0);"&gt;Here are Some Important questions of Operators which are frequently asked in practical viva's and Job Interviews.They are a bit theoretical but they are very basic questions.&lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 255);"&gt;&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(51, 51, 255);"&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/search/label/Operators"&gt;Operators&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;1) What are operators and what are the various types of operators available in Java?&lt;br /&gt;Ans: Operators are special symbols used in expressions.&lt;br /&gt;The following are the types of operators:&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/02/arithmetic-operators.html"&gt;Arithmetic operators&lt;/a&gt;,&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/02/assignment-operators.html"&gt;Assignment operators, &lt;/a&gt;&lt;br /&gt;Increment &amp;amp; Decrement operators,&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/02/logical-operators.html"&gt;Logical operators,&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/03/bitwise-operator-introduction.html"&gt;Bitwise operators, &lt;/a&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/02/relational-operator.html"&gt;&lt;br /&gt;Comparison/Relational operators &lt;/a&gt;and&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/02/conditional-operator.html"&gt;Conditional operators&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;2) The ++ operator is used for incrementing and the -- operator is used for&lt;br /&gt;decrementing.&lt;br /&gt;a)True&lt;br /&gt;b)False&lt;br /&gt;Ans: a.&lt;br /&gt;&lt;br /&gt;3) Comparison/Logical operators are used for testing and magnitude.&lt;br /&gt;a)True&lt;br /&gt;b)False&lt;br /&gt;Ans: a.&lt;br /&gt;&lt;br /&gt;4) Character literals are stored as unicode characters.&lt;br /&gt;a)True&lt;br /&gt;b)False&lt;br /&gt;Ans: a.&lt;br /&gt;&lt;br /&gt;5) What are the Logical operators?&lt;br /&gt;Ans: OR(|), AND(&amp;amp;), XOR(^) AND NOT(~).&lt;br /&gt;&lt;br /&gt;6) What is the % operator?&lt;br /&gt;Ans : % operator is the modulo operator or reminder operator. It returns the reminder of dividing the first operand by second operand.&lt;br /&gt;&lt;br /&gt;7) What is the value of 111 % 13?&lt;br /&gt;a)3&lt;br /&gt;b)5&lt;br /&gt;c)7&lt;br /&gt;d)9&lt;br /&gt;Ans : c.&lt;br /&gt;&lt;br /&gt;8) Is &amp;amp;&amp;amp;= a valid operator?&lt;br /&gt;Ans : No.&lt;br /&gt;&lt;br /&gt;9) Can a double value be cast to a byte?&lt;br /&gt;Ans : Yes&lt;br /&gt;&lt;br /&gt;10) Can a byte object be cast to a double value ?&lt;br /&gt;Ans : No. An object cannot be cast to a primitive value.&lt;br /&gt;&lt;br /&gt;11) What are order of precedence and associativity?&lt;br /&gt;Ans : Order of precedence the order in which operators are evaluated in expressions.&lt;br /&gt;Associativity determines whether an expression is evaluated left-right or right-left.&lt;br /&gt;&lt;br /&gt;12) Which Java operator is right associativity?&lt;br /&gt;Ans : = operator.&lt;br /&gt;&lt;br /&gt;13) What is the difference between prefix and postfix of -- and ++ operators?&lt;br /&gt;Ans : The prefix form returns the increment or decrement operation and returns the value of the increment or decrement operation.&lt;br /&gt;The postfix form returns the current value of all of the expression and then&lt;br /&gt;performs the increment or decrement operation on that value.&lt;br /&gt;&lt;br /&gt;14) What is the result of expression 5.45 + "3,2"?&lt;br /&gt;a)The double value 8.6&lt;br /&gt;b)The string ""8.6"&lt;br /&gt;c)The long value 8.&lt;br /&gt;d)The String "5.453.2"&lt;br /&gt;Ans : d&lt;br /&gt;&lt;br /&gt;15) What are the values of x and y ?&lt;br /&gt;x = 5; y = ++x;&lt;br /&gt;Ans : x = 6; y = 6&lt;br /&gt;&lt;br /&gt;16) What are the values of x and z?&lt;br /&gt;x = 5; z = x++;&lt;br /&gt;Ans : x = 6; z = 5&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(51, 51, 255);"&gt;Control Statements&lt;/span&gt;&lt;br /&gt;1) What are the programming constructs?&lt;br /&gt;Ans: a) Sequential&lt;br /&gt;b) Selection -- if and switch statements&lt;br /&gt;c) Iteration -- for loop, while loop and do-while loop&lt;br /&gt;&lt;br /&gt;2) class conditional {&lt;br /&gt;public static void main(String args[]) {&lt;br /&gt;int i = 20;&lt;br /&gt;int j = 55;&lt;br /&gt;int z = 0;&lt;br /&gt;z = i &lt; j ? i : j; // ternary operator&lt;br /&gt;System.out.println("The value assigned is " + z);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;What is output of the above program?&lt;br /&gt;Ans: The value assigned is 20&lt;br /&gt;3) The switch statement does not require a break.&lt;br /&gt;a)True&lt;br /&gt;b)False&lt;br /&gt;Ans: b.&lt;br /&gt;&lt;br /&gt;4) The conditional operator is otherwise known as the ternary operator.&lt;br /&gt;a)True&lt;br /&gt;b)False&lt;br /&gt;Ans: a.&lt;br /&gt;&lt;br /&gt;5) The while loop repeats a set of code while the condition is false.&lt;br /&gt;a)True&lt;br /&gt;b)False&lt;br /&gt;Ans: b.&lt;br /&gt;&lt;br /&gt;6) The do-while loop repeats a set of code atleast once before the condition is tested.&lt;br /&gt;a)True&lt;br /&gt;b)False&lt;br /&gt;Ans: a.&lt;br /&gt;&lt;br /&gt;7) What are difference between break and continue?&lt;br /&gt;Ans: The break keyword halts the execution of the current loop and forces control out of the loop.&lt;br /&gt;The continue is similar to break, except that instead of halting the execution of the loop, it starts the next iteration.&lt;br /&gt;&lt;br /&gt;8) The for loop repeats a set of statements a certain number of times until a condition is matched.&lt;br /&gt;a)True&lt;br /&gt;b)False&lt;br /&gt;Ans: a.&lt;br /&gt;&lt;br /&gt;9) Can a for statement loop indefinitely?&lt;br /&gt;Ans : Yes.&lt;br /&gt;&lt;br /&gt;10) What is the difference between while statement and a do statement/&lt;br /&gt;Ans : A while statement checks at the beginning of a loop to see whether the next loop iteration should occur.&lt;br /&gt;A do statement checks at the end of a loop to see whether the next iteration of a loop should occur. The do statement will always execute the body of a loop at least once.&lt;br /&gt;&lt;br /&gt;Links:-&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com"&gt;Home&lt;/a&gt;&lt;br /&gt;&lt;a href="http://bux.to/?r=va28"&gt;Earn Quick Money&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-7880871271473270215?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/7880871271473270215/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/05/java-practice-and-interview.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/7880871271473270215'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/7880871271473270215'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/05/java-practice-and-interview.html' title='Java Practice and Interview Questions:Operators'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-8708457795354853281</id><published>2009-05-07T18:06:00.003+05:30</published><updated>2009-05-07T18:19:28.622+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Access Control and Declaration'/><category scheme='http://www.blogger.com/atom/ns#' term='Interview Questions'/><title type='text'>Java Basic Questions</title><content type='html'>&lt;div style="text-align: justify;"&gt;List of Java Basic Questions which are frequently asked in Technical Interviews:-&lt;br /&gt;&lt;br /&gt;1.The Java  interpreter is used for the execution of the source code.&lt;br /&gt;True&lt;br /&gt;False&lt;br /&gt;Ans: a.&lt;br /&gt;&lt;br /&gt;2) On successful compilation a file with the class extension is created.&lt;br /&gt;a) True&lt;br /&gt;b) False&lt;br /&gt;Ans: a.&lt;br /&gt;&lt;br /&gt;3) The Java source code can be created in a Notepad editor.&lt;br /&gt;a) True&lt;br /&gt;b) False&lt;br /&gt;Ans: a.&lt;br /&gt;&lt;br /&gt;4) The Java Program is enclosed in a class definition.&lt;br /&gt;a) True&lt;br /&gt;b) False&lt;br /&gt;Ans: a.&lt;br /&gt;&lt;br /&gt;5) What declarations are required for every Java application?&lt;br /&gt;Ans: A class and the main( ) method declarations.&lt;br /&gt;&lt;br /&gt;6) What are the two parts in executing a Java program and their purposes?&lt;br /&gt;Ans: Two parts in executing a Java program are:&lt;br /&gt;Java Compiler and Java Interpreter.&lt;br /&gt;The Java Compiler is used for compilation and the Java Interpreter is used for execution of the application.&lt;br /&gt;&lt;br /&gt;7) What are the three OOPs principles and define them?&lt;br /&gt;Ans : Encapsulation, Inheritance and Polymorphism are the three OOPs&lt;br /&gt;Principles.&lt;br /&gt;Encapsulation:&lt;br /&gt;Is the Mechanism that binds together code and the data it manipulates, and keeps both safe from outside interference and misuse.&lt;br /&gt;Inheritance:&lt;br /&gt;Is the process by which one object acquires the properties of another object.&lt;br /&gt;Polymorphism:&lt;br /&gt;Is a feature that allows one interface to be used for a general class of actions.&lt;br /&gt;&lt;br /&gt;8) What is a compilation unit?&lt;br /&gt;Ans : Java source code file.&lt;br /&gt;&lt;br /&gt;9) What output is displayed as the result of executing the following statement?&lt;br /&gt;System.out.println("// Looks like a comment.");&lt;br /&gt;// Looks like a comment&lt;br /&gt;The statement results in a compilation error&lt;br /&gt;Looks like a comment&lt;br /&gt;No output is displayed&lt;br /&gt;Ans : a.&lt;br /&gt;&lt;br /&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;br /&gt;a)It must have a package statement&lt;br /&gt;b)It must be named Test.java&lt;br /&gt;c)It must import java.lang&lt;br /&gt;c)It must declare a public class named Test&lt;br /&gt;Ans : b&lt;br /&gt;&lt;br /&gt;11) What are identifiers and what is naming convention?&lt;br /&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;br /&gt;&lt;br /&gt;12) What is the return type of program’s main( ) method?&lt;br /&gt;Ans : void&lt;br /&gt;&lt;br /&gt;13) What is the argument type of program’s main( ) method?&lt;br /&gt;Ans : string array.&lt;br /&gt;&lt;br /&gt;14) Which characters are as first characters of an identifier?&lt;br /&gt;Ans : A – Z, a – z, _ ,$&lt;br /&gt;&lt;br /&gt;15) What are different comments?&lt;br /&gt;Ans : 1) // -- single line comment&lt;br /&gt;2) /* --&lt;br /&gt;*/ multiple line comment&lt;br /&gt;3) /** --&lt;br /&gt;*/ documentation&lt;br /&gt;&lt;br /&gt;16) What is the difference between constructor method and method?&lt;br /&gt;Ans : Constructor will be automatically invoked when an object is created. Whereas method has to be call explicitly.&lt;br /&gt;&lt;br /&gt;17) What is the use of bin and lib in JDK?&lt;br /&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;br /&gt; &lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Data types,variables and Arrays&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;1) What is meant by variable?&lt;br /&gt;Ans: Variables are locations in memory that can hold values. Before assigning any value to a variable, it must be declared.&lt;br /&gt;&lt;br /&gt;2) What are the kinds of variables in Java? What are their uses?&lt;br /&gt;Ans: Java has three kinds of variables namely, the instance variable, the local variable and the class variable.&lt;br /&gt;Local variables are used inside blocks as counters or in methods as temporary variables and are used to store information needed by a single method.&lt;br /&gt;Instance variables are used to define attributes or the state of a particular object and are used to store information needed by multiple methods in the objects.&lt;br /&gt;Class variables are global to a class and to all the instances of the class and are useful for communicating between different objects of all the same class or keeping track of global states.&lt;br /&gt;&lt;br /&gt;3) How are the variables declared?&lt;br /&gt;Ans: Variables can be declared anywhere in the method definition and can be initialized during their declaration.They are commonly declared before usage at the beginning of the definition.&lt;br /&gt;Variables with the same data type can be declared together. Local variables must be given a value before usage.&lt;br /&gt;&lt;br /&gt;4) What are variable types?&lt;br /&gt;Ans: Variable types can be any data type that java supports, which includes the eight primitive data types, the name of a class or interface and an array.&lt;br /&gt;&lt;br /&gt;5) How do you assign values to variables?&lt;br /&gt;Ans: Values are assigned to variables using the assignment operator =.&lt;br /&gt;&lt;br /&gt;6) What is a literal? How many types of literals are there?&lt;br /&gt;Ans: A literal represents a value of a certain type where the type describes how that value behaves.&lt;br /&gt;There are different types of literals namely number literals, character literals,&lt;br /&gt;boolean literals, string literals,etc.&lt;br /&gt;&lt;br /&gt;7) What is an array?&lt;br /&gt;Ans: An array is an object that stores a list of items.&lt;br /&gt;&lt;br /&gt;8) How do you declare an array?&lt;br /&gt;Ans: Array variable indicates the type of object that the array holds.&lt;br /&gt;Ex: int arr[];&lt;br /&gt;&lt;br /&gt;9) Java supports multidimensional arrays.&lt;br /&gt;a)True&lt;br /&gt;b)False&lt;br /&gt;Ans: a.&lt;br /&gt;&lt;br /&gt;10) An array of arrays can be created.&lt;br /&gt;a)True&lt;br /&gt;b)False&lt;br /&gt;Ans: a.&lt;br /&gt;&lt;br /&gt;11) What is a string?&lt;br /&gt;Ans: A combination of characters is called as string.&lt;br /&gt;&lt;br /&gt;12) Strings are instances of the class String.&lt;br /&gt;a)True&lt;br /&gt;b)False&lt;br /&gt;Ans: a.&lt;br /&gt;&lt;br /&gt;13) When a string literal is used in the program, Java automatically creates instances of the string class.&lt;br /&gt;a)True&lt;br /&gt;b)False&lt;br /&gt;Ans: a.&lt;br /&gt;&lt;br /&gt;14) Which operator is to create and concatenate string?&lt;br /&gt;Ans: Addition operator(+).&lt;br /&gt;&lt;br /&gt;15) Which of the following declare an array of string objects?&lt;br /&gt;a)String[ ] s;&lt;br /&gt;b)String [ ]s:&lt;br /&gt;c)String[ s]:&lt;br /&gt;d)String s[ ]:&lt;br /&gt;Ans : a, b and d&lt;br /&gt;&lt;br /&gt;16) What is the value of a[3] as the result of the following array declaration?&lt;br /&gt;a)1&lt;br /&gt;b)2&lt;br /&gt;c)3&lt;br /&gt;d)4&lt;br /&gt;Ans : d&lt;br /&gt;&lt;br /&gt;17) Which of the following are primitive types?&lt;br /&gt;a)byte&lt;br /&gt;b)String&lt;br /&gt;c)integer&lt;br /&gt;d)Float&lt;br /&gt;Ans : a.&lt;br /&gt;&lt;br /&gt;18) What is the range of the char type?&lt;br /&gt;a)0 to 216&lt;br /&gt;b)0 to 215&lt;br /&gt;c)0 to 216-1&lt;br /&gt;d)0 to 215-1&lt;br /&gt;Ans. d&lt;br /&gt;&lt;br /&gt;19) What are primitive data types?&lt;br /&gt;Ans : byte, short, int, long&lt;br /&gt;float, double&lt;br /&gt;boolean&lt;br /&gt;char&lt;br /&gt;&lt;br /&gt;20) What are default values of different primitive types?&lt;br /&gt;Ans : int - 0&lt;br /&gt;short - 0&lt;br /&gt;byte - 0&lt;br /&gt;long - 0 l&lt;br /&gt;float - 0.0 f&lt;br /&gt;double - 0.0 d&lt;br /&gt;boolean - false&lt;br /&gt;char - null&lt;br /&gt;&lt;br /&gt;21) Converting of primitive types to objects can be explicitly.&lt;br /&gt;a)True&lt;br /&gt;b)False&lt;br /&gt;Ans: b.&lt;br /&gt;&lt;br /&gt;22) How do we change the values of the elements of the array?&lt;br /&gt;Ans : The array subscript expression can be used to change the values of the elements of the array.&lt;br /&gt;&lt;br /&gt;23) What is final variable?&lt;br /&gt;Ans : If a variable is declared as final variable, then you can not change its value. It becomes constant.&lt;br /&gt;&lt;br /&gt;24) What is static variable?&lt;br /&gt;Ans : Static variables are shared by all instances of a class.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Links:-&lt;/span&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com"&gt;Home&lt;/a&gt;&lt;br /&gt;&lt;a href="http://bux.to/?r=va28"&gt;Earn Quick Money&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/04/java-practice-questions.html"&gt;Java Practice Questions&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/02/best-java-interview-questions.html"&gt;Best Java Interview Questions&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-8708457795354853281?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/8708457795354853281/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/05/java-basic-questions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/8708457795354853281'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/8708457795354853281'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/05/java-basic-questions.html' title='Java Basic Questions'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-9152377149362626103</id><published>2009-05-07T15:36:00.006+05:30</published><updated>2009-05-07T16:17:11.008+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java utilities'/><title type='text'>Compute any day in calendar using Java.Util package</title><content type='html'>&lt;div style="text-align: justify;"&gt;Computing a day on any date is not an easy task,it can't be done so easily.By using below given source code you can compute any day which will come after your mentioned date whether it may be tomorrow or after 25 years very easily.Java.Util package has been used.This code is developed when I was doing coding for railway reservation system and the condition was to make reservation in advance say 30 days or more.This Program takes input in the specified date format which is mentioned in static method now().This method returns a String of current date.Here we have taken the two dates specifically but you can add interactivity in your program by taking date as a input.But note that the dates must be of same format. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Example(Source Code):-&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 102, 0);"&gt;// Created by vaibhav Pandey&lt;/span&gt;&lt;br /&gt;//diffdays.java&lt;br /&gt;&lt;br /&gt;import java.util.Calendar;&lt;br /&gt;import java.io.Serializable;&lt;br /&gt;import java.util.Date;&lt;br /&gt;import java.text.SimpleDateFormat;&lt;br /&gt;&lt;br /&gt;public class diffdays&lt;br /&gt;{&lt;br /&gt;   public static String now(String dateFormat) {&lt;br /&gt;   Calendar cal = Calendar.getInstance();&lt;br /&gt;   SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);&lt;br /&gt;   return sdf.format(cal.getTime());&lt;br /&gt;  } &lt;br /&gt;   public static void main(String a[])&lt;br /&gt;   {&lt;br /&gt; &lt;br /&gt;   long diffDays;&lt;br /&gt;    int k;&lt;br /&gt;    String tempTo="";&lt;br /&gt;    String tempFrom="";&lt;br /&gt;    SimpleDateFormat df = new SimpleDateFormat("yyyy/mm/dd");&lt;br /&gt;    Date from =new Date(diffdays.now("yyyy/MM/dd"));&lt;br /&gt;    Date to =new Date("2009/05/10");&lt;br /&gt;     &lt;br /&gt;    long diffMillis = to.getTime() - from.getTime();&lt;br /&gt;    diffDays = diffMillis / (1000 * 60 * 60 * 24);&lt;br /&gt;  &lt;br /&gt;    System.out.println("Format Used is yyyy/mm/dd");&lt;br /&gt;    System.out.println(diffdays.now("yyyy/MM/dd"));&lt;br /&gt;  &lt;br /&gt;    long i=0;&lt;br /&gt;    String today=(diffdays.now("EEEEEE"));&lt;br /&gt;    String day_computed="";&lt;br /&gt;    System.out.println("Today is:-   "+today);&lt;br /&gt;    if(today.compareTo("Sunday")==0)&lt;br /&gt;    {&lt;br /&gt;        i=1;&lt;br /&gt;    }&lt;br /&gt;    else if(today.compareTo("Monday")==0)&lt;br /&gt;    {&lt;br /&gt;        i=2;&lt;br /&gt;    }&lt;br /&gt;    if(today.compareTo("Tuesday")==0)&lt;br /&gt;    {&lt;br /&gt;        i=3;&lt;br /&gt;    }&lt;br /&gt;    if(today.compareTo("Wednesday")==0)&lt;br /&gt;    {&lt;br /&gt;        i=4;&lt;br /&gt;    }&lt;br /&gt;    if(today.compareTo("Thursday")==0)&lt;br /&gt;    {&lt;br /&gt;        i=5;&lt;br /&gt;    }&lt;br /&gt;    if(today.compareTo("Friday")==0)&lt;br /&gt;    {&lt;br /&gt;        i=6;&lt;br /&gt;    }&lt;br /&gt;    if(today.compareTo("Saturday")==0)&lt;br /&gt;    {&lt;br /&gt;        i=7;&lt;br /&gt;    }&lt;br /&gt;    i=(i+(diffDays-1)%7);&lt;br /&gt;    int j=(int)((i%7));&lt;br /&gt;  &lt;br /&gt;    switch(j)&lt;br /&gt;    {&lt;br /&gt;        case 0:day_computed="Sunday";&lt;br /&gt;               break;&lt;br /&gt;        case 1:day_computed="Monday";&lt;br /&gt;               break;&lt;br /&gt;        case 2:day_computed="Tueday";&lt;br /&gt;               break;&lt;br /&gt;        case 3:day_computed="Wednesday";&lt;br /&gt;               break;&lt;br /&gt;        case 4:day_computed="Thursday";&lt;br /&gt;               break;&lt;br /&gt;        case 5:day_computed="Friday";&lt;br /&gt;               break;&lt;br /&gt;        case 6:day_computed="Saturday";&lt;br /&gt;               break;&lt;br /&gt;    }&lt;br /&gt;   System.out.println("Day on 2009/05/10 is  "+day_computed);&lt;br /&gt;   System.out.println("Created by vaibhav pandey on 2009/05/06");&lt;br /&gt; &lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Output:-&lt;/span&gt;In the output you will get following screen showing following values:-&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_1CvsF-MJpr4/SgK1xkQdbAI/AAAAAAAAALs/t0NRrAjT7lQ/s1600-h/diffdays.JPG"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer; width: 400px; height: 200px;" src="http://4.bp.blogspot.com/_1CvsF-MJpr4/SgK1xkQdbAI/AAAAAAAAALs/t0NRrAjT7lQ/s400/diffdays.JPG" alt="" id="BLOGGER_PHOTO_ID_5333024771911019522" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;H:\&gt;java diffdays&lt;br /&gt;&gt;Format used is yyyy/mm/dd&lt;br /&gt;&gt;2009/05/06&lt;br /&gt;&gt;Today is:-  Thursday&lt;br /&gt;&gt;Day on 2009/05/10 is Sunday&lt;br /&gt;&gt;Created by Vaibhav Pandey on 2009/05/06&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Illustration:-&lt;/span&gt;As in&lt;a href="http://javatutorialsworld.blogspot.com/2009/05/datetime-in-your-specified-format.html"&gt; previous post&lt;/a&gt; where I told you how can you &lt;a href="http://javatutorialsworld.blogspot.com/2009/05/datetime-in-your-specified-format.html"&gt;get date your specified format&lt;/a&gt;,we will use it here also coz it is needed to get date in desired format to save complexity and time.The logic of this is implemented in now() method.Coming to main() method you can see we have taken two variables of date type and passed same type of date format to them.Then we have computed the difference in milliseconds between both dates.According to which we have calculated difference in days by dividing the value by (1000*60*60*24).&lt;br /&gt;&lt;br /&gt;Coming to the implementation logic ,here we computed current day and matched it to get the value of ' i ' in &lt;a href="http://javatutorialsworld.blogspot.com/2009/03/switch-construct-another-decision.html"&gt;switch() construct&lt;/a&gt;.After getting this value we applied the formula (i+(diffdays-1)%7) to get the resulting value of ' i ' which will take us the resultant day.This formula computes the value of ' i ' by adding remiander of (diffdays-1)%7.Actually only (diffdays%7) would have worked but since I have taken it so I have to work accordingly.Lets make it simple assume that today is monday the from first switch we will get i=2,and we wish to compute day after 4 days, thus diffdays would be equal to 4.Now applying the formula we get&lt;br /&gt;&lt;br /&gt;i=(2+(4-1)%7)&lt;br /&gt;&lt;br /&gt;=&gt;  i = (2+3)  //since 3%7=3&lt;br /&gt;=&gt;  i = 5.&lt;br /&gt;&lt;br /&gt;going to next &lt;a href="http://javatutorialsworld.blogspot.com/2009/03/switch-construct-another-decision.html"&gt;switch()&lt;/a&gt; and getting day according to value of j we get day=" Friday" which is desired result.We used ' j ' here to use in &lt;a href="http://javatutorialsworld.blogspot.com/2009/03/switch-construct-another-decision.html"&gt;switch()&lt;/a&gt; because ' i ' being long cannot be used in it.If you liked it please comment.I need your feedback desperately.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Links:-&lt;/span&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com"&gt;Home &lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/05/datetime-in-your-specified-format.html"&gt;Date Time in your Specified Format&lt;/a&gt;&lt;br /&gt;&lt;a href="http://bux.to/?r=va28"&gt;Earn Money Quick&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-9152377149362626103?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/9152377149362626103/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/05/compute-any-day-in-calendar-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/9152377149362626103'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/9152377149362626103'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/05/compute-any-day-in-calendar-using.html' title='Compute any day in calendar using Java.Util package'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_1CvsF-MJpr4/SgK1xkQdbAI/AAAAAAAAALs/t0NRrAjT7lQ/s72-c/diffdays.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-261968886029354228</id><published>2009-05-06T23:25:00.007+05:30</published><updated>2009-05-07T00:00:36.523+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java Swings'/><category scheme='http://www.blogger.com/atom/ns#' term='Java utilities'/><title type='text'>Loading Image on JFrame using JFileChooser</title><content type='html'>&lt;div style="text-align: justify;"&gt;&lt;span style="font-style: italic;font-size:130%;" &gt;&lt;span style="font-weight: bold;"&gt;JFileChooser &lt;/span&gt;&lt;/span&gt;is a very handy utility in java Swings to choose any particular file of an extension.&lt;br /&gt;Sometimes in our applications we need to load images onto our main container .In java we can use either JFrame or JPanel to load images.Statically we can provide the path of image into our program,but most of times it is not feasible for us to give image path statically.For specifying image path dynamically we use JFileChooser which returns path of a selected image.You can also select the desierd file extensions for whom you are looking.In following Example it is elaborated how to use JFileChooser and using it how we can load an image on a container.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Example (Source code ):-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;//imageloading.java&lt;br /&gt;&lt;br /&gt;//Program developed by Vaibhav Pandey&lt;br /&gt;&lt;br /&gt;import java.awt.image.BufferedImage;&lt;br /&gt;import java.io.File;&lt;br /&gt;import java.io.IOException;&lt;br /&gt;import java.sql.SQLException;&lt;br /&gt;import java.util.logging.Level;&lt;br /&gt;import java.util.logging.Logger;&lt;br /&gt;import javax.imageio.ImageIO;&lt;br /&gt;import javax.swing.ImageIcon;&lt;br /&gt;import javax.swing.JFileChooser;&lt;br /&gt;import javax.swing.JFrame;&lt;br /&gt;import javax.swing.JLabel;&lt;br /&gt;import javax.swing.JOptionPane;&lt;br /&gt;&lt;br /&gt;public class imageloading extends JFrame&lt;br /&gt;{&lt;br /&gt; BufferedImage mImage;&lt;br /&gt; String name,name1;&lt;br /&gt;public imageloading()&lt;br /&gt;   {&lt;br /&gt;       JFrame frm=new JFrame("image loading test");&lt;br /&gt;      String source=filechoose();&lt;br /&gt;          File inputFile = new File(source);&lt;br /&gt;         try {&lt;br /&gt;             mImage = ImageIO.read(inputFile);&lt;br /&gt;         } catch (IOException ex) {&lt;br /&gt;             //Logger.getLogger(index.class.getName()).log(Level.SEVERE, null, ex);&lt;br /&gt;         }&lt;br /&gt;       JLabel lb=new JLabel(new ImageIcon(mImage));&lt;br /&gt;       frm.getContentPane().add(lb);&lt;br /&gt;       frm.show();&lt;br /&gt;       frm.pack();&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;   String filechoose()&lt;br /&gt;   {&lt;br /&gt;       JFileChooser chooser = new JFileChooser();&lt;br /&gt;   chooser.setCurrentDirectory(new File("."));&lt;br /&gt;&lt;br /&gt;   chooser.setFileFilter(new javax.swing.filechooser.FileFilter() {&lt;br /&gt;     public boolean accept(File f) {&lt;br /&gt;       name = f.getName().toLowerCase();&lt;br /&gt;       return name.endsWith(".gif") || name.endsWith(".jpg")&lt;br /&gt;           || name.endsWith(".jpeg") || f.isDirectory();&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;     public String getDescription() {&lt;br /&gt;       return "Image files";&lt;br /&gt;     }&lt;br /&gt;   });&lt;br /&gt;&lt;br /&gt;   int r = chooser.showOpenDialog(this);&lt;br /&gt;&lt;br /&gt;   if (r == JFileChooser.APPROVE_OPTION) {&lt;br /&gt;      name1 = chooser.getSelectedFile().getAbsolutePath();&lt;br /&gt;      StringBuffer sb=new StringBuffer();&lt;br /&gt;      sb.append(name1);&lt;br /&gt;&lt;br /&gt;      int l=sb.length();&lt;br /&gt;      for(int i=0;i&lt;br /&gt;&lt;l;i++)&gt;        {&lt;/l;i++)&gt;&lt;br /&gt;&lt;l;i++)&gt;            if(sb.charAt(i)=='\\')&lt;/l;i++)&gt;&lt;br /&gt;&lt;l;i++)&gt;            {&lt;/l;i++)&gt;&lt;br /&gt;&lt;l;i++)&gt;              sb.insert(i, "\\");i++;&lt;/l;i++)&gt;&lt;br /&gt;&lt;l;i++)&gt;            }&lt;/l;i++)&gt;&lt;br /&gt;&lt;l;i++)&gt;        }&lt;/l;i++)&gt;&lt;br /&gt;&lt;l;i++)&gt;     }&lt;/l;i++)&gt;&lt;br /&gt;&lt;l;i++)&gt;     return name1;&lt;/l;i++)&gt;&lt;br /&gt;&lt;l;i++)&gt;     }&lt;/l;i++)&gt;&lt;br /&gt;&lt;l;i++)&gt;   public static void main(String a[])&lt;/l;i++)&gt;&lt;br /&gt;&lt;l;i++)&gt;   {&lt;/l;i++)&gt;&lt;br /&gt;&lt;l;i++)&gt;       new imageloading();&lt;/l;i++)&gt;&lt;br /&gt;&lt;l;i++)&gt;   }&lt;/l;i++)&gt;&lt;br /&gt;&lt;l;i++)&gt;}&lt;/l;i++)&gt;&lt;br /&gt;&lt;l;i++)&gt;&lt;/l;i++)&gt;&lt;br /&gt;&lt;l;i++) style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Output &lt;/l;i++)&gt;&lt;l;i++) style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Windows:-&lt;/l;i++)&gt;&lt;br /&gt;&lt;l;i++)&gt;&lt;/l;i++)&gt;&lt;br /&gt;&lt;l;i++)&gt;Following first widow shows the &lt;span style="font-style: italic;"&gt;JFileChooser&lt;/span&gt;() instance opened and asking to&lt;/l;i++)&gt;&lt;br /&gt;&lt;l;i++)&gt; select a file of given extension,and in second window you can see the loaded image.&lt;/l;i++)&gt;&lt;br /&gt;&lt;l;i++)&gt;&lt;/l;i++)&gt;&lt;br /&gt;&lt;l;i++)&gt;&lt;/l;i++)&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_1CvsF-MJpr4/SgHRChtKiiI/AAAAAAAAALc/oWdWiGiylPA/s1600-h/imageloading1.JPG"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 282px;" src="http://4.bp.blogspot.com/_1CvsF-MJpr4/SgHRChtKiiI/AAAAAAAAALc/oWdWiGiylPA/s400/imageloading1.JPG" alt="" id="BLOGGER_PHOTO_ID_5332773275121125922" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_1CvsF-MJpr4/SgHRauFntjI/AAAAAAAAALk/2jHKVIymYtg/s1600-h/imageloading2.JPG"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer; width: 132px; height: 212px;" src="http://1.bp.blogspot.com/_1CvsF-MJpr4/SgHRauFntjI/AAAAAAAAALk/2jHKVIymYtg/s320/imageloading2.JPG" alt="" id="BLOGGER_PHOTO_ID_5332773690761786930" border="0" /&gt;&lt;/a&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;&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;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Elaboration:-&lt;/span&gt;In the given code we have used the &lt;span style="font-style: italic;"&gt;ImageIO &lt;/span&gt;class to read the image file whose file is being specified and consequently is buffered.Later this buffered image is set on a Label as a &lt;span style="font-style: italic;"&gt;ImageIcon&lt;/span&gt; to display it on the frame.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;JFileChooser&lt;/span&gt;() is used to choose the files of desired extension here &lt;span style="font-style: italic;"&gt;FileFilter() &lt;/span&gt;method is used to filter the files on the basis of extensions .Here we have considered only .jpeg and .gif images.Since the '/' is treated as a escape sequence in Java  thus in when we are fetching path name in variable 'name1' using method 'J&lt;span style="font-style: italic;"&gt;FileChoose.getSelectedFile().getAbsolutePath()&lt;/span&gt;' ,in order to omit the escape sequence we embed '//' in the path when we have some path selected.&lt;br /&gt;&lt;br /&gt;We have used 'JFileChooser.APPROVE_OPTION' because to verify that we have selected a legitimate file or not.Any queries and comments are most welcome.In Java JFileChooser is a nice utility ,use it and tell me about the tutorial.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-261968886029354228?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/261968886029354228/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/05/loading-image-on-jframe-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/261968886029354228'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/261968886029354228'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/05/loading-image-on-jframe-using.html' title='Loading Image on JFrame using JFileChooser'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_1CvsF-MJpr4/SgHRChtKiiI/AAAAAAAAALc/oWdWiGiylPA/s72-c/imageloading1.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-5298627323332184808</id><published>2009-05-05T20:02:00.005+05:30</published><updated>2009-05-06T03:53:15.755+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='JDBC'/><title type='text'>Using SQL(insert command) in Java through JDBC</title><content type='html'>Using SQL DML statements in Java is very easy and is done through JDBC.Apart from writing this first I tell you what happened to me today.I have just given my first exam of this semester under some real harsh conditions.I was badly suffering and have vomiting and lose motions going around,But still somehow I managed to write away all the answers.&lt;br /&gt;So its enough lets start:-&lt;br /&gt;&lt;br /&gt;Peoples aware with SQL must know that there are 3 types of languages:-&lt;br /&gt;&lt;br /&gt;1.Data Definition Language(DDL)&lt;br /&gt;2.Data Manipulation Language(DML)&lt;br /&gt;3.Transaction control Language(TCL)&lt;br /&gt;&lt;br /&gt;Right here I will present ways by which you can use DML to update,insert and delete your database through front end application.I have presented here simple methods which can be used directly into your programmes.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Here we will see how data can be added to database through JDBC.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Adding Records to DataBase&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You can use &lt;span style="font-style: italic;"&gt;executeUpdate()&lt;/span&gt; method of Statement object to execute simple insert command.Through this insert Command the values are inserted in the database.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Syntax:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;//  stat.excecuteUpdate("insert table values (26,50)")  &lt;br /&gt;&lt;br /&gt;There is no return type of this method but it results in the affected rows in the database.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Method:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;public void addRecord()&lt;br /&gt;{&lt;br /&gt;       try&lt;br /&gt;           {&lt;br /&gt;                     stat.executeUpdate("insert employee values('vaibhav',21,javaapp)");&lt;br /&gt;           }&lt;br /&gt;      catch(Exception e){}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;This was the example of static data manipulation that is value are provides in advance,what if we will do if our application is a bit interactive.You have to provide values during execution.For this purpose we will use &lt;span style="font-style: italic;"&gt;PreparedStatement&lt;/span&gt; object and few methods of this Class named &lt;span style="font-style: italic;"&gt;executeUpdate()&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;setString()&lt;/span&gt;(or &lt;span style="font-style: italic;"&gt;setInt()&lt;/span&gt;).&lt;br /&gt;&lt;br /&gt;In that case the method will look like following:-&lt;br /&gt;&lt;br /&gt;public void addRecord()&lt;br /&gt;{&lt;br /&gt;        try&lt;br /&gt;            {&lt;br /&gt;                 stat=con.prepareStatement("insert employee values(?,?,?)");&lt;br /&gt;                 stat.setString(1,text1.getText());&lt;br /&gt;                 stat.setString(2,text2.getText());&lt;br /&gt;                 stat.setString(3,text3.getText());&lt;br /&gt;                 stat.executeUpdate();&lt;br /&gt;            }catch(Exception e){}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Here in above example we have used &lt;span style="font-style: italic;"&gt;placeholder("?")&lt;/span&gt; to provide values at runtime through the TextBoxes.We assume here that values are coming form the textbox on an ActionEvent.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;con&lt;/span&gt; is the object of Connection class and is used to create &lt;span style="font-style: italic;"&gt;preparedStatement&lt;/span&gt;.&lt;span style="font-style: italic;"&gt;setString(index,value) &lt;/span&gt;or &lt;span style="font-style: italic;"&gt;setInt(index,value)&lt;/span&gt; methods are used to set the value for the specified column indicated by index and value indicates the value to be stored in database.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;Links&lt;/span&gt;:-&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com"&gt;Home&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/03/jdbcintroduction.html"&gt;JDBC :Introduction&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/03/configuring-odbc-data-source-for-jdbc.html"&gt;Configuring data source&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/03/connecting-to-database.html"&gt;connecting to database&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/03/database-querying.html"&gt;querying database&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/03/jdbc-resultset-object.html"&gt;JDBC:ResultSet Object&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/03/detailed-jdbc-example-statement-object.html"&gt;JDBC:Statement Object&lt;/a&gt;&lt;br /&gt;&lt;a href="http://javatutorialsworld.blogspot.com/2009/03/using-prepared-statement.html"&gt;JDBC:PreparedStatement Object&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-5298627323332184808?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/5298627323332184808/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/05/using-sqlinsert-command-in-java-through.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/5298627323332184808'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/5298627323332184808'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/05/using-sqlinsert-command-in-java-through.html' title='Using SQL(insert command) in Java through JDBC'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-658862634149697151</id><published>2009-05-04T18:59:00.000+05:30</published><updated>2009-05-04T19:32:45.922+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Authors Update'/><title type='text'>Not usual java Post</title><content type='html'>Again this is not the usual java post,So if you believe that there is something about Java in it ,no its not its all about personal thoughts.From so many days I am creating posts on Java.In this post I want to share few my personal experiences,what I am feeling from a few days.The heat and pressure is building up as I am going to take my final semester Examinations.Most of you still don't know who I am.I am Vaibhav Pandey  author of this Java blog.I am also pursuing my Engineering degree and will get it this June/July.I have already submitted my final year project and I am not up to my expectation(its a huge blow for me and my confidance).&lt;br /&gt;&lt;br /&gt;In this semester I have 4 subjects Distributed Systems,Advanced Computer Architecture,Mobile Computing,Software Project Management.Please don't ask me write blog on them coz I have no interest in them.Distributed Systems Exam is on 5th May but I just can't remain away from this blog and stop writing,this has became a passion for me.I am a Indian Student and already got a job offer from a Multi National Company in my country where I have to join on 11th Jan 2010.There are plans queued up for me .I am planning to launch a complete educational site which will contain almost everything from tutorials to articles,reviews to polls and much much more.This will be done once Exam gets finished.I wish I could train people online on Sun Certification Once I will get Certified.I am currently preparing too and expected to write Exam somewhere around end of July.I am graduating in Computer Science and Engineering .It feels great when you let somebody learn a new technology or a new programming language tweaks and basics,because now a days what I have seen most of beginning programmers tend to start designing GUI'S and coding them despite making their programming fundamentals clears.This leads to a hugely inefficient programming I hope everybody must learn good and start from beginning rather than just run away with things.This will hamper your natural style of coding.&lt;br /&gt;&lt;br /&gt;I also want to do some thing for charity that is why I have launched a campaign to help UNICEF please make sure you are playing your part in making world literate,because what matters is knowledge.Click following banner to contribute and buy a gift.&lt;br /&gt;&lt;a onmouseover="window.status='http://www.unicef.org.uk/store/index.aspx?mediacode=9P95';return true;" onmouseout="window.status=' ';return true;" href="http://www.dpbolvw.net/click-3407517-10512698" target="_blank"&gt;&lt;br /&gt;&lt;img alt="" src="http://www.lduhtrp.net/image-3407517-10512698" width="300" border="0" height="250" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Peoples have talent but they don't want to brush it up.I have seen so many guys destroying their lives during this course of 4 Years so called Graduation.So be cautious always use your mind to do tasks.always try to seek knowledge from everyone and everything around you.Make most of your resources.The biggest source is the INTERNET.I am not a believer that the Social networking sites are bad and waste of time but sometimes they do . Use them but not that much so that they starting affecting your intellect.Building your network is also necessary but always think before doing something.I have so much to tell ,I am always filled up with Ideas and trying to get a way to realize them.More of my life will come soon but after I will write some good Java tutorials posts.Love you all.&lt;br /&gt;&lt;br /&gt;For more of me mail me&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="color: rgb(0, 0, 0); font-weight: bold;"&gt;Vaibhav Pandey&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 153);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 153);"&gt;javatute@gmail.com&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0); font-weight: bold;"&gt;&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 153);"&gt;&lt;br /&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/2124855005622377541-658862634149697151?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/658862634149697151/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/05/not-usual-java-post_04.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/658862634149697151'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/658862634149697151'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/05/not-usual-java-post_04.html' title='Not usual java Post'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-8268704019647844345</id><published>2009-05-03T00:23:00.000+05:30</published><updated>2009-05-03T00:25:27.136+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='SCJP'/><title type='text'>SCJP(310-065) Exam Objectives</title><content type='html'>&lt;span style="color: rgb(51, 51, 51);font-family:Arial;font-size:9;"  &gt;&lt;b&gt;             Section 1: Declarations, Initialization and Scoping&lt;/b&gt;&lt;/span&gt;             &lt;ul style="color: rgb(51, 51, 51);"&gt;&lt;li&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;Develop code that declares classes (including abstract and all forms of nested classes), interfaces, and enums, and includes the appropriate use of package and import statements (including static imports).&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;Develop code that declares an interface. Develop code that implements or extends one or more interfaces. Develop code that declares an abstract class. Develop code that extends an abstract class.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;Develop code that declares, initializes, and uses primitives, arrays, enums, and objects as static, instance, and local variables. Also, use legal identifiers for variable names.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;Develop code that declares both static and non-static methods, and - if appropriate - use method names that adhere to the JavaBeans naming standards. Also develop code that declares and uses a variable-length argument list.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;Given a code example, determine if a method is correctly overriding or overloading another method, and identify legal return values (including covariant returns), for the method.&lt;b&gt;                  &lt;/b&gt;&lt;/span&gt;&lt;span class="text"&gt;             &lt;p&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;&lt;b&gt;Section 2: Flow Control&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="text"&gt;&lt;p&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;Develop code that implements an if or switch statement; and identify legal argument types for these statements.&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="text"&gt;&lt;p&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;Develop code that implements all forms of loops and iterators, including the use of for, the enhanced for loop (for-each), do, while, labels, break, and continue; and explain the values taken by loop counter variables during and after loop execution.&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="text"&gt;&lt;p&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;Develop code that makes use of assertions, and distinguish appropriate from inappropriate uses of assertions.&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="text"&gt;&lt;p&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;Develop code that makes use of exceptions and exception handling clauses (try, catch, finally), and declares methods and overriding methods that throw exceptions.&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="text"&gt;&lt;p&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;Recognize the effect of an exception arising at a specified point in a code fragment. Note that the exception may be a runtime exception, a checked exception, or an error.&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="text"&gt;&lt;p&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;Recognize situations that will result in any of the following being thrown: ArrayIndexOutOfBoundsException,ClassCastException, IllegalArgumentException, IllegalStateException, NullPointerException, NumberFormatException, AssertionError, ExceptionInInitializerError, StackOverflowError or NoClassDefFoundError. Understand which of these are thrown by the virtual machine and recognize situations in which others should be thrown programatically.&lt;/span&gt;&lt;/p&gt;                          &lt;/span&gt;                                 &lt;br /&gt; &lt;span style=";font-family:Arial;font-size:9;"  &gt;&lt;b&gt;Section 3: API Contents&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="text"&gt;&lt;p&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;Develop code that uses the primitive wrapper classes (such as Boolean, Character, Double, Integer, etc.), and/or autoboxing &amp;amp; unboxing. Discuss the differences between the String, StringBuilder, and StringBuffer classes.&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="text"&gt;&lt;p&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;Given a scenario involving navigating file systems, reading from files, or writing to files, develop the correct solution using the following classes (sometimes in combination), from java.io: BufferedReader,BufferedWriter, File, FileReader, FileWriter and PrintWriter.&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="text"&gt;&lt;p&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;Develop code that serializes and/or de-serializes objects using the following APIs from java.io: DataInputStream, DataOutputStream, FileInputStream, FileOutputStream, ObjectInputStream, ObjectOutputStream and Serializable.&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="text"&gt;&lt;p&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;Use standard J2SE APIs in the java.text package to correctly format or parse dates, numbers, and currency values for a specific locale; and, given a scenario, determine the appropriate methods to use if you want to use the default locale or a specific locale. Describe the purpose and use of the java.util.Locale class.&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="text"&gt;&lt;p&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;Write code that uses standard J2SE APIs in the java.util and java.util.regex packages to format or parse strings or streams. For strings, write code that uses the Pattern and Matcher classes and the String.split method. Recognize and use regular expression patterns for matching (limited to: . (dot), * (star), + (plus), ?, \d, \s, \w, [], ()). The use of *, +, and ? will be limited to greedy quantifiers, and the parenthesis operator will only be used as a grouping mechanism, not for capturing content during matching. For streams, write code using the Formatter and Scanner classes and the PrintWriter.format/printf methods. Recognize and use formatting parameters (limited to: %b, %c, %d, %f, %s) in format strings.&lt;/span&gt;&lt;/p&gt;                          &lt;p&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;&lt;b&gt;Section 4: Concurrency&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="text"&gt;&lt;p&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;write code to define, instantiate, and start new threads using both java.lang.Thread and java.lang.Runnable.&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="text"&gt;&lt;p&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;Recognize the states in which a thread can exist, and identify ways in which a thread can transition from one state to another.&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="text"&gt;&lt;p&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;Given a scenario, write code that makes appropriate use of object locking to protect static or instance variables from concurrent access problems.&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="text"&gt;&lt;p&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;Given a scenario, write code that makes appropriate use of wait, notify, or notifyAll.&lt;/span&gt;&lt;/p&gt;                          &lt;p&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;&lt;b&gt;Section 5: OO Concepts&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="text"&gt;&lt;p&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;Develop code that implements tight encapsulation, loose coupling, and high cohesion in classes, and describe the benefits.&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="text"&gt;&lt;p&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;Given a scenario, develop code that demonstrates the use of polymorphism. Further, determine when casting will be necessary and recognize compiler vs. runtime errors related to object reference casting.&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="text"&gt;&lt;p&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;Explain the effect of modifiers on inheritance with respect to constructors, instance or static variables, and instance or static methods.&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="text"&gt;&lt;p&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;Given a scenario, develop code that declares and/or invokes overridden or overloaded methods and code that declares and/or invokes superclass, overridden, or overloaded constructors.&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="text"&gt;&lt;p&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;Develop code that implements "is-a" and/or "has-a" relationships.&lt;/span&gt;&lt;/p&gt;                          &lt;p&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;&lt;br /&gt;           &lt;b&gt;Section 6: Collections / Generics&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="text"&gt;&lt;p&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;Given a design scenario, determine which collection classes and/or interfaces should be used to properly implement that design, including the use of the Comparable interface.&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="text"&gt;&lt;p&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;Distinguish between correct and incorrect overrides of corresponding hashCode and equals methods, and explain the difference between == and the equals method.&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="text"&gt;&lt;p&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;Write code that uses the generic versions of the Collections API, in particular, the Set, List, and Map interfaces and implementation classes. Recognize the limitations of the non-generic Collections API and how to refactor code to use the generic versions.&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="text"&gt;&lt;p&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;Develop code that makes proper use of type parameters in class/interface declarations, instance variables, method arguments, and return types; and write generic methods or methods that make use of wildcard types and understand the similarities and differences between these two approaches.&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="text"&gt;&lt;p&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;Use capabilities in the java.util package to write code to manipulate a list by sorting, performing a binary search, or converting the list to an array. Use capabilities in the java.util package to write code to manipulate an array by sorting, performing a binary search, or converting the array to a list. Use the java.util.Comparator and java.lang.Comparable interfaces to affect the sorting of lists and arrays. Furthermore, recognize the effect of the "natural ordering" of primitive wrapper classes and java.lang.String on sorting.&lt;/span&gt;&lt;/p&gt;                          &lt;p&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;&lt;b&gt;Section 7: Fundamentals&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="text"&gt;&lt;p&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;Given a code example and a scenario, write code that uses the appropriate access modifiers, package declarations, and import statements to interact with (through access or inheritance) the code in the example.&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="text"&gt;&lt;p&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;Given an example of a class and a command-line, determine the expected runtime behavior.&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="text"&gt;&lt;p&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;Determine the effect upon object references and primitive values when they are passed into methods that perform assignments or other modifying operations on the parameters.&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="text"&gt;&lt;p&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;Given a code example, recognize the point at which an object becomes eligible for garbage collection, and determine what is and is not guaranteed by the garbage collection system. Recognize the behaviors of System.gc and finalization.&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="text"&gt;&lt;p&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;Given the fully-qualified name of a class that is deployed inside and/or outside a JAR file, construct the appropriate directory structure for that class. Given a code example and a classpath, determine whether the classpath will allow the code to compile successfully.&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="text"&gt;&lt;p&gt;&lt;span style=";font-family:Arial;font-size:9;"  &gt;Write code that correctly applies the appropriate operators including assignment operators (limited to: =, +=, -=), arithmetic operators (limited to: +, -, *, /, %, ++, --), relational operators (limited to: &lt;, &lt;=, &gt;, &gt;=, ==, !=), the instanceof operator, logical operators (limited to: &amp;amp;, |, ^, !, &amp;amp;&amp;amp;, ||), and the conditional operator ( ? : ), to produce a desired result. Write code that determines the equality of two objects or two primitives.&lt;/span&gt;&lt;/p&gt;                          &lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-8268704019647844345?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/8268704019647844345/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/05/scjp310-065-exam-objectives.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/8268704019647844345'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/8268704019647844345'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/05/scjp310-065-exam-objectives.html' title='SCJP(310-065) Exam Objectives'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-8842820274590779682</id><published>2009-05-01T13:29:00.003+05:30</published><updated>2009-05-01T13:47:16.388+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java utilities'/><title type='text'>Date,Time in your Specified Format</title><content type='html'>Many times in your application you need to fetch system date,time in some particular format.In following Source code I have illustrated the way you can get date,time .I have used SimpleDateFormat class with an argument which specifies the format and Calendar class for getting instance of time combined with date.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Example:-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;//dateformat.java&lt;br /&gt;&lt;br /&gt;import java.util.Calendar;&lt;br /&gt;import java.io.Serializable;&lt;br /&gt;import java.util.Date;&lt;br /&gt;import java.text.SimpleDateFormat;&lt;br /&gt;&lt;br /&gt;public class dateformat&lt;br /&gt;{&lt;br /&gt;   public dateformat()&lt;br /&gt;   {&lt;br /&gt;    System.out.println(now("EEEEEE"));&lt;br /&gt;    System.out.println(now("yyyy/MM/dd"));&lt;br /&gt;    System.out.println(now("yyyy"));&lt;br /&gt;    System.out.println(now("MMMMM"));&lt;br /&gt;    System.out.println(now("MMMMM dd yyyy hh:mm aaa "));&lt;br /&gt;    System.out.println(now("dd MMMMM yyyy  "));&lt;br /&gt;    System.out.println(now("dd yyyy MMMMM  "));&lt;br /&gt;    System.out.println(now("hh:mm aaa "));&lt;br /&gt;   }&lt;br /&gt;   public String now(String dateFormat) {&lt;br /&gt;   Calendar cal = Calendar.getInstance();&lt;br /&gt;   SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);&lt;br /&gt;   return sdf.format(cal.getTime());&lt;br /&gt;  } &lt;br /&gt;  public static void main(String a[])&lt;br /&gt;  {&lt;br /&gt;      new dateformat();&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;OutPut:-&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_1CvsF-MJpr4/SfqvdD1nlOI/AAAAAAAAAK4/VVBRNfO0TQU/s1600-h/dateformat.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 201px;" src="http://4.bp.blogspot.com/_1CvsF-MJpr4/SfqvdD1nlOI/AAAAAAAAAK4/VVBRNfO0TQU/s400/dateformat.JPG" alt="" id="BLOGGER_PHOTO_ID_5330766022727668962" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-8842820274590779682?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/8842820274590779682/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/05/datetime-in-your-specified-format.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/8842820274590779682'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/8842820274590779682'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/05/datetime-in-your-specified-format.html' title='Date,Time in your Specified Format'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_1CvsF-MJpr4/SfqvdD1nlOI/AAAAAAAAAK4/VVBRNfO0TQU/s72-c/dateformat.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-4929706144327460728</id><published>2009-05-01T09:38:00.003+05:30</published><updated>2009-05-01T09:58:12.308+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='SCJP'/><title type='text'>Tips to Crack SCJP</title><content type='html'>Following are Tips to Crack SCJP :-&lt;br /&gt;&lt;br /&gt;1.Concentrate only on one book although you may refer various quiz engines for practice&lt;br /&gt;Recommended:&lt;a style="font-weight: bold;" href="http://www.amazon.com/gp/product/0071591060?ie=UTF8&amp;amp;tag=javwor08-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=0071591060"&gt; Katherine Sierra and Bert Bates&lt;/a&gt;&lt;img src="http://www.assoc-amazon.com/e/ir?t=javwor08-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=0071591060" alt="" style="border: medium none  ! important; margin: 0px ! important; font-weight: bold;" width="1" border="0" height="1" /&gt; and &lt;a style="font-weight: bold;" href="http://www.amazon.com/gp/product/0321556054?ie=UTF8&amp;amp;tag=javwor08-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=0321556054"&gt;Khalid E Mughal.&lt;/a&gt;&lt;img src="http://www.assoc-amazon.com/e/ir?t=javwor08-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=0321556054" alt="" style="border: medium none  ! important; margin: 0px ! important; font-weight: bold;" width="1" border="0" height="1" /&gt;&lt;br /&gt;&lt;br /&gt;2.Atleast 2 months of hard work.&lt;br /&gt;&lt;br /&gt;3.Always try to experiment with your own.That is try run any program with complex and simple     modifications.&lt;br /&gt;&lt;br /&gt;4.Be very clear and specific about programming and syntax rule for that you may visit &lt;a style="font-weight: bold;" href="http://www.javaranch.com/"&gt;Javaranch.com&lt;/a&gt;&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;for playing rule roundup game.&lt;br /&gt;&lt;br /&gt;5.Give as many mock exams as you can as they will increase your chances of cracking the exam.&lt;br /&gt;&lt;br /&gt;6.If in the Exam you are not sure of any option try omitting the options.&lt;br /&gt;&lt;br /&gt;7.Go on to solve questions that have less to read and easy to answer as by the end of SCJP exam you will be getting exhausted and loosing patience.&lt;br /&gt;&lt;br /&gt;8. First guess which concept is being tested and then bring out all the facts about that concept from the back of your mind.&lt;br /&gt;&lt;br /&gt;&lt;iframe src="http://rcm.amazon.com/e/cm?t=javwor08-20&amp;amp;o=1&amp;amp;p=20&amp;amp;l=ur1&amp;amp;category=books&amp;amp;banner=0YM0V4GHQ57EK3WYRZR2&amp;amp;f=ifr" border="0" marginwidth="0" style="border: medium none ;" scrolling="no" width="120" frameborder="0" height="90"&gt;&lt;/iframe&gt;&lt;br /&gt;&lt;br /&gt;Apart from these if you have any problems then you can send it to &lt;span style="color: rgb(255, 0, 0); font-weight: bold;"&gt;javatute@gmail.com&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2124855005622377541-4929706144327460728?l=www.javasync.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.javasync.com/feeds/4929706144327460728/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.javasync.com/2009/05/tips-to-crack-scjp.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/4929706144327460728'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2124855005622377541/posts/default/4929706144327460728'/><link rel='alternate' type='text/html' href='http://www.javasync.com/2009/05/tips-to-crack-scjp.html' title='Tips to Crack SCJP'/><author><name>va</name><uri>http://www.blogger.com/profile/15299039029147936014</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_1CvsF-MJpr4/SunJcXJ5gwI/AAAAAAAAARI/CsiDDSWSGA8/S220/snap.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2124855005622377541.post-446227966415806394</id><published>2009-04-30T14:34:00.004+05:30</published><updated>2009-04-30T14:49:13.991+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java Swings'/><title type='text'>Using JTextField and JTextArea</title><content type='html'>TextFields are used to take input from user also it can be used to display results.&lt;br /&gt;The various constructors and methods are defined in the previous JTextField tutorials.&lt;br /&gt;&lt;br /&gt;Values from a TextField is extracted using String  &lt;span style="font-style: italic; font-weight: bold;"&gt;getText()&lt;/span&gt; and set using &lt;span style="font-weight: bold;"&gt;void &lt;/span&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;setText(String txt).&lt;/span&gt;&lt;br /&gt;The user can select a portion from the JTextField and JTextArea using &lt;span style="font-weight: bold;"&gt;String &lt;/span&gt;&lt;span style="font-weight: bold;"&gt;getSelectedText() &lt;/span&gt;and &lt;span style="font-style: italic; font-weight: bold;"&gt;void select(int start_index,int end_index)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;String getSelectedText()&lt;/span&gt;&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;retrurns the String portion selected by the user from the textfield.&lt;br /&gt;You can also enable or disable the TextField that is if you want TextField to be editable the use the methos void &lt;span style="font-style: italic; font-weight: bold;"&gt;setEditable(boolean value)&lt;/span&gt; to true else set false.If you want to get value of editable TextField use &lt;span style="font-style: italic; font-weight: bold;"&gt;boolean isEditable()&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Sometimes you wish to set a password field in which the entered character must not be shown.It has to be replaced by some other sign or value.To set a password field you must use &lt;span style="font-weight: bold;"&gt;void &lt;/span&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;setEchoChar(Char ch)&lt;/span&gt;&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;character you specified in 'ch' will be shown when some charater is typed.&lt;br /&gt;If you want to get the Charcter specified the use &lt;span style="font-weight: bold;"&gt;char &lt;/span&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;getEchoChar()&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt; &lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Example :-&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;getting selected value from a text field and displaying it to other and use of Password field.&lt;br /&gt;&lt;br /&gt;// textfield.java&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_1CvsF-MJpr4/SflslLsG5TI/AAAAAAAAAKw/ZgtgJHrLVzQ/s1600-h/textfield.JPG"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer; width: 320px; height: 62px;" src="http://2.bp.blogspot.com/_1CvsF-MJpr4/SflslLsG5TI/AAAAAAAAAKw/ZgtgJHrLVzQ/s320/textfield.JPG" alt="" id="BLOGGER_PHOTO_ID_5330411020018443570" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;import javax.swing.*;&lt;br /&gt;import java.awt.*;&lt;br /&gt;import java.awt.event.*;&lt;br /&gt;&lt;br /&gt;public class textfield extends JFrame implements ActionListener&lt;br /&gt;{&lt;br /&gt;  JFrame frame;&lt;br /&gt;   JPanel panel;&lt;br /&gt;   JTextField txtname,txtdisplay;&lt;br /&gt;   TextField txtpass;&lt;br /&gt;   JButton button;&lt;br /&gt;  public textfield()&lt;br /&gt;  {&lt;br /&gt;  frame=new JFrame("Text Field usage demo");&lt;br /&gt;  panel=new JPanel();&lt;br /&gt;  txtname=new JTextField(25);&lt;br /&gt;  txtpass=new TextField(25);&lt;br /&gt;  txtpass.setEchoChar('#');&lt;br /&gt;  txtdisplay =new JTextField(25);&lt;br /&gt;  JButton button=new JButton("Display selected");&lt;br /&gt;  button.addActionListener(this);&lt;br /&gt;  panel.setLayout(new GridLayout(3,2));&lt;br /&gt;  panel.add(new JLabel("Name :"));&lt;br /&gt;  panel.add(txtname);&lt;br /&gt;  panel.add(new JLabel("Password :"));&lt;br /&gt;  panel.add(txtpass);&lt;br /&gt;  panel.add(txtdisplay);&lt;br /&gt;  panel.add(button);&lt;br /&gt;  frame.getContentPane().add(panel);&lt;br /&gt;  frame.show();&lt;br /&gt;  frame.pack();&lt;br /&gt;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  public void actionPerformed(ActionEvent ae)&lt;br /&gt;  {&lt;br /&gt;   &lt;br /&gt;      txtdisplay.setText("Name :"+txtname.getSelectedText()+" Pass :"+txtpass.getText());&lt;br /&gt;   &lt;br /&gt;  }&lt;br /&gt;  public static void main(String a[])&lt;br /&gt;  {&lt;br /&gt;      new textfield();&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);font-size:130%;" &gt;&lt;span style="font-weight: bold;"&gt;Example:-&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;getting selected value from a text area and displaying selected in textfield.&lt;br /&gt;&lt;br /&gt;// textarea.java&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_1CvsF-MJpr4/SflslIekWVI/AAAAAAAAAKo/ntr13RsE1
