<?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>SCJP Certification &#187; assertion</title>
	<atom:link href="http://www.scjp-certification.com/tag/assertion/feed" rel="self" type="application/rss+xml" />
	<link>http://www.scjp-certification.com</link>
	<description>Sun Certified Java Programmer Certification exam essentials</description>
	<lastBuildDate>Fri, 30 Sep 2011 05:54:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>What is an assertion?</title>
		<link>http://www.scjp-certification.com/what-is-an-assertion.html</link>
		<comments>http://www.scjp-certification.com/what-is-an-assertion.html#comments</comments>
		<pubDate>Thu, 24 Sep 2009 12:08:41 +0000</pubDate>
		<dc:creator>Daisy Williams</dc:creator>
				<category><![CDATA[Java Facts]]></category>
		<category><![CDATA[assert]]></category>
		<category><![CDATA[assertion]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[package]]></category>

		<guid isPermaLink="false">http://www.scjp-certification.com/?p=256</guid>
		<description><![CDATA[An assertion is a statement that will be evauated during the execution of a program. It returns a boolean result....]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.scjp-certification.com%2Fwhat-is-an-assertion.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.scjp-certification.com%2Fwhat-is-an-assertion.html&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>An assertion is a statement that will be evauated during the execution of a program. It returns a boolean result. If the result is true, the code executes normally and no other action takes place. This confirms that the assumed statement is true. If the result is false, an AssertionError is thrown. The assertion condition is tested using the assert keyword. The assert keyword has the following two forms:
<ul>
<li><strong>assert assertCondition;</strong><br />
Here, assertCondition is an expression that evaluates to a boolean expression.</li>
<li><strong>assert assertCondition : exp;</strong><br />
Here, an expression exp is passed to the AssertionError in case an error is thrown at runtime.</li>
</ul>
<p>An assertion can be enabled or disabled for a class or a package during runtime as follows:</p>
<ul>
<li><strong>-da ClassName or -da PackageName</strong>: This will disable the assertion for a class or a package respectively. </li>
<li><strong>-ea ClassName or -ea PackageName:</strong> This will enable the assertion for a class or a package respectively. </li>
</ul>
<p>The following code illustrates how illustrations are used:</p>
<p><strong>public class Test<br />
 {<br />
   public static void main(String[] args)<br />
     {<br />
       int x =1;<br />
       assert(x==1);<br />
       assert(x ==2) : testA();<br />
       assert(x++>1): new Test();<br />
     }<br />
   public static void testA()<br />
     {<br />
        System.out.println(&#8220;Inside the method testA&#8221;);<br />
     }<br />
 }</strong>  </p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.scjp-certification.com%2Fwhat-is-an-assertion.html&amp;title=What%20is%20an%20assertion%3F"><img src="http://www.scjp-certification.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.scjp-certification.com/what-is-an-assertion.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What are assertions?</title>
		<link>http://www.scjp-certification.com/what-are-assertions.html</link>
		<comments>http://www.scjp-certification.com/what-are-assertions.html#comments</comments>
		<pubDate>Thu, 03 Sep 2009 12:03:18 +0000</pubDate>
		<dc:creator>Daisy Williams</dc:creator>
				<category><![CDATA[Java Facts]]></category>
		<category><![CDATA[assertion]]></category>
		<category><![CDATA[assertionerror]]></category>
		<category><![CDATA[expression]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.scjp-certification.com/?p=159</guid>
		<description><![CDATA[An assertion is a statement that is assumed to be true during the execution of a program. It returns a...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.scjp-certification.com%2Fwhat-are-assertions.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.scjp-certification.com%2Fwhat-are-assertions.html&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>An assertion is a statement that is assumed to be true during the execution of a program. It returns a boolean result. If the result is true, the code executes normally and no other action takes place. This confirms that the assumed statement is true. If the result is false, an AssertionError is thrown. The assertion condition is tested using the assert keyword. The assert keyword has the following two forms:
<ul>
<li><strong>assert assertCondition;</strong><br />
Here, assertCondition is an expression that evaluates to a boolean expression.</li>
<li><strong>assert assertCondition : exp; </strong><br />
Here, an expression exp is passed to the AssertionError in case an error is thrown at runtime.</li>
</ul>
<p>An assertion can be enabled or disabled for a class or a package during runtime as follows:</p>
<ul>
<li><strong>-da ClassName</strong> or <strong>-da PackageName</strong>: This will disable the assertion for a class or a package respectively. </li>
<li><strong>-ea ClassName</strong> or <strong>-ea PackageName</strong>: This will enable the assertion for a class or a package respectively. </li>
</ul>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.scjp-certification.com%2Fwhat-are-assertions.html&amp;title=What%20are%20assertions%3F"><img src="http://www.scjp-certification.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.scjp-certification.com/what-are-assertions.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

