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

<channel>
	<title>JavaBeat &#187; Interview Questions</title>
	<atom:link href="http://www.javabeat.net/category/interview-questions/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.javabeat.net</link>
	<description>Java Technology News</description>
	<lastBuildDate>Tue, 21 May 2013 13:43:42 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Networking Interview Questions</title>
		<link>http://www.javabeat.net/2011/06/networking-interview-questions/</link>
		<comments>http://www.javabeat.net/2011/06/networking-interview-questions/#comments</comments>
		<pubDate>Mon, 06 Jun 2011 08:14:10 +0000</pubDate>
		<dc:creator>krishnas</dc:creator>
				<category><![CDATA[Interview Questions]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/examples/?p=295</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>Networking Interview Questions (Hands on tips for cracking the interview) Description Technical interviews are largely focused on assessing your knowledge and skills on a specific technology or subject matter. Preparing for a technical job interview could be an uphill task, where you would need to scan voluminous books and material from numerous sources spread across [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><a id="dd_start"></a><h1>Networking Interview Questions</h1>
<h1>(Hands on tips for cracking the interview)</h1>
<h2>Description</h2>
<p>Technical interviews are largely focused on assessing your knowledge and skills on<br />
a specific technology or subject matter. Preparing for a technical job interview could be an uphill<br />
task, where you would need to scan voluminous books and material from numerous sources spread<br />
across different media. Wouldn’t your efforts be reduced greatly if you get a book specifically<br />
devoted towards the technical interviews on the respective technology/subject matter?</p>
<p>A new book by Dreamtech Press, <b>Networking Interview Questions ( <i>May 02, 2011, INR.<br />
199/-, ISBN: 978-81-7722-795-6 </i>)</b> bringing to you an economical and time-saving ensemble<br />
of probable questions being asked in the technical interviews, and their adequate answers and<br />
explanations.</p>
<p>This book will help the reader in preparing for an interview and reviewing all the important topics<br />
that are needed to be known by beginners as well as professionals in Networking. This book covers<br />
the valuable information on the concepts of Network Cards, Cabling, Topologies and Protocol Suites,<br />
Network Services and Communication Devices, Networking with Microsoft Windows, Managing<br />
Client and Server Computers, Managing NTFS Permission, Monitoring Server Health and Security,<br />
Managing Active Directory and Services, TCP/IP Administration, Dynamic Host Configuration<br />
Protocol and Managing IIS, Cisco IOS Software Fundamentals, IOS Reference Model, LAN’s Bridges<br />
and Switches and TCP/IP and IP Routing, Routing and Routing Protocol, WAN Protocol and Security.</p>
<h2>About the Authors</h2>
<p><b>Pradeep Mathur</b> is founder of Divyamm Solutions, a comprehensive technical writing solutions<br />
provider to suite various business needs. He has ventured into technical writing after years of<br />
experience in technical support for world&#8217;s leading software and networking companies like Microsoft<br />
Inc. and Cisco Systems Inc. Besides being a management graduate, he also holds strong technical<br />
knowledge with an ability to simplify complex technical information into clear, compelling, and easyto-<br />
understand language. He holds various technical certifications: CCNA, MCSE, MCSA, MCDBA, IBM<br />
E-Commerce Professional.</p>
<p>The proficient team at <b>Kogent Learning Solutions Inc.</b> and <b>Dreamtech Press</b> has seized the<br />
market of computer books bringing excellent content in software development to the fore. The<br />
team is committed to excellence—excellence in quality of content, excellence in the dedication of its<br />
authors and editors, excellence in the attention to detail, and excellence in understanding the needs<br />
of its readers.</p>
<h2>About Dreamtech Press</h2>
<p>Dreamtech Press is one of the India’s leading IT, Management and Engineering books publisher,<br />
devoted to students and professionals, novices and experts, instructors and teachers. We have<br />
ardently analyzed and comprehended the needs of our readers. Moreover our meticulous care in<br />
creating and publishing our books; focusing on generic and specific educational requirements and<br />
demands of our readers makes us the best choice among readers. Efficacious process management<br />
and enduring quality processes have been hallmark towards our success.</p>
<p>Relationship Investing is the core of our business that has been the hallmark of our success. No<br />
wonder, respected global corporation – Apress/Springer, Manning Publication (USA), Source Books<br />
Inc., Career Press and W-Business have trusted our capability to deliver value in India. We have<br />
an exclusive sales and distribution with Wiley India Pvt. Ltd. wherein all the books printed by<br />
Dreamtech Press and distributed by Wiley India Pvt. Ltd.</p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<h2>Media Contact</h2>
<p><i>
<p>Akash Kumar</p>
<p>Assistant Manager – Marketing &amp; Public Relations</p>
<p>Cell: +91 987 383 8807</p>
<p>Email: akash.kumar@dreamtechpress.com</p>
<p></i></p>
<h2>Books for Interview Questions</h2>
<ul>
<li><a href="http://astore.amazon.com/javabeat-20/detail/1411668243">Java/J2EE Job Interview Companion </a></li>
<li><a href="http://astore.amazon.com/javabeat-20/detail/047012167X">Programming Interviews Exposed</a></li>
</ul>
<div class='dd_outer'><div class='dd_inner'><div id='dd_ajax_float'><div class='dd_button_v'><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http%3A%2F%2Fwww.javabeat.net%2Fcategory%2Finterview-questions%2Ffeed%2F" send="false" show_faces="false"  layout="box_count" width="50"  ></fb:like></div><div style='clear:left'></div><div class='dd_button_v'><script type='text/javascript' src='https://apis.google.com/js/plusone.js'></script><g:plusone size='tall' href='http://www.javabeat.net/category/interview-questions/feed/'></g:plusone></div><div style='clear:left'></div><div class='dd_button_v'><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.javabeat.net/category/interview-questions/feed/" data-count="vertical" data-text="Interview Questions" data-via="javabeat" ></a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div style='clear:left'></div><div class='dd_button_extra_v'><script type="text/javascript">jQuery(document).load(function(){ stLight.options({publisher:'bab47279-62c9-46af-addc-79fd1fe8fee0'}); });</script><div class="st_email_custom"><span id='dd_email_text'>email</span></div></div><div style='clear:left'></div><div class='dd_button_extra_v'><div id='dd_print_button'><span id='dd_print_text'><a href='javascript:window:print()'>print</a></span></div></div><div style='clear:left'></div></div></div></div><script type="text/javascript">var dd_offset_from_content = 44; var dd_top_offset_from_content = 0;</script><script type="text/javascript" src="http://www.javabeat.net/wp-content/plugins/digg-digg//js/diggdigg-floating-bar.js?ver=5.3.0"></script><div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2011/06/networking-interview-questions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Weblogic Interview Questions</title>
		<link>http://www.javabeat.net/2010/08/weblogic-interview-questions/</link>
		<comments>http://www.javabeat.net/2010/08/weblogic-interview-questions/#comments</comments>
		<pubDate>Sun, 08 Aug 2010 00:44:21 +0000</pubDate>
		<dc:creator>krishnas</dc:creator>
				<category><![CDATA[Interview Questions]]></category>
		<category><![CDATA[WebLogic]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=462</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>Weblogic Interview Questions &#8211; 1 1)How do I provide user credentials for starting a server? When you create a domain, the Configuration Wizard prompts you to provide the username and password for an initial administrative user. If you create the domain in development mode, the wizard saves the username and encrypted password in a boot [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><h2>Weblogic Interview Questions &#8211; 1</h2>
<h3>1)How do I provide user credentials for starting a server?</h3>
<p>When you create a domain, the Configuration Wizard prompts you to provide the<br />
username and password for an initial administrative user. If you create the<br />
domain in development mode, the wizard saves the username and encrypted password<br />
in a boot identity file. A WebLogic Server instance can refer to a boot identity<br />
file during its startup process. If a server instance does not find such a file,<br />
it prompts you to enter credentials.</p>
<p>If you create a domain in production mode, or if you want to change user<br />
credentials in an existing boot identity file, you can create a new boot<br />
identity file.</p>
<h3>2)Can I start a Managed Server if the Administration Server is unavailable?</h3>
<p>By default, if a Managed Server is unable to connect to the specified<br />
Administration Server during startup, it can retrieve its configuration by<br />
reading a configuration file and other files directly. You cannot change the<br />
server&#8217;s configuration until the Administration Server is available. A Managed<br />
Server that starts in this way is running in Managed Server Independence mode.</p>
<h3>3)What is the function of T3 in WebLogic Server?</h3>
<p>T3 provides a framework for WebLogic Server messages that support for<br />
enhancements. These enhancements include abbreviations and features, such as<br />
object replacement, that work in the context of WebLogic Server clusters and<br />
HTTP and other product tunneling. T3 predates Java Object Serialization and RMI,<br />
while closely tracking and leveraging these specifications. T3 is a superset of<br />
Java Object. Serialization or RMI; anything you can do in Java Object<br />
Serialization and RMI can be done over T3. T3 is mandated between WebLogic<br />
Servers and between programmatic clients and a WebLogic Server cluster. HTTP and<br />
IIOP are optional protocols that can be used to communicate between other<br />
processes and WebLogic Server. It depends on what you want to do. For example,<br />
when you want to communicate between a browser and WebLogic Server-use HTTP, or<br />
an ORB and WebLogic Server-IIOP.</p>
<h3>4)How do you set the classpath?</h3>
<p>WebLogic Server installs the following script that you can use to set the<br />
classpath that a server requires:</p>
<p>WL_HOME\server\bin\setWLSEnv.cmd (on Windows)</p>
<p>WL_HOME/server/bin/setWLSEnv.sh (on UNIX)</p>
<h3>5)How do stubs work in a WebLogic Server cluster?</h3>
<p>Clients that connect to a WebLogic Server cluster and look up a clustered object<br />
obtain a replica-aware stub for the object. This stub contains the list of<br />
available server instances that host implementations of the object. The stub<br />
also contains the load balancing logic for distributing the load among its host<br />
servers.</p>
<p>What happens when a failure occurs and the stub cannot connect to a WebLogic<br />
Server instance?</p>
<p>When the failure occurs, the stub removes the failed server instance from its<br />
list. If there are no servers left in its list, the stubb uses DNS again to find<br />
a running server and obtain a current list of running instances. Also, the stub<br />
periodically refreshes its list of available server instances in the cluster;<br />
this allows the stub to take advantage of new servers as they are added to the<br />
cluster.</p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<h3>6)How does a server know when another server is unavailable?</h3>
<p>WebLogic Server uses two mechanisms to determine if a given server instance is<br />
unavailable.</p>
<p>Each WebLogic Server instance in a cluster uses multicast to broadcast regular<br />
&#8220;heartbeat&#8221; messages that advertise its availability. By monitoring heartbeat<br />
messages, server instances in a cluster determine when a server instance has<br />
failed. The other server instances will drop a server instance from the cluster,<br />
if they do not receive three consecutive heartbeats from that server instance</p>
<p>WebLogic Server also monitors socket errors to determine the availability of a<br />
server instance. For example, if server instance A has an open socket to server<br />
instance B, and the socket unexpectedly closes, server A assumes that server B<br />
is offline.</p>
<h3>7)How are notifications made when a server is added to a cluster?</h3>
<p>The WebLogic Server cluster broadcasts the availability of a new server instance<br />
each time a new instance joins the cluster. Cluster-aware stubs also<br />
periodically update their list of available server instances.</p>
<h3>8)How do clients handle DNS requests to failed servers?</h3>
<p>If a server fails and DNS continues to send requests to the unavailable machine,<br />
this can waste bandwidth. For a Java client application, this problem occurs<br />
only during startup. WebLogic Server caches the DNS entries and removes the<br />
unavailable ones, to prevent the client from accessing a failed server twice.</p>
<p>Failed servers can be more of a problem for browser-based clients, because they<br />
always use DNS. To avoid unnecessary DNS requests with browser-based clients,<br />
use a third-party load-balancer such as Resonate, BigIP, Alteon, and<br />
LocalDirector. These products mask multiple DNS addresses as a single address.<br />
They also provide more sophisticated load-balancing options than round-robin,<br />
and they keep track of failed servers to avoid routing unnecessary requests.</p>
<h3>9)How many WebLogic Servers can I have on a multi-cpu machine?</h3>
<p>There are many possible configurations and each has its own advantages and<br />
disadvantages. BEA WebLogic Server has no built-in limit for the number of<br />
server instances that can reside in a cluster. Large, multi-processor servers<br />
such as Sun Microsystems, Inc. Sun Enterprise 10000, therefore, can host very<br />
large clusters or multiple clusters.</p>
<p>In most cases, WebLogic Server clusters scale best when deployed with one<br />
WebLogic Server instance for every two CPUs. However, as with all capacity<br />
planning, you should test the actual deployment with your target web<br />
applications to determine the optimal number and distribution of server<br />
instances.</p>
<h3>10)How can I set deployment order for applications?</h3>
<p>WebLogic Server allows you to select the load order for applications. WebLogic<br />
Server deploys server-level resources (first JDBC and then JMS) before deploying<br />
applications. Applications are deployed in this order: connectors, then EJBs,<br />
then Web Applications. If the application is an EAR, the individual components<br />
are loaded in the order in which they are declared in the application.xml<br />
deployment descriptor.</p>
<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2010/08/weblogic-interview-questions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JBoss Seam Interview Questions</title>
		<link>http://www.javabeat.net/2010/08/jboss-seam-interview-questions/</link>
		<comments>http://www.javabeat.net/2010/08/jboss-seam-interview-questions/#comments</comments>
		<pubDate>Thu, 05 Aug 2010 00:49:13 +0000</pubDate>
		<dc:creator>krishnas</dc:creator>
				<category><![CDATA[Interview Questions]]></category>
		<category><![CDATA[JBoss Seam]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=474</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>Q: What version of JBoss AS do I need to run Seam? A: For Seam 1.3: Seam was developed against JBoss 4.2. Seam can still be run against JBoss 4.0. The seam documentation contains instructions for configuring JBoss 4.0. A: For Seam 1.2: Since Seam requires the latest edition of EJB3, you need to install [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><h3><strong><a name="jbossas"></a>Q: What version of JBoss AS do I need to run Seam?</strong></h3>
<p><strong><a name="jbossas"></a></strong></p>
<p><a name="jbossas"></a>A: For Seam 1.3: Seam was developed against <a href="http://sourceforge.net/project/showfiles.php?group_id=22866&amp;package_id=16942&amp;release_id=507793">JBoss 4.2</a>. Seam can still be run against JBoss 4.0. The <a href="http://docs.jboss.com/seam/1.3.0.ALPHA/reference/en/html/gettingstarted.html#d0e2434">seam documentation</a> contains instructions for configuring JBoss 4.0.</p>
<p>A: For Seam 1.2: Since Seam requires the latest edition of EJB3, you need to install JBoss AS from the latest<br />
<a href="http://sourceforge.net/project/showfiles.php?group_id=22866&amp;package_id=193295">JEMS installer</a>. Make sure that you select the &#8220;ejb3&#8243; or &#8220;ejb3+clustering&#8221; profile to include EJB3 support. Also, the <code>jboss-seam.jar</code> library file from the Seam distribution must be included in each Seam application you deploy. Refer to examples in <a href="http://labs.jboss.com/portal/jbossseam/download/index.html">Seam distribution</a> (inside the <code>examples</code> directory) to see how to build and package Seam applications.</p>
<h3><strong><a name="tomcat"></a>Q: Can I run Seam outside of JBoss AS?</strong></h3>
<p><strong><a name="tomcat"></a></strong></p>
<p><a name="tomcat"></a>A: Yes, you can run Seam applications in plain Tomcat 5.5+ or in the Sun GlassFish application server. To run Seam application in Tomcat, you need a number of additional library files and a few configuration files to bootstrap the JBoss EJB3 inside Tomcat. Please refer to the <code>deploy.tomcat</code> ANT build target for the Seam <code>booking</code> example (in the <code>examples/booking</code> directory of the<br />
<a href="http://labs.jboss.com/portal/jbossseam/download/index.html">Seam distribution</a>) for more on how to build a Tomcat WAR for Seam applications. Refer to this <a href="http://weblogs.java.net/blog/bleonard/archive/2006/06/running_jboss_s.html">blog post</a> on how to run Seam in Sun&#8217;s Glassfish application server.</p>
<h3><strong><a name="j2ee"></a>Q: Can I run Seam in a J2EE environment?</strong></h3>
<p> <strong><a name="j2ee"></a></strong></p>
<p><a name="j2ee"></a>A: Yes, as of Seam 1.1, you can use Seam in any J2EE application server, with one caveat: you will not be able to use EJB 3.0 session beans. However, you can use either Hibernate or JPA for persistence,<br />
and you can use Seam JavaBean components instead of session beans. <a name="j2ee"></a><br />
<h3><a name="j2ee"></a><strong><a name="jdk"></a>Q: Can I run Seam with JDK 1.4 and earlier?</strong></h3>
<p><strong><a name="jdk"></a></strong></p>
<p><a name="jdk"></a>A: No, Seam only works on JDK 5.0 and above. It uses annotations and other JDK 5.0 features.</p>
<p><a name="jdk"></a><br />
<h3><a name="jdk"></a><strong><a name="docs"></a>Q: Where can I find Seam examples and<br />
documentation?</strong></h3>
<p> <strong><a name="docs"></a></strong></p>
<p><a name="docs"></a>A: The source code and build script of all Seam example applications are included in the <code>examples</code> directory of the <a href="http://labs.jboss.com/portal/jbossseam/download/index.html">Seam<br />
distribution</a>. Seam documentation is <a href="http://labs.jboss.com/portal/jbossseam/docs">available here</a>.</p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<h3><strong><a name="forum"></a>Q: Where can I ask questions and make suggestions about<br />
Seam?</strong></h3>
<p><strong><a name="forum"></a></strong></p>
<p><a name="forum"></a>Please use the <a href="http://www.jboss.com/index.html?module=bb&amp;op=viewforum&amp;f=231">Seam User&#8217;s discussion forum</a> for user questions.</p>
<h3><strong><a name="books"></a>Q: Are there books about Seam?</strong></h3>
<p><strong><a name="books"></a></strong></p>
<p><a name="books"></a>A: Yes, Prentice Hall&#8217;s <a href="http://my.safaribooksonline.com/013241273X">&#8220;JBoss Seam:<br />
Simplicity and Power Beyond Java EE 5.0&#8243;</a> is a comprehensive guide for Seam written by JBoss insiders.</p>
<h3><strong><a name="jsf"></a>Q: Is it true that Seam only works with JSF?</strong></h3>
<p> <strong><a name="jsf">/a></strong></p>
<p><a name="jsf"></a>Seam only supports JSF as a view framework at this time. We plan to support other web rameworks in the future. We like JSF because it is a component-based UI framework, which fits really well with Seam&#8217;s  component-based approach to business objects and persistence objects. <strong>Seam made a major improvement to JSF by eliminating almost all XML configuration for backing beans &#8212; you can now define back beans from POJOs or EJB3 components using simple annotations.</strong> We recommend you use <a href="https://facelets.dev.java.net/">Facelets</a>, instead of JSP, with JSF. Facelets provide a powerful templating framework, better appplication performance, and allows us to write much simpler JSF pages. Please see the Seam <code>booking</code> example application for an example on how to use Facelets.</p>
<h3><strong><a name="ajax"></a>Q: Can I use AJAX with Seam?</strong></h3>
<p> <a name="ajax"></a>A: Yes, Seam provides excellent support for AJAX. First, Seam supports the ICEfaces and Ajax4JSF Ajax component libraries for JSF. If you prefer a more &#8220;old fashioned&#8221; approach, Seam provides a complete <a href="http://docs.jboss.com/seam/latest/reference/en/html/remoting.html">JavaScript remoting framework</a> which lets you call Seam components and subscribe to JMS topics directly from the client. Please refer to the Seam <code>remoting</code> example application on how to use AJAX remoting to implement a chat room.</p>
<p>Finally, Seam&#8217;s concurrency model is designed especially for use with Ajax. </p>
<h3><strong><a name="test"></a>Q: Can I unit test Seam applications without starting the Application Server?</strong></h3>
<p> <strong><a name="test"></a></strong></p>
<p><a name="test"></a>Yes, Seam provides its own <a href="http://docs.jboss.com/seam/latest/reference/en/html/testing.html">integration test framework based on TestNG</a>. You can easily mock all Seam services<br />
using those facilities without ever loading an application server or a database. Refer to the  <code>testexample</code> ANT target in the Seam <code>booking</code> example application for more details.</p>
<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2010/08/jboss-seam-interview-questions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JVM,JRE,Java Compiler Interview Questions</title>
		<link>http://www.javabeat.net/2010/08/jvmjrejava-compiler-interview-questions/</link>
		<comments>http://www.javabeat.net/2010/08/jvmjrejava-compiler-interview-questions/#comments</comments>
		<pubDate>Thu, 05 Aug 2010 00:48:00 +0000</pubDate>
		<dc:creator>krishnas</dc:creator>
				<category><![CDATA[Interview Questions]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JRE]]></category>
		<category><![CDATA[JVM]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=471</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>JVM,JRE,Java Compiler FAQs-1 1)How can I write a program that takes command line input? A: Java programs that take input from the command line declare a special static method called main, which takes a String array as an argument and returns void. The example program below loops through any arguments passed to the program on [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><h2>JVM,JRE,Java Compiler FAQs-1</h2>
<h3>1)How can I write a program that takes command line input?</h3>
<p>A: Java programs that take input from the command line declare a special static method called <code>main</code>, which takes a <code>String</code> array as an argument and returns void. The example program below loops through any arguments passed to the program on the command line and lists their values.</p>
<h3>2)What does <code>public static void main(String[])</code> mean?</h3>
<p>A: This is a special static method signature that is used to run Java programs from a command line interface (CLI). There is nothing special about the method itself, it is a standard Java method, but the Java interpreter is designed to call this method when a class reference is given on the command line, as below.</p>
<h3>3)Why are command line arguments passed as a <code>String</code>?</h3>
<p>A: Command line arguments are passed to the application&#8217;s main method by the Java runtime system before the application class or any supporting objects are instantiated. It would be much more complex to define and construct arbitrary object types to pass to the main method and primitive values alone are not versatile enough to provide the range of input data that strings can. String arguments can be parsed for primitive values and can also be used for arbitrary text input, file and <abbr title="Uniform Resource Locator">URL</abbr> references.</p>
<h3>4)Why doesn&#8217;t the <code>main</code> method throw an error with no arguments?</h3>
<p>A: When you invoke the Java Virtual Machine on a class without any arguments, the class&#8217; <code>main</code> method receives a <code>String</code> array of zero length. Thus, the method signature is fulfilled. Provided the main method does not make any reference to elements in the array, or checks the array length before doing so, no exception will occur.</p>
<h3>5)Why do we only use the <code>main</code> method to start a program?</h3>
<p>A: The entry point method <code>main</code> is used to the provide a standard convention for starting Java programs. The choice of the method name is somewhat arbitrary, but is partly designed to avoid clashes with the <code>Thread</code> <code>start()</code> and <code>Runnable</code> <code>run()</code> methods, for example.</p>
<h3>6)Can the <code>main</code> method be overloaded?</h3>
<p>A: Yes, any Java method can be overloaded, provided there is no <code>final</code> method with the same signature already. The Java interpreter will only invoke the standard entry point signature for the <code>main</code> method, with a string array argument, but your application can call its own <code>main</code> method as required.</p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<h3>7)Can the <code>main</code> method be declared final?</h3>
<p>A: Yes, the <code>static void main(String[])</code> method can be declared final.</p>
<h3>8)I get an exception if I remove the <code>static</code> modifier from <code>main</code>!</h3>
<p>A: The <code>static void main(String[])</code> method is a basic convention of the Java programming language that provides an entry point into the runtime system. The <code>main</code> method must be declared static because no objects exist when you first invoke the Java<br />
Virtual Machine (JVM), so there are no references to instance methods. The JVM creates the initial runtime environment in which this static method can be called, if you remove the <code>static</code> modifier, it will throw a <code>NoSuchMethodException</code>.</p>
<h3>9)How can the static <code>main</code> method use instance variables?</h3>
<p>A: For very simple programs it is possible to write a <code>main</code> method that only uses static variables and methods. For more complex systems, the <code>main</code> method is used to create an instance of itself, or another primary class, as the basis of the application. The primary application object reference uses instance methods to create and interact with other objects, do the work and return when the application terminates.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">public class SimpleClass {
&nbsp;
  public void doSomething() {
&nbsp;
    // Instance method statements
  }
&nbsp;
  public static main(final String[] args) {
&nbsp;
    SimpleClass instance = new SimpleClass();
&nbsp;
    instance.doSomething();
  }
}</pre></td></tr></table></div>

<h3>10)<a>main method from another class? </a></h3>
<p><a> A: Yes, the <code>main</code> method can be called from a separate class. First you must prepare the string array of arguments to pass to the method, then call the method through a static reference to the host class, MaxFactors in the example below. </a></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">String[] arguments = new String[] {&quot;123&quot;};
&nbsp;
MaxFactors.main(arguments);</pre></td></tr></table></div>

<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2010/08/jvmjrejava-compiler-interview-questions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tapestry Interview Questions and FAQs</title>
		<link>http://www.javabeat.net/2010/08/tapestry-interview-questions-and-faqs/</link>
		<comments>http://www.javabeat.net/2010/08/tapestry-interview-questions-and-faqs/#comments</comments>
		<pubDate>Thu, 05 Aug 2010 00:46:29 +0000</pubDate>
		<dc:creator>krishnas</dc:creator>
				<category><![CDATA[Interview Questions]]></category>
		<category><![CDATA[Tapestry]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=468</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>Jakarta Tapestry Interview Questions and FAQs &#8211; 1 1. How does Tapestry compare to other frameworks? Tapestry is very much unlike most other frameworks in that it doesn&#8217;t use code generation; instead it uses a true component object model based on JavaBeans properties and strong specifications. This gives Tapestry a huge amount of flexibility and [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><div class="h2">
<h1>Jakarta Tapestry Interview Questions and FAQs &#8211; 1</h1>
<h3>1. How does Tapestry compare to other frameworks?</h3>
</div>
<p>Tapestry is very much unlike most other frameworks in that it doesn&#8217;t use code<br />
generation; instead it uses a true component object model based on JavaBeans<br />
properties and strong specifications. This gives Tapestry a huge amount of<br />
flexibility and enables dynamic runtime inspection of the application with the<br />
Tapestry Inspector (a mini-application that can be built into any Tapestry<br />
application).</p>
<p>In addition, Tapestry applications require far less Java coding and are far<br />
more robust than equivalent applications developed with other popular<br />
frameworks. This is because the Tapestry framework takes responsibility for<br />
many important tasks, such as maintaining server-side state and dispatching<br />
incoming requests to appropriate objects and methods.</p>
<p>The many new features of release 3.0 mean that Tapestry is not only the most<br />
powerful web application framework available, it is also the fastest and<br />
easiest to adopt, regardless of whether your background is Java, Perl, XML or<br />
PHP!</p>
<div class="h2">
<h3>2. How is the performance of Tapestry?</h3>
</div>
<p>My own testing, documented in the Sept. 2001 issue of the Java Report, agrees<br />
with other testing (documented in the Tapestry discussion forums): Although<br />
straight JSPs have a slight edge in demo applications, in real applications<br />
with a database or application server backend, the performance curves for<br />
equivalent Tapestry and JSP applications are identical.</p>
<p>Don&#8217;t think about the performance of Tapestry; think about the performance of<br />
your Java developers.</p>
<div class="h2">
<h3>3. Is Tapestry a JSP tag library?</h3>
</div>
<p>Tapestry is <em>not</em> a JSP tag library; Tapestry builds on the servlet<br />
API, but doesn&#8217;t use JSPs in any way.  It uses it own HTML template<br />
format and its own rendering engine.</p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<p>Starting with release 3.0, Tapestry includes a simple JSP tag library to allow<br />
JSP pages to create links to Tapestry pages.</p>
<div class="h2">
<h3>4. What does it cost?</h3>
</div>
<p>Tapestry is open source and free. It is licensed under the Apache Software<br />
License, which allows it to be used even inside proprietary software.</p>
<div class="h2">
<h3>5. Is there a WYSIWYG editor for Tapestry, or an IDE plugin?</h3>
</div>
<p>Currently, no WYSIWYG editor is available for Tapestry; however, the design of<br />
Tapestry allows existing editors to work reasonably well (Tapestry additions<br />
to the HTML markup are virtually invisible to a WYSIWYG editor).</p>
<p><a href="http://sf.net/projects/spindle">Spindle</a> is a Tapestry plugin for<br />
the excellent open-source <a href="http://www.eclipse.org/">Eclipse</a> IDE.<br />
It adds wizards and editors for creating Tapestry applications, pages and<br />
components.</p>
<div class="h2">
<h3>6. Does Tapestry work with other other application servers besides JBoss?</h3>
</div>
<p>Of course! <a href="http://www.jboss.org/">JBoss</a> is free and convienient<br />
for the turn-key demonstrations. You can download Tapestry and JBoss and have<br />
a real J2EE application running in about a minute! The scripts that configure<br />
JBoss are sensitive to the particular release of JBoss, it must be release<br />
3.0.6.</p>
<p>However, Tapestry applications are 100% container agnostic &#8230; Tapestry<br />
doesn&#8217;t care what servlet container it is used with and does not even require<br />
an EJB container.</p>
<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2010/08/tapestry-interview-questions-and-faqs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Threads Interview Questions</title>
		<link>http://www.javabeat.net/2010/08/java-threads-interview-questions/</link>
		<comments>http://www.javabeat.net/2010/08/java-threads-interview-questions/#comments</comments>
		<pubDate>Thu, 05 Aug 2010 00:45:23 +0000</pubDate>
		<dc:creator>krishnas</dc:creator>
				<category><![CDATA[Interview Questions]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=465</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>Java Threads Interview Questions &#8211; 1 1)What is threaded programming and when is it used? Threaded programming is normally used when a program is required to do more than one task at the same time. Threading is often used in applications with graphical user interfaces; a new thread may be created to do some processor-intensive [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><h2>Java Threads Interview Questions &#8211; 1</h2>
<h3>1)What is threaded programming and when is it used?</h3>
<p>Threaded programming is normally used when a program is required to do more than one task at the same time. Threading is often used in applications with graphical user interfaces; a new thread may be created to do<br />
some processor-intensive work while the main thread keeps the interface responsive to human interaction.<br />
The Java programming language has threaded programming facilities built in, so it is relatively easy to create threaded programs. However, multi-threaded programs introduce a degree of complexity that is not justified for most simple command line applications.</p>
<h3>  2)<a name="threadmethods"></a>Why are <code>wait()</code>, <code>notify()</code><br />
and <code>notifyall()</code> methods defined in the <code>Object</code> class?</h3>
<p><span class="A">A:</span> These methods are detailed on the Java Software Development Kit JavaDoc page for the <code>Object</code> class, they are to implement threaded programming for all subclasses of <code>Object</code>.</p>
<h3>  <span class="Q">3)</span><a name="sleepmethod"></a>Why are there separate<br />
<code>wait</code> and <code>sleep</code> methods?</h3>
<p><span class="A">A:</span> The static <code>Thread.sleep(long)</code> method maintains control of thread execution but delays the next action until the sleep time expires. The <code>wait</code> method gives up control over thread execution indefinitely so that other threads can run.</p>
<h3><a name="threadclass"></a>  4)What&#8217;s the difference between <code>Thread</code> and <code>Runnable</code><br />
types?</h3>
<p><span class="A">A:</span> A Java <code>Thread</code> controls the main path of execution in an application. When you invoke the Java Virtual Machine with the <code>java</code> command, it creates an implicit thread in which to execute the <code>main</code> method. The <code>Thread</code> class provides a mechanism for the first thread to start-up other threads to run in parallel with it.<br />
The <code>Runnable</code> interface defines a type of class that can be run by a thread. The only method it requires is <code>run</code>, which makes the interface very easy to to fulfil by extending existing classes. A runnable class may have custom constructors and any number of other methods for configuration and manipulation.</p>
<h3>  <span class="Q">5)</span><a name="runmethod"></a>How does the <code>run()</code> method in <code>Runnable</code> work?</h3>
<p><span class="A">A:</span> It may help to think of the <code>run</code> method like the <code>main</code> method in standard single threaded applications. The <code>run</code> method is a standard entry point to run or execute a class. The <code>run</code> method is normally only executed in the context of an independent  <code>Thread</code>, but is a normal method in all other respects.</p>
<h3>  <span class="Q">6)</span><a name="threadrunmethod"></a>A <code>Thread</code> is runnable, how does that work?</h3>
<p><span class="A">A:</span> The <code>Thread</code> class&#8217; <code>run</code> method normally invokes the<br />
<code>run</code> method of the <code>Runnable</code> type it is passed in its constructor. However, it is<br />
possible to override the thread&#8217;s <code>run</code> method with your own.</p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<h3>  <span class="Q">7)</span><a name="separaterunnable"></a>Why not override<br />
<code>Thread</code> to make a <code>Runnable</code>?</h3>
<p><span class="A">A:</span> There is little difference in the work required to override the <code>Thread</code> class compared with implementing the <code>Runnable</code> interface, both require the body of the <code>run()</code> method. However, it is much simpler to make an existing class hierarchy runnable because any class can be adapted to implement the <code>run()</code> method. A subclass of <code>Thread</code> cannot extend any other type, so application-specific code would have to be added to it rather than inherited.<br />
Separating the <code>Thread</code> class from the <code>Runnable</code> implementation also avoids potential<br />
synchronization problems between the thread and the <code>run()</code> method. A separate <code>Runnable</code> generally gives greater flexibility in the way that runnable code is referenced and executed.</p>
<h3>  <span class="Q">8)</span><a name="threadstartrun"></a>What&#8217;s the difference<br />
between a thread&#8217;s <code>start()</code> and <code>run()</code> methods?</h3>
<p><span class="A">A:</span> The separate <code>start()</code> and <code>run()</code> methods in the  <code>Thread</code> class provide two ways to create threaded programs. The <code>start()</code> method starts<br />
the execution of the new thread and calls the <code>run()</code> method. The <code>start()</code> method<br />
returns immediately and the new thread normally continues until the <code>run()</code> method returns.<br />
The <code>Thread</code> class&#8217; <code>run()</code> method does nothing, so sub-classes should override the<br />
method with code to execute in the second thread. If a <code>Thread</code> is instantiated with a <code>Runnable</code> argument, the thread&#8217;s <code>run()</code> method executes the <code>run()</code> method of<br />
the <code>Runnable</code> object in the new thread instead.<br />
Depending on the nature of your threaded program, calling the <code>Thread</code> <code>run()</code> method directly <em>can</em> give the same output as calling via the <code>start()</code> method, but in the latter case the code is actually executed in a new thread. </p>
<h3>  <span class="Q">9)</span><a name="overridestart"></a>Can I implement my own <code>start()</code> method?</h3>
<p><span class="A">A:</span> The <code>Thread</code> <code>start()</code> method is not marked <code>final</code>, but should not be overridden. This method contains the code that creates a new executable thread and is very specialised. Your threaded application should either pass a <code>Runnable</code> type to a new  <code>Thread</code>, or extend <code>Thread</code> and override the <code>run()</code> method.</p>
<h3>  <span class="Q">10)</span><a name="synchronizedusage"></a>Do I need to use <code>synchronized</code> on <code>setValue(int)</code>?</h3>
<p><span class="A">A:</span> It depends whether the method affects method local variables, class static or instance variables. If only method local variables are changed, the value is said to be <em>confined</em> by the method and is not prone to threading issues.</p>
<h3></h3>
<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2010/08/java-threads-interview-questions/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Groovy Interview Questions and FAQs</title>
		<link>http://www.javabeat.net/2010/08/groovy-interview-questions-and-faqs/</link>
		<comments>http://www.javabeat.net/2010/08/groovy-interview-questions-and-faqs/#comments</comments>
		<pubDate>Thu, 05 Aug 2010 00:43:15 +0000</pubDate>
		<dc:creator>krishnas</dc:creator>
				<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Interview Questions]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=460</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>Groovy Interview Questions and FAQs &#8211; 1 What is Groovy? Groovy is a powerful high level language for the Java platform which compiles down to Java bytecode. Think of it as a Ruby or Python like language that is tightly integrated with the Java platform &#8211; allowing you the same powerful and concise coding syntax [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><h2>Groovy Interview Questions and FAQs &#8211; 1</h2>
<h2>What is Groovy?</h2>
<p>Groovy is a powerful high level language for the Java platform which compiles down to Java bytecode.<br />
Think of it as a Ruby or Python like language that is tightly integrated with the Java platform &#8211; allowing you the same powerful and concise coding syntax as Ruby or Pyton but allowing you to stay on the JVM and protect your investment in J2SE, J2EE and all the plethora of great useful Java code out there.</p>
<h2>Why Groovy? Why don&#8217;t you just use Jython, JRuby, bsh, rhino, pnuts, &#8230;</h2>
<p>Firstly ports of existing languages like Python, Ruby, Smalltalk and JavaScript to the JVM are a good thing and we welcome them. If you already use and/or are fond of these languages please be our guests to use the Java-port of them.One of the main design goals of Groovy is to be a scripting language for Java developers to use. So we wanted to reuse both Java&#8217;s semantics and the whole set of J2SE APIs rather than introduce a port of a different language with different semantics and APIs to learn and implement/maintain.</p>
<p>e.g. in Groovy, java.lang.Object is the root of the object hierarchy, Object.equals(), Object.hashCode() and Comparable are used for comparions and lookups of objects, that java.util.List and java.util.Map are used for collections, Java Beans are fully supported and that Java and Groovy classes are interchangable inside the<br />
VM. Groovy is built on top of the J2SE APIs, rather than having 2 parallel platforms etc.<br />
In other words we wanted the Groovy language to be very easy to pick up if you&#8217;re already a Java developer and for there to be a very small number of new APIs to learn. By this statement we&#8217;re not implying that Python / Ruby / JavaScript are hard to learn per se &#8211; its just there&#8217;s more to know, things are more different and there&#8217;s more APIs to learn</p>
<p>Think of Groovy as a Ruby or Python like language that is tightly integrated with the Java platform (as opposed to the Unix/Posix command shell and C-libraries) &#8211; allowing you the same powerful and concise coding syntax as Ruby or Pyton but allowing you to stay on the JVM and protect your investment in J2SE, J2EE and all the plethora of great useful Java code out there without any adapter layers or parallel API sets etc. There is a more detailed set of comparisio ther languages here</p>
<h2>What are the dependencies for Groovy?</h2>
<p>As well as Java 1.4 and the Groovy jar we also depend at runtime on the ASM library.</p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<h2>What is the licence for Groovy?</h2>
<p>Groovy is open source using a BSD / Apache style licence</p>
<h2>I get errors when trying to run groovy, groovysh or groovyConsole. Whats wrong?</h2>
<p>Groovy depends on JDK 1.4 or later. Common errors people have when trying to run Groovy is that there&#8217;s an old groovy jar on the CLASSPATH somewhere (have you checked in java/lib/ext?) or that JAVA_HOME points to an old JDK before JDK 1. For more help please see this description of running Groovy code.</p>
<h2>How can I add stuff to the classpath when running things in groovysh or groovy?</h2>
<p>You can add things to your $CLASSPATH environment variable. Another popular option is to create a .groovy/lib directory in your home directory and add whatever jars you want to be available by default. e.g. if you wish to connect to your favourite JDBC database and do some scripting with it then add your JDBC driver to ~/.groovy/lib.</p>
<h2>Things work if I use Suns conventions and put { on the same line, but if I add a new line things break?</h2>
<p>When using closures with method calls we have some syntax sugar in Groovy which is sensitive to whitespace (newlines to be preceise). Please see this description in common gotchas for a full description.</p>
<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2010/08/groovy-interview-questions-and-faqs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tomcat Interview Questions</title>
		<link>http://www.javabeat.net/2010/08/tomcat-interview-questions/</link>
		<comments>http://www.javabeat.net/2010/08/tomcat-interview-questions/#comments</comments>
		<pubDate>Thu, 05 Aug 2010 00:42:03 +0000</pubDate>
		<dc:creator>krishnas</dc:creator>
				<category><![CDATA[Apache Tomcat]]></category>
		<category><![CDATA[Interview Questions]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=457</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>Tomcat Interview Questions &#8211; 1 How do you create multiple virtual hosts? If you want tomcat to accept requests for different hosts e.g., www.myhostname.com then you must 0. create ${catalina.home}/www/appBase , ${catalina.home}/www/deploy, and ${catalina.home}/conf/Catalina/www.myhostname.com 1. add a host entry in the server.xml file 1 &#60;Host appBase=&#34;www/appBase&#34; name=&#34;www.myhostname.com&#34;/&#62; 2. Create the the following file under conf/Catalina/www.myhostname.com/ROOT.xml [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><h2>Tomcat Interview Questions &#8211; 1</h2>
<h3>How do you create multiple virtual hosts?</h3>
<p>If you want tomcat to accept requests for different hosts e.g., www.myhostname.com then you must 0. create ${catalina.home}/www/appBase , ${catalina.home}/www/deploy, and ${catalina.home}/conf/Catalina/www.myhostname.com</p>
<p>1. add a host entry in the server.xml file</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">  &lt;Host appBase=&quot;www/appBase&quot; name=&quot;www.myhostname.com&quot;/&gt;</pre></td></tr></table></div>

<p>2. Create the the following file under conf/Catalina/www.myhostname.com/ROOT.xml</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;Context
    path=&quot;/&quot;
    docBase=&quot;www/deploy/mywebapp.war&quot;
    reloadable=&quot;true&quot; antiJARLocking=&quot;true&quot;&gt;
&lt;/Context&gt;</pre></td></tr></table></div>

<p>Add any parameters specific to this hosts webapp to this context file</p>
<p>3. put your war file in ${catalina.home}/www/deploy</p>
<p>When tomcat starts, it finds the host entry, then looks for any context files and will start any apps with a context</p>
<p>To add more sites just repeat and rinse, all webapps can share the same war file location and appbase</p>
<h3>How will you load properties file?</h3>
<p>* Use a ResourceBundle. See the Java docs for the specifics of how the ResourceBundle class works. Using this method, the properties file must go into the WEB-INF/classes directory or in a jar file contained in the WEB-INF/lib directory.</p>
<p>* Another way is to use the method getResourceAsStream() from the ServletContext class. This allows you update the file without having to reload the webapp as required by the first method. Here is an example code snippet, without any error trapping:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">// Assuming you are in a Servlet extending HttpServlet
                    // This will look for a file called &quot;/more/cowbell.properties&quot; relative
                    // to your servlet Root Context
                   InputStream is = getServletContext().getResourceAsStream(&quot;/more/cowbell.properties&quot;);
                   Properties  p  = new Properties();
                   p.load(is);
                 is.close();</pre></td></tr></table></div>

<h3>Can I set Java system properties differently for each webapp?</h3>
<p>No. If you can edit Tomcat&#8217;s startup scripts, you can add &#8220;-D&#8221; options to Java. But there is no way to add such properties in web.xml or the webapp&#8217;s context.</p>
<h3>How do I configure Tomcat to work with IIS and NTLM?</h3>
<p>Follow the standard instructions for when the isapi_redirector.dll Configure IIS to use &#8220;integrated windows security&#8221;</p>
<p>In server.xml, make sure you disable tomcat authentication:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">&lt;Connector port=&quot;8009&quot; enableLookups=&quot;false&quot; redirectPort=&quot;8443&quot; protocol=&quot;AJP/1.3&quot; tomcatAuthentication=&quot;false&quot; /&gt;</pre></td></tr></table></div>

<h3>How can I access members of a custom Realm or Principal?</h3>
<p>When you create a custom subclass of RealmBase or GenericPrincipal and attempt to use those classes in your webapp code, you&#8217;ll probably have problems with ClassCastException. This is because the instance returned by request.getUserPrincipal() is of a class loaded by the server&#8217;s classloader, and you are trying to access it through you webapp&#8217;s classloader. While the classes maybe otherwise exactly the same, different (sibling) classloaders makes them different classes.</p>
<p>This assumes you created a My&#8220;Principal class, and put in Tomcat&#8217;s server/classes (or lib) directory, as well as in your webapp&#8217;s webinf/classes (or lib) directory. Normally, you would put custom realm and principal classes in the server directory because they depend on other classes there.</p>
<p>Here&#8217;s what you would like to do, but it throws ClassCastException:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">MyPrincipal p = request.getUserPrincipal();
String emailAddress = p.getEmailAddress();</pre></td></tr></table></div>

<p>Here are 4 ways you might get around the classloader boundary:</p>
<p>1) Reflection</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">Principal p = request.getUserPrincipal();
String emailAddress = p.getClass().getMethod(&quot;getEmailAddress&quot;, null).invoke(p, null);</pre></td></tr></table></div>

<p>2) Move classes to a common classloader</p>
<p>You could put your custom classes in a classloader that is common to both the server and your webapp &#8211; e.g., either the &#8220;common&#8221; or bootstrap classloaders. To do this, however, you would also need to move the classes that your custom classes depend on up to the common classloader, and that seems like a bad idea, because there a many of them and they a core server classes.</p>
<p>3) Common Interfaces</p>
<p>Rather than move the implementing custom classes up, you could define interfaces for your customs classes, and put the interfaces in the common directory. You&#8217;re code would look like this:</p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">public interface MyPrincipalInterface extends java.security.Principal {
  public String getEmailAddress();
}
&nbsp;
public class MyPrincipal implements MyPrincipalInterface {
...
  public String getEmailAddress() {
    return emailAddress;
  }
}
&nbsp;
public class MyServlet implements Servlet {
  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    MyPrincipalInterface p = (MyPrincipalInterface)request.getUserPrincipal();
    String emailAddress = p.getEmailAddress();
...
}</pre></td></tr></table></div>

<p>Notice that this method gives you pretty much the webapp code you wanted in the first place</p>
<p>4) Serializing / Deserializing</p>
<p>You might want to try serializing the response of &#8216;request.getUserPrincipal()&#8217; and deserialize it to an instance of [webapp]MyPrincipal.</p>
<h3>How do I override the default home page loaded by Tomcat?</h3>
<p>After successfully installing Tomcat, you usually test it by loading http://localhost:8080 . The contents of that page are compiled into the index_jsp servlet. The page even warns against modifying the index.jsp files for this reason. Luckily, it is quite easy to override that page. Inside $TOMCAT_HOME/conf/web.xml there is a section called &lt;welcome-file-list&gt; and it looks like this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">&lt;welcome-file-list&gt;
        &lt;welcome-file&gt;index.html&lt;/welcome-file&gt;
        &lt;welcome-file&gt;index.htm&lt;/welcome-file&gt;
        &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
    &lt;/welcome-file-list&gt;</pre></td></tr></table></div>

<p>The default servlet attempts to load the index.* files in the order listed. You may easily override the index.jsp file by creating an index.html file at $TOMCAT_HOME/webapps/ROOT. It&#8217;s somewhat common for that file to contain a new static home page or a redirect to a servlet&#8217;s main page. A redirect would look<br />
like:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">&lt;html&gt;
&nbsp;
&lt;head&gt;
&lt;meta http-equiv=&quot;refresh&quot; content=&quot;0;URL=http://mydomain.com/some/path/to/servlet/homepage/&quot;&gt;
&lt;/head&gt;
&nbsp;
&lt;body&gt;
&lt;/body&gt;
&nbsp;
&lt;/html&gt;</pre></td></tr></table></div>

<p>This change takes effect immediately and does not require a restart of Tomcat.</p>
<h3>How do I enable Server Side Includes (SSI)?</h3>
<p>Two things have to be done for tomcat to aknowledge SSI scripts:</p>
<p>1. Rename $CATALINA_BASE/server/lib/servlets-ssi.renametojar to $CATALINA_BASE/server/lib/servlets-ssi.jar.</p>
<p>2. Uncomment the section of web.xml found in $CATALINA_BASE/conf/web.xml that deals with SSI. it looks like this when it is uncommented:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">&lt;servlet&gt;
        &lt;servlet-name&gt;ssi&lt;/servlet-name&gt;
        &lt;servlet-class&gt;
          org.apache.catalina.ssi.SSIServlet
        &lt;/servlet-class&gt;
        &lt;init-param&gt;
          &lt;param-name&gt;buffered&lt;/param-name&gt;
          &lt;param-value&gt;1&lt;/param-value&gt;
        &lt;/init-param&gt;
        &lt;init-param&gt;
          &lt;param-name&gt;debug&lt;/param-name&gt;
          &lt;param-value&gt;0&lt;/param-value&gt;
        &lt;/init-param&gt;
        &lt;init-param&gt;
          &lt;param-name&gt;expires&lt;/param-name&gt;
          &lt;param-value&gt;666&lt;/param-value&gt;
        &lt;/init-param&gt;
        &lt;init-param&gt;
          &lt;param-name&gt;isVirtualWebappRelative&lt;/param-name&gt;
          &lt;param-value&gt;0&lt;/param-value&gt;
        &lt;/init-param&gt;
        &lt;load-on-startup&gt;4&lt;/load-on-startup&gt;
    &lt;/servlet&gt;</pre></td></tr></table></div>

<h3>How do I use DataSources with Tomcat?</h3>
<p>When developing J2EE web applications, the task of database connection management can be daunting. Best practice involves using a J2EE DataSource to provide connection pooling, but configuring DataSources in web application servers and connecting your application to them is often a cumbersome process and poorly documented.</p>
<p>The usual procedure requires the application developer to set up a DataSource in the web application server, specifying the driver class, JDBC URL (connect string), username, password, and various pooling options. Then, the developer must reference the DataSource in his application&#8217;s web.xml configuration file, and then access it properly in his servlet or JSP. Particularly during<br />
development, setting all of this up is tedious and error-prone.</p>
<p>With Tomcat 5.5, the process is vastly simplified. Tomcat allows you to configure DataSources for your J2EE web application in a context.xml file that is stored in your web application project. You don&#8217;t have to mess with configuring the DataSource separately in the Tomcat server.xml, or referencing it in your application&#8217;s web.xml file. Here&#8217;s how:</p>
<p>Install the JDBC Driver</p>
<p>Install the .jar file(s) containing the JDBC driver in Tomcat&#8217;s common/lib folder. You do not need to put them in your application&#8217;s WEB-INF/lib folder. When working with J2EE DataSources, the web application server manages connections for your application.</p>
<p>Create META-INF/context.xml</p>
<p>In the root of your web app directory structure, create a folder named META-INF (all caps). Inside that folder, create a file named context.xml that contains a Resource like this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&nbsp;
&lt;Context&gt;
&nbsp;
  &lt;Resource name=&quot;jdbc/WallyDB&quot; auth=&quot;Container&quot;
            type=&quot;javax.sql.DataSource&quot; username=&quot;wally&quot; password=&quot;wally&quot;
            driverClassName=&quot;com.microsoft.sqlserver.jdbc.SQLServerDriver&quot;
            url=&quot;jdbc:sqlserver://localhost;DatabaseName=mytest;SelectMethod=cursor;&quot;
            maxActive=&quot;8&quot;
            /&gt;
&nbsp;
&lt;/Context&gt;</pre></td></tr></table></div>

<p>This example shows how to configure a DataSource for a SQL Server database named mytest located on the development machine. Simply edit the Resource name, driverClassName, username, password, and url to provide values appropriate for your JDBC driver.</p>
<p>Access the DataSource in Your Application</p>
<p>From a Servlet</p>
<p>Here&#8217;s how you might access the data in a servlet:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">InitialContext ic = new InitialContext();
  DataSource ds = (DataSource) ic.lookup(&quot;java:comp/env/jdbc/WallyDB&quot;);
  Connection c = ds.getConnection();
  ...
  c.close();</pre></td></tr></table></div>

<p>Notice that, when doing the DataSource lookup, you must prefix the JNDI name of the resource with java:comp/env/</p>
<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2010/08/tomcat-interview-questions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache Ant Interview Questions</title>
		<link>http://www.javabeat.net/2010/08/apache-ant-interview-questions/</link>
		<comments>http://www.javabeat.net/2010/08/apache-ant-interview-questions/#comments</comments>
		<pubDate>Thu, 05 Aug 2010 00:40:19 +0000</pubDate>
		<dc:creator>krishnas</dc:creator>
				<category><![CDATA[Apache Ant]]></category>
		<category><![CDATA[Interview Questions]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=454</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>Apache Ant Interview Questions &#8211; 1 1)What is ant? Ant is a small animal who can build magnificent buildings. Ant builds! ANT is a Java based building tool, which is similar to make, and so much better than make. ANT, what a smart name for a building tool, even the original author of ANT, James [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><h2>Apache Ant Interview Questions &#8211; 1</h2>
<h3>1)What is ant?</h3>
<p>Ant is a small animal who can build magnificent buildings. Ant builds! ANT is a Java based building tool, which is similar to make, and so much better than make. ANT, what a smart name for a building tool, even the original author of ANT, James Duncan Davidson, meant &#8220;Another Neat Tool&#8221;. A win-win ant learning method</p>
<p>There is a shortcut.</p>
<p>If you download a small jakarta project, such as Log4J, which is built by ant. It is a good and simple example for you to learn ant. Actually, you hit two birds with one stone.<br />
Ant is easy!<br />
The hard part is how to make a very complicated diversified system work very simple and elegant. Knowledge about ant is not enough, you need an elegant and simple design, you need great naming convention, you need to optimize the code reusability and flexibility, you need a least maintenance system&#8230;<br />
Then it is not easy now ..</p>
<h3>2)How do I get started to use ant? Can you give me a &#8220;Hello World&#8221; ant script?</h3>
<p>Simple.</p>
<ul>
<li>Download the most recent version of ant from Apache; unzip it some where on your machine.</li>
<li>Install j2sdk 1.4 or above.</li>
<li>Set JAVA_HOME and ANT_HOME to the directory your installed them respectively.</li>
<li>Put %JAVA_HOME%/bin;%ANT_HOME%/bin on your Path. Use ${JAVA_HOME}/bin:${ANT_HOME}/bin on UNIX. Yes, you can use forward slash on windows.</li>
<li>Write a &#8220;Hello world&#8221; build.xml</li>
</ul>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">&lt;project name=&quot;hello&quot; default=&quot;say.hello&quot; basedir=&quot;.&quot; &gt;
                    &lt;property name=&quot;hello.msg&quot; value=&quot;Hello, World!&quot; /&gt;
                    &lt;target name=&quot;say.hello&quot; &gt;
                      &lt;echo&gt;${hello.msg}&lt;/echo&gt;
                    &lt;/target&gt;
                  &lt;/project&gt;</pre></td></tr></table></div>

<p>* Type ant in the directory your build.xml located.</p>
<p>* You are ready to go!!!!</p>
<h3>3)How to delete files from a directory if it exists?</h3>
<p>The following code fails when directory does not exist!</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">&lt;delete&gt;
    &lt;fileset dir=&quot;${upperdir.which.exists}&quot;&gt;
      &lt;include name=&quot;${classes.dir}/*.class&quot; /&gt;
    &lt;/fileset&gt;
  &lt;/delete&gt;</pre></td></tr></table></div>

<p>Your code has many problems.</p>
<p>1. You should not use implicit fileset, which is deprecated. You should use nested fileset.</p>
<p>2. If dir does not exist, the build will fail, period!</p>
<p>3. If you are not sure, use a upper level dir, which exists for sure. See the following fileset.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">&lt;path id=&quot;build.classpath&quot;&gt;
    &lt;fileset dir=&quot;${build.lib}&quot; includes=&quot;**/*.jar&quot;/&gt;
    &lt;fileset dir=&quot;${build.classes}&quot; /&gt;
  &lt;/path&gt;
&nbsp;
  &lt;target....&gt;
    &lt;javac ....&gt;
      &lt;classpath refid=&quot;build.classpath&quot; /&gt;
    &lt;/java&gt;
  &lt;/target&gt;
&nbsp;
  &lt;target....&gt;
    &lt;java ....&gt;
      &lt;classpath refid=&quot;build.classpath&quot; /&gt;
    &lt;/java&gt;
  &lt;/target&gt;</pre></td></tr></table></div>

<h3>5)How does ant read properties? How to set my property system?</h3>
<p>Ant sets properties by order, when something is set, the later same properties cannot overwrite the previous ones. This is opposite to your Java setters.  This give us a good leverage of preset all properties in one place, and overwrite only the needed. Give you an example here. You need password for a task, but don&#8217;t want to share it with your team members, or not the developers outside your team.</p>
<p>Store your password in your ${user.home}/prj.properties</p>
<p>pswd=yourrealpassword</p>
<p>In your include directory master prj.properties</p>
<p>pswd=password</p>
<p>In your build-common.xml read properties files in this order</p>
<p>1. The commandline will prevail, if you use it: ant<br />
-Dpswd=newpassword</p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<p>2. ${user.home}/prj.properties (personal)</p>
<p>3. yourprojectdir/prj.properties (project team wise)</p>
<p>4. your_master_include_directory/prj.properties (universal)</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">&lt;cvsnttask password=&quot;${pswd} ... /&gt;</pre></td></tr></table></div>

<p>Problem solved!</p>
<h3>6)How to modify properties in ant?</h3>
<p>No, you can&#8217;t!</p>
<p>Properties in Ant are immutable. There is a good reason behind this, see this FAQ item for more details.</p>
<h3>7)How to use ant-contrib tasks?</h3>
<p>A: Simple, just copy ant-contrib.jar to your ant*/lib directory</p>
<p>And add this line into your ant script, all ant-contrib tasks are now available to you!</p>
<p>&lt;taskdef<br />
resource=&#8221;net/sf/antcontrib/antcontrib.properties&#8221; /&gt;</p>
<h3>8)How to loop on a list or fileset?</h3>
<p>Use ant-contrib &lt;for&gt; &lt;foreach&gt; tasks</p>
<p>General to say, use &lt;for&gt; is better than use &lt;foreach&gt; since for each is actually open another ant property space, use more memory too.</p>
<h3>9)Why do I get en exception when I use location=&#8221;D:\\Code\\include&#8221; as<br />
attribute of includepath?</h3>
<p>See here.</p>
<p>You need to escape the string to &#8220;D:\\\\Code\\\\include&#8221; or use &#8220;D:/Code/include&#8221; instead!</p>
<p>Believe me or not? Forward slash works on windows in all ant or java code. It also works in windows environment variables. It does not work in cmd (dos) window before XP. It also works in XP dos window now!</p>
<h3>10)Can I put the contents of a classpath or fileset into a property?</h3>
<p>Yes, you can.</p>
<p>This is very similar to the call of Java class toString() method and actually it is calling the toString() method inside ant. For example</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">&lt;fileset id=&quot;fs1&quot; dir=&quot;t1&quot; includes=&quot;**/*.java&quot;/&gt;
&lt;property name=&quot;f1.contents&quot; refid=&quot;fs1&quot;/&gt;
&lt;echo&gt;f1.contents=${f1.contents}&lt;/echo&gt;</pre></td></tr></table></div>

<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2010/08/apache-ant-interview-questions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quartz Interview Questions</title>
		<link>http://www.javabeat.net/2010/08/quartz-interview-questions/</link>
		<comments>http://www.javabeat.net/2010/08/quartz-interview-questions/#comments</comments>
		<pubDate>Thu, 05 Aug 2010 00:38:25 +0000</pubDate>
		<dc:creator>krishnas</dc:creator>
				<category><![CDATA[Interview Questions]]></category>
		<category><![CDATA[Quartz Scheduler]]></category>
		<category><![CDATA[Quartz]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=451</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>What is Quartz? Quartz is a job scheduling system that can be integrated with, or used along side virtually any other software system. The term &#8220;job scheduler&#8221; seems to conjure different ideas for different people. As you read this tutorial, you should be able to get a firm idea of what we mean when we [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><h2>What is Quartz?</h2>
<p>Quartz is a job scheduling system that can be integrated with, or used along side virtually any other software system. The term &#8220;job scheduler&#8221; seems to conjure different ideas for different people. As you read this tutorial, you should be able to get a firm idea of what we mean when we use this term, but in short, a job scheduler is a system that is responsible for executing (or notifying) other software components when a pre-determined (scheduled) time arrives.</p>
<p>Quartz is quite flexible, and contains multiple usage paradigms that can be used separately or together, in order to achieve your desired behavior, and enable you to write your code in the manner that seems most &#8216;natural&#8217; to your project.</p>
<p>Quartz is very light-weight, and requires very little setup/configuration &#8211; it can actually be used &#8216;out-of-the-box&#8217; if your needs are relatively basic.</p>
<p>Quartz is fault-tolerant, and can persist (&#8216;remember&#8217;) your scheduled jobs between system restarts.</p>
<p>Although Quartz is extremely useful for simply running certain system processes on given schedules, the full potential of Quartz can be realized when you learn how to use it to drive the flow of your application&#8217;s business processes.<br />
What is Quartz &#8211; From a Software Component View?</p>
<p>Quartz is distributed as a small java library (.jar file) that contains all of the core Quartz functionality. The main interface (API) to this functionality is the Scheduler interface. It provides simple operations such as scheduling/unscheduling jobs, starting/stopping/pausing the scheduler.</p>
<p>If you wish to schedule your own software components for execution they must implement the simple Job interface, which contains the method execute(). If you wish to have components notified when a scheduled fire-time arrives, then the components should implement either the TriggerListener or JobListener interface.</p>
<p>The main Quartz &#8216;process&#8217; can be started and ran within your own application, as a stand-alone application (with an RMI interface), or within a J2EE app. server to be used as a resource by your J2EE components.</p>
<h2>Why not just use java.util.Timer?</h2>
<p>Since JDK 1.3, Java has &#8220;built-in&#8221; timer capabilities, through the java.util.Timer and java.util.TimerTask classes &#8211; why would someone use Quartz rather than these standard features?</p>
<p>There are many reasons! Here are a few:</p>
<p>1. Timers have no persistence mechanism.</p>
<p>2. Timers have inflexible scheduling (only able to set start-time &amp; repeat interval, nothing based on dates, time of day, etc.)</p>
<p>3. Timers don&#8217;t utilize a thread-pool (one thread per timer)</p>
<p>4. Timers have no real management schemes &#8211; you&#8217;d have to write your own mechanism for being able to remember, organize and retreive your tasks by name, etc.</p>
<p>&#8230;of course to some simple applications these features may not be important, in which case it may then be the right decision not to use Quartz.</p>
<h2>How can I control the instantiation of Jobs?</h2>
<p>See org.quartz.spi.JobFactory and the org.quartz.Scheduler.setJobFactory(..) method.</p>
<h2>How do I keep a Job from being removed after it completes?</h2>
<p>Set the property JobDetail.setDurability(true) &#8211; which instructs Quartz not to delete the Job when it becomes an &#8220;orphan&#8221; (when the Job not longer has a Trigger referencing it).</p>
<h2>How do I keep a Job from firing concurrently?</h2>
<p>Make the job class implement StatefulJob rather than Job. Read the JavaDOC for StatefulJob for more information.</p>
<h2>How do I stop a Job that is currently executing?</h2>
<p>See the org.quartz.InterruptableJob interface, and the Scheduler.interrupt(String, String) method.</p>
<h2>How do I chain Job execution? Or, how do I create a workflow?</h2>
<p>There currently is no &#8220;direct&#8221; or &#8220;free&#8221; way to chain triggers with Quartz. However there are several ways you can accomplish it without much effort. Below is an outline of a couple approaches:</p>
<p>One way is to use a listener (i.e. a TriggerListener, JobListener or SchedulerListener) that can notice the completion of a job/trigger and then immediately schedule a new trigger to fire. This approach can get a bit involved, since you&#8217;ll have to inform the listener which job follows which &#8211; and you may need to worry about persistence of this information.</p>
<p>Another way is to build a Job that contains within its JobDataMap the name of the next job to fire, and as the job completes (the last step in its execute() method) have the job schedule the next job. Several people are doing this and have had good luck. Most have made a base (abstract) class that is a Job that knows how to get the job name and group out of the JobDataMap using special keys (constants) and contains code to schedule the identified job. Then they simply make extensions of this class that included the additional work the job should do.</p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<p>In the future, Quartz will provide a much cleaner way to do this, but until then, you&#8217;ll have to use one of the above approaches, or think of yet another that works better for you.</p>
<h2>Why isn&#8217;t my trigger firing?</h2>
<p>The most common reason for this is not having called Scheduler.start(), which tells the scheduler to start firing triggers.</p>
<p>The second most common reason is that the trigger or trigger group has been paused.</p>
<h2>Daylight Saving Time and Triggers</h2>
<p>CronTrigger and SimpleTrigger each handle daylight savings time in their own way &#8211; each in the way that is intuitive to the trigger type.</p>
<p>First, as a review of what daylight savings time is, please read this resource: http://webexhibits.org/daylightsaving/g.html . Some readers may be unaware that the rules are different for different nations/contents. For example, the 2005 daylight savings time starts in the United States on April 3, but in Egypt on April 29. It is also important to know that not only the dates are different for different locals, but the time of the shift is different as well. Many places shift at 2:00 am, but others shift time at 1:00 am, others at 3:00 am, and still others right at midnight.</p>
<p>SimpleTrigger allows you to schedule jobs to fire every N milliseconds. As such, it has to do nothing in particular with respect to daylight savings time in order to &#8220;stay on schedule&#8221; &#8211; it simply keeps firing every N milliseconds. Regardless your SimpleTrigger is firing every 10 seconds, or every 15 minutes, or every hour or every 24 hours it will continue to do so. However the implication of this which confuses some users is that if your SimpleTrigger is firing say every 12 hours, before daylight savings switches it may be firing at what appears to be 3:00 am and 3:00 pm, but after daylight savings 4:00 am and 4:00 pm. This is not a bug &#8211; the trigger has kept firing exacly every N milliseconds, it just that the &#8220;name&#8221; of that time that humans impose on that moment has changed.</p>
<p>CronTrigger allows you to schedule jobs to fire at certain moments with respect to a &#8220;gregorian calendar&#8221;. Hence, if you create a trigger to fire every day at 10:00 am, before and after daylight savings time switches it will continue to do so. However, depending on whether it was the Spring or Autumn daylight savings event, for that particular Sunday, the actual time interval between the firing of the trigger on Sundary morning at 10:00 am since its firing on Saturday morning at 10:00 am will not be 24 hours, but will instead be 23 or 25 hours respectively.</p>
<p>There is one additional point users must understand about CronTrigger with respect to daylight savings. This is that you should take careful thought about creating schedules that fire between midnight and 3:00 am (the critical window of time depends on your trigger&#8217;s locale, as explained above). The reason is that depending on your trigger&#8217;s schedule, and the particular daylight event, the trigger may be skipped or may appear to not fire for an hour or two. As examples, say you are in the United States, where daylight savings events occur at 2:00 am. If you have a CronTrrigger that fires every day at 2:15 am, then on the day of the beginning of daylight savings time the trigger will be skipped, since, 2:15 am never occurs that day. If you have a CronTrigger that fires every 15 minutes of every hour of every day, then on the day daylight savings time ends you will have an hour of time for which no triggerings occur, because when 2:00 am arrives, it will become 1:00 am again, however all of the firings during the one o&#8217;clock hour have already occurred, and the trigger&#8217;s next fire time was set to 2:00 am &#8211; hence for the next hour no triggerings will occur.</p>
<h2>How do I improve the performance of JDBC-JobStore?</h2>
<p>There are a few known ways to speed up JDBC-JobStore, only one of which is very practical.</p>
<p>First, the obvious, but not-so-practical:<br />
* Buy a better (faster) network between the machine that runs Quartz, and the machine that runs your RDBMS.</p>
<p>* Buy a better (more powerful) machine to run your database on.</p>
<p>* Buy a better RDBMS.</p>
<p>Now for something simple, but effective: Build indexes on the Quartz tables.</p>
<p>Most database systems will automatically put indexes on the primary-key fields, many will also automatically do it for the foreign-key field. Make sure yours does this, or make the indexes on all key fields of every table manually.</p>
<p>Next, manually add some additional indexes: most important to index are the TRIGGER table&#8217;s &#8220;next_fire_time&#8221; and &#8220;state&#8221; fields. Last (but not as important), add indexes to every column on the FIRED_TRIGGERS table.</p>
<h2>Create Table Indexes</h2>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">create index idx_qrtz_t_next_fire_time on qrtz_triggers(NEXT_FIRE_TIME);
create index idx_qrtz_t_state on qrtz_triggers(TRIGGER_STATE);
create index idx_qrtz_t_nf_st on qrtz_triggers(TRIGGER_STATE,NEXT_FIRE_TIME);
create index idx_qrtz_ft_trig_name on qrtz_fired_triggers(TRIGGER_NAME);
create index idx_qrtz_ft_trig_group on qrtz_fired_triggers(TRIGGER_GROUP);
create index idx_qrtz_ft_trig_name on qrtz_fired_triggers(TRIGGER_NAME);
create index idx_qrtz_ft_trig_n_g on qrtz_fired_triggers(TRIGGER_NAME,TRIGGER_GROUP);
create index idx_qrtz_ft_trig_inst_name on qrtz_fired_triggers(INSTANCE_NAME);
create index idx_qrtz_ft_job_name on qrtz_fired_triggers(JOB_NAME);
create index idx_qrtz_ft_job_group on qrtz_fired_triggers(JOB_GROUP);</pre></td></tr></table></div>

<h2>My DB Connections don&#8217;t recover properly if the database server is restarted.</h2>
<p>If you&#8217;re having Quartz create the connection data source (by specifying the connection parameters in the quartz properties file) make sure you have a connection validation query specified, such as:<br />
Connection Validation Query</p>
<p>org.quartz.dataSource.myDS.validationQuery=select 0 from dual</p>
<p>This particular query is extremly efficient for Oracle. For other databases, you&#8217;ll need to think of an efficient query that always works as long as the connection is good.</p>
<p>If you&#8217;re datasource is managed by your application server, make sure the datasource is configured in such a way that it can detect failed connections.</p>
<h2>I&#8217;m using JobStoreCMT and I&#8217;m seeing deadlocks, what can I do?</h2>
<p>JobStoreCMT is in heavy use, under heavy load by many people. It is believed to be free of bugs that can cause deadlock. However, every now and then we get complaints about deadlocks. In all cases thus far, the problem has turned out to be &#8220;user error&#8221;, thus the list below is some things for you to check if you are experiencing deadlocks.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">* Some databases falsely detect deadlocks when a tx takes a long time. Make sure you have put indexes on your tables (see improving performance of JDBCJobStore).
* Make sure you have at least number-of-threads-in-thread-pool + 2 connections in your datasources.
* Make sure you have both a managed and non-managed datasource configured for Quartz to use.
* Make sure that all work you do with the Scheduler interface is done from within a transaction. Accomplish this by using the Scheduler within a SessionBean that has its tx settings &quot;Required&quot; and &quot;Container&quot;. Or within a MessageDrivenBean with similar settings. Finally, start a UserTransaction yourself, and commit the work when done.
* If your Jobs' execute() methods use the Scheduler, make sure a transaction is in progress by using a UserTransaction or by setting the Quartz config propery &quot;org.quartz.scheduler.wrapJobExecutionInUserTransaction=true&quot;.</pre></td></tr></table></div>

<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2010/08/quartz-interview-questions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
