tag:blogger.com,1999:blog-50584816850383206962024-03-05T08:55:46.215-08:00Java cafePatelwalahttp://www.blogger.com/profile/12814606641177309811noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-5058481685038320696.post-15842179795939098962016-10-18T04:20:00.000-07:002016-10-18T04:20:34.870-07:00Exception In java Id name and price<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: left;">
<div style="text-align: center;">
<span style="font-family: "Courier New", Courier, monospace; font-size: x-large;"><br /></span></div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-large;"><div style="text-align: center;">
Id is Not Nagative And Name Is Only A to Z And Price is 0 to 9 Value Allow Exception</div>
</span></h2>
<div>
<br /></div>
<div>
<br /></div>
<div>
<table border="1" cellpadding="0" cellspacing="0" class="MsoTable15Grid6ColorfulAccent5" style="border-collapse: collapse; border: none;"><tbody>
<tr><td style="border-color: rgb(142, 170, 219); border-image: initial; border-style: solid; border-width: 1pt 1pt 1.5pt; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">import java.io.*;<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">import java.util.*;<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">class NonNegId extends Exception<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">{<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">String msg;<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">NonNegId(String m)<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">{<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">this.msg = m;<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">} <o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">public String toString()<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">{<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">return this.msg;<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">}<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">}<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">class Bname extends Exception<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">{<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">String bnm;<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">Bname(String nm)<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">{<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">this.bnm = nm;<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">} <o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">public String toString()<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">{<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">return this.bnm;<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">}<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"><o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"><o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"><o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">}<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">class PrOnly extends Exception<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">{<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">String str;<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">PrOnly(String s)<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">{<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">this.str = s;<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">} <o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">public String toString()<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">{<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">return this.str;<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">}<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">}<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<br /></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<br /></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">class Book<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">{<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">int bid;<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">String bname;<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">double bprice;<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">Book(int no,String nm,double pr) throws NonNegId,PrOnly,Bname<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">{<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"><o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<br /></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">if(no<0)<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">{<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">throw new NonNegId("Book Id Can not be Nagative.");<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">}<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">for(int i=0;i< nm.length();i++)<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">{<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">if(nm.charAt(i)>='0' && nm.charAt(i)<='9')<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">{<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">throw new Bname("Not a perfect String");<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">}<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">}<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"><o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"><o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"><o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">if(pr < 0){<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<br /></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> <o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> throw new PrOnly("Only supported for Price 0 to 10");<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<br /></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> }else{<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"><o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">this.bid=no;<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">this.bname=nm;<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">this.bprice=pr;<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"><o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> }<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<br /></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">}<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"><o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"><o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">public static void main(String[] args) throws NonNegId,PrOnly<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">{<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"><o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><span class="apple-converted-space"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> try{<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<br /></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">Book b= new Book(1,"ja0va",120.5);<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> <o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> }catch(NonNegId eid){<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<br /></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> System.out.println(eid); <o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> <o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<br /></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> }catch(PrOnly eprice){<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<br /></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> System.out.println(eprice); <o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<br /></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> }catch(Bname enm){<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<br /></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> System.out.println(enm); <o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<br /></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> }finally{<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<br /></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> System.out.println("Releasing resources"); <o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<br /></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> }<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<br /></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> }<o:p></o:p></span></b></div>
</td></tr>
<tr><td style="background: rgb(217, 226, 243); border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<span class="apple-tab-span"><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"> </span></b></span><b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;"><o:p></o:p></span></b></div>
</td></tr>
<tr><td style="border-bottom: 1pt solid rgb(142, 170, 219); border-image: initial; border-left: 1pt solid rgb(142, 170, 219); border-right: 1pt solid rgb(142, 170, 219); border-top: none; padding: 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="line-height: 18.4px; margin: 0in 0in 0.0001pt;">
<b><span style="background: yellow; color: #00b050; font-size: 13.5pt; line-height: 20.7px;">}</span></b><b><span style="color: #00b050; font-size: 13.5pt; line-height: 20.7px;"><o:p></o:p></span></b></div>
</td></tr>
</tbody></table>
<div style="margin: 0in 0in 0.0001pt;">
<br /></div>
<br />
<div class="MsoNormal">
<br /></div>
</div>
</div>
Patelwalahttp://www.blogger.com/profile/12814606641177309811noreply@blogger.com0tag:blogger.com,1999:blog-5058481685038320696.post-3623747811570975282016-10-13T02:00:00.000-07:002016-10-13T02:00:00.195-07:00method overriding in java ?<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<h2 style="text-align: center;">
<span style="color: red; font-family: "courier new" , "courier" , monospace; text-align: justify;"><span style="font-size: large;">What do you mean by method overriding? Why it is </span></span><span style="color: red; font-family: "courier new" , "courier" , monospace; font-size: large;">needed? Explain the uses of this and super keyword with </span><span style="color: red; font-family: "courier new" , "courier" , monospace; font-size: large;">example.</span></h2>
<hr />
<span style="color: purple; font-family: Courier New, Courier, monospace; font-size: large;"><div style="text-align: justify;">
<br /></div>
</span><br />
<div>
<div style="text-align: justify;">
<span style="color: purple; font-family: Courier New, Courier, monospace; font-size: large;">The benefit of overriding is: ability to define a behavior that's specific to the subclass type, which means a sub class can implement a parent class method based on its requirement.</span></div>
<div style="text-align: justify;">
<span style="color: purple; font-family: Courier New, Courier, monospace; font-size: large;"><br /></span></div>
<div style="text-align: justify;">
<span style="color: purple; font-family: Courier New, Courier, monospace; font-size: large;">In object-oriented terms, overriding means to override the functionality of an existing method</span></div>
<div style="text-align: justify;">
<span style="color: purple; font-family: Courier New, Courier, monospace; font-size: large;"><br /></span></div>
<div style="text-align: justify;">
<span style="color: purple; font-family: Courier New, Courier, monospace; font-size: large;"><b>Method Overriding:</b></span></div>
<div style="text-align: justify;">
<span style="color: purple; font-family: Courier New, Courier, monospace; font-size: large;"><br /></span></div>
<div style="text-align: justify;">
<span style="color: purple; font-family: Courier New, Courier, monospace; font-size: large;">Method overriding means have same signature but with different implementation.</span></div>
<div style="text-align: justify;">
<span style="color: purple; font-family: Courier New, Courier, monospace; font-size: large;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Courier New, Courier, monospace; font-size: large;"><span style="color: purple;">If subclass<b> (child class)</b> has same method as declared in the parent class, it is known as method overriding in java</span>.</span></div>
</div>
<div style="text-align: justify;">
<span style="font-family: Courier New, Courier, monospace; font-size: large;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Courier New, Courier, monospace; font-size: large;"><div style="color: purple;">
In other words, if sub class provides the specific implementation of a method that is already provided by its super class. it is known as</div>
<div style="color: purple;">
<br /></div>
<div style="color: purple;">
<b>method overriding.</b></div>
<div style="color: purple;">
<b><br /></b></div>
<div style="color: purple;">
<b>Super class reference can be used to refer to a subclass object.</b> The dynamic method dispatch mechanism in java selects the appropriate version of an overridden method to execute based on the class of the executing object, not the type of a variable that references that object. </div>
<div style="color: purple;">
<br /></div>
<div style="color: purple;">
<b>Usage of java Method Overriding:</b></div>
<div style="color: purple;">
<br /></div>
<div style="color: purple;">
Method overriding is used to provide specific implementation of the method that is already provided by its super class. </div>
<div style="color: purple;">
<br /></div>
<div style="color: purple;">
Method overriding is used for <b>runtime polymorphism.</b></div>
<div style="color: purple;">
<br /></div>
<div style="color: purple;">
<div>
<b>Why it is Needed?</b></div>
<div>
<br /></div>
<div>
Method overriding in object oriented programming is a language feature that all allows a subclass or child class to specific implementation of a method that is already provided by one of its super classes or parent classes.</div>
<div>
<br /></div>
<div>
The implementation in the subclass override(replaces)the implementation in the super class by providing a method that has same name, same parameters or signature and same return type as the method in the parent class.</div>
</div>
<div style="color: purple;">
<br /></div>
<div style="color: purple;">
<div>
<b>Super keyword:</b></div>
<div>
<br /></div>
<div>
super keyword in java is a reference variable that is used to refer parent class object super class an implicit keyword create by <b>JVM</b> and supply each and every java program for performing impotent in three places:</div>
</div>
<div style="color: purple;">
<b><br /></b></div>
<div style="color: purple;">
<div>
<b>---> At variable level</b></div>
<div>
<b>---> At method level</b></div>
<div>
<b>---> At constructor level</b></div>
<div>
<b><br /></b></div>
<div>
<b>Need of super keyword:</b></div>
<div>
<br /></div>
<div>
Whenever the derived class is inherits the base class features there is a possibility that base class features are similar to derived class features and JVM gets an ambiguity.</div>
<div>
<br /></div>
<div>
In order to different between base class features and derived class feature must be preceded by super keyword.</div>
</div>
<div style="color: purple;">
<br /></div>
<div style="color: purple;">
<div>
<b>Usage of java super Keyword:</b></div>
<div>
<br /></div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span>1. super is used to refer immediate parent class instance variable.</div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span>2. <b>super()</b> is used to invoke immediate parent class constructor.</div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span>3. super is used to invoke immediate parent class method.</div>
</div>
<div style="color: purple;">
<br /></div>
<div style="color: purple;">
<br /></div>
<div style="color: purple;">
<div>
<b>Real example of Java Method Overriding:</b></div>
<div>
<br /></div>
<div>
Consider a scenario, Bank is a class that provides functionality to get rate of interest. But, rate of interest varies according to banks. For example, SBI, ICICI and AXIS banks could provide 8%, 7% and 9% rate of interest.</div>
</div>
<div style="color: purple;">
<br /></div>
<div class="separator" style="clear: both; color: purple; text-align: left;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHEYvb1XCA84vE8THRjEC250vB7EPR_AHY9FEWhVUnlsH9kEeJX9EXAYko66R3R1xzh_jQwZR4lp2FvriXXfgxq1RVsYGeTD0biPczkadNa9u6ryC4jRbnd3W6hwbpPiz1nQoF7hWIW7IM/s1600/java.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="244" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHEYvb1XCA84vE8THRjEC250vB7EPR_AHY9FEWhVUnlsH9kEeJX9EXAYko66R3R1xzh_jQwZR4lp2FvriXXfgxq1RVsYGeTD0biPczkadNa9u6ryC4jRbnd3W6hwbpPiz1nQoF7hWIW7IM/s640/java.jpg" width="640" /></a></div>
<div style="color: purple;">
<br /></div>
<div style="color: purple;">
<br /></div>
<div style="color: purple;">
<br /></div>
<div>
<div>
<b><span style="color: blue;">Example:</span></b></div>
<div>
<b><span style="color: blue;"><br /></span></b></div>
<div>
<b><span style="color: blue;">class A</span></b></div>
<div>
<b><span style="color: blue;">{</span></b></div>
<div>
<b><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>int i;</span></b></div>
<div>
<b><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>A()</span></b></div>
<div>
<b><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>{</span></b></div>
<div>
<b><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span></b></div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"><b><span style="color: blue;"> </span></b></span></div>
<div>
<b><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>A(int i)</span></b></div>
<div>
<b><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>{</span></b></div>
<div>
<b><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>this.i=i;</span></b></div>
<div>
<b><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span></b></div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"><b><span style="color: blue;"> </span></b></span></div>
<div>
<b><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>void print()</span></b></div>
<div>
<b><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>{</span></b></div>
<div>
<b><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println(this.i);</span></b></div>
<div>
<b><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span></b></div>
<div>
<b><span style="color: blue;">}</span></b></div>
<div>
<b><span style="color: blue;">class B extends A</span></b></div>
<div>
<b><span style="color: blue;">{</span></b></div>
<div>
<b><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>int k;</span></b></div>
<div>
<b><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>B(int k)</span></b></div>
<div>
<b><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>{</span></b></div>
<div>
<b><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>super(k);</span></b></div>
<div>
<b><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>this.k=k;</span></b></div>
<div>
<b><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span></b></div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"><b><span style="color: blue;"> </span></b></span></div>
<div>
<b><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>B()</span></b></div>
<div>
<b><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>{</span></b></div>
<div>
<b><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>super.i=5;</span></b></div>
<div>
<b><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>this.k=5;</span></b></div>
<div>
<b><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span></b></div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"><b><span style="color: blue;"> </span></b></span></div>
<div>
<b><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>void print()</span></b></div>
<div>
<b><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>{</span></b></div>
<div>
<b><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>super.print();</span></b></div>
<div>
<b><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println(this.k);</span></b></div>
<div>
<b><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span></b></div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"><b><span style="color: blue;"> </span></b></span></div>
<div>
<b><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>public static void main(String s[])</span></b></div>
<div>
<b><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>{</span></b></div>
<div>
<b><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>B b1=new B(50);</span></b></div>
<div>
<b><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>b1.print();</span></b></div>
<div>
<b><span style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span></b></div>
<div>
<b><span style="color: blue;">}</span></b></div>
<div>
<b><span style="color: blue;"><br /></span></b></div>
<div>
<b><span style="color: blue;"><br /></span></b></div>
<div>
<b><span style="color: blue;">OutPut:</span></b></div>
<div>
<b><span style="color: blue;">50</span></b></div>
<div>
<b><span style="color: blue;">50</span></b></div>
</div>
</span></div>
</div>
Patelwalahttp://www.blogger.com/profile/12814606641177309811noreply@blogger.com0tag:blogger.com,1999:blog-5058481685038320696.post-15976045494025209582016-10-12T01:30:00.000-07:002016-10-12T01:30:20.970-07:00Explain the use of finalize method with Example<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<h2 style="text-align: center;">
<b><span style="background-color: #6aa84f; color: purple; font-family: "courier new" , "courier" , monospace; font-size: x-large;"> Explain the use of </span></b></h2>
<h2 style="text-align: center;">
<b><span style="background-color: #6aa84f; color: purple; font-family: "courier new" , "courier" , monospace; font-size: x-large;"> finalize method with Example </span></b></h2>
<br class="Apple-interchange-newline" />
<hr />
<span style="font-family: Courier New, Courier, monospace; font-size: large;"><br /></span><div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b>Finalize() Method:</b></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><br /></span></div>
<div style="text-align: left;">
<ul>
<li><span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;">When you will need to do some actions when an object is destroyed by <b>garbage collection.</b></span></li>
<li><span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;">For example when your program is using some <b>non-java resources</b>, you have to free the memory for these resources.</span></li>
<li><span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;">This process is known as <b>finalization.</b></span></li>
<li><span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;">The finalization is done by the <b>finalize() method.</b></span></li>
</ul>
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8VRCH3uC9lwJPLbWhCllVVxq_nqDQKpzo4fDMh9vsoKC8p0AR4Ib6vneg3CZH5i6VVUhcLykpBRLvy9GHLCRPCefnQy0udSwYiL5X0no0lSXvrZpVnsVbcCdcfLbmeYQhqrjZM8yYW7Ud/s1600/java+Garbage+collection.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8VRCH3uC9lwJPLbWhCllVVxq_nqDQKpzo4fDMh9vsoKC8p0AR4Ib6vneg3CZH5i6VVUhcLykpBRLvy9GHLCRPCefnQy0udSwYiL5X0no0lSXvrZpVnsVbcCdcfLbmeYQhqrjZM8yYW7Ud/s320/java+Garbage+collection.jpg" width="206" /></a></div>
<div style="text-align: left;">
<span class="Apple-tab-span" style="white-space: pre;"><span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><br /></span></span></div>
<div style="text-align: left;">
<span class="Apple-tab-span" style="white-space: pre;"><span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><br /></span></span></div>
<div style="text-align: left;">
<span class="Apple-tab-span" style="white-space: pre;"><span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"> </span></span></div>
<div style="text-align: left;">
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b>Syntax :</b></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><br /></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><span class="Apple-tab-span" style="white-space: pre;"> </span><b>protected void finalize()</b></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>{</b></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>//statements to be executed</b></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>}</b></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><br /></span></div>
<div style="text-align: left;">
<ul>
<li><span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;">Finalize() method <b>does not return any value</b> so the <b>return type is void.</b></span></li>
<li><span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;">The finalize() mehod is <b>called just before when java runtime system perform garbage collection.</b></span></li>
<li><span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b>Finalize</b> method is <b>object class</b> method, so applied all the class.</span></li>
</ul>
</div>
<div style="text-align: left;">
<span class="Apple-tab-span" style="white-space: pre;"><span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"> </span></span></div>
<div style="text-align: left;">
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b>Example :</b></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b><br /></b></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b>class Demo</b></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b>{</b></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>static int cnt=0;</b></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>protected void finalize()</b></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>{</b></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>cnt++;</b></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println</b></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b> ("Finalize"+ cnt);</b></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>}</b></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>public static void main(String[] a)</b></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>{</b></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>int i;</b></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>Demo obj[] = </b></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b> new Demo[10000000];</b></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>for (i=0;i<10000000;i++)</b></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>{</b></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>obj[i]s=new Demo();</b></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>}</b></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>for (i=0;i<10000000;i++)</b></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>{</b></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>obj = null;</b></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>}</b></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>System.gc();</b></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>}<span class="Apple-tab-span" style="white-space: pre;"> </span></b></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b>}</b></span></div>
</div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b><br /></b></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b><br /></b></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b><br /></b></span></div>
<div>
<h3 class="med _wI _kk" style="background-color: white; color: grey; font-family: arial, sans-serif; font-size: 18px; font-weight: normal; height: auto; line-height: 18px; margin: 0px; padding: 0px 0px 7px;">
Searches related to finalize method in java</h3>
<div class="card-section" style="background-color: white; color: #222222; font-family: arial, sans-serif;">
<div class="brs_col" style="display: inline-block; float: left; font-size: 13px; line-height: 20px; margin-top: -1px; padding-bottom: 1px; padding-right: 16px;">
<div class="_e4b" style="padding-top: 5px;">
<a href="https://www.google.co.in/search?bih=589&biw=1366&espv=2&q=finalize+method+in+java+with+example&sa=X&ved=0ahUKEwi9lYHFuNLPAhVC0WMKHabFABoQ1QIIfygA" style="color: #660099; cursor: pointer; text-decoration: none;">finalize method in java <b>with example</b></a></div>
<div class="_e4b" style="padding-top: 5px;">
<a href="https://www.google.co.in/search?bih=589&biw=1366&espv=2&q=finalize+method+in+java+with+example+program&sa=X&ved=0ahUKEwi9lYHFuNLPAhVC0WMKHabFABoQ1QIIgAEoAQ" style="color: #660099; cursor: pointer; text-decoration: none;">finalize method in java <b>with example program</b></a></div>
<div class="_e4b" style="padding-top: 5px;">
<a href="https://www.google.co.in/search?bih=589&biw=1366&espv=2&q=finalize+method+in+java+with+simple+example&sa=X&ved=0ahUKEwi9lYHFuNLPAhVC0WMKHabFABoQ1QIIgQEoAg" style="color: #660099; cursor: pointer; text-decoration: none;">finalize method in java <b>with simple example</b></a></div>
<div class="_e4b" style="padding-top: 5px;">
<a href="https://www.google.co.in/search?bih=589&biw=1366&espv=2&q=finalize+method+in+java+wiki&sa=X&ved=0ahUKEwi9lYHFuNLPAhVC0WMKHabFABoQ1QIIggEoAw" style="color: #660099; cursor: pointer; text-decoration: none;">finalize method in java <b>wiki</b></a></div>
</div>
<div class="brs_col" style="display: inline-block; float: left; font-size: 13px; line-height: 20px; margin-top: -1px; padding-bottom: 1px; padding-right: 16px;">
<div class="_e4b" style="padding-top: 5px;">
<a href="https://www.google.co.in/search?bih=589&biw=1366&espv=2&q=final+keyword+in+java&sa=X&ved=0ahUKEwi9lYHFuNLPAhVC0WMKHabFABoQ1QIIgwEoBA" style="color: #660099; cursor: pointer; text-decoration: none;"><b>final keyword</b> in java</a></div>
<div class="_e4b" style="padding-top: 5px;">
<a href="https://www.google.co.in/search?bih=589&biw=1366&espv=2&q=finalize+method+in+java+pdf&sa=X&ved=0ahUKEwi9lYHFuNLPAhVC0WMKHabFABoQ1QIIhAEoBQ" style="color: #660099; cursor: pointer; text-decoration: none;">finalize method in java <b>pdf</b></a></div>
<div class="_e4b" style="padding-top: 5px;">
<a href="https://www.google.co.in/search?bih=589&biw=1366&espv=2&q=finalize+method+in+java+javatpoint&sa=X&ved=0ahUKEwi9lYHFuNLPAhVC0WMKHabFABoQ1QIIhQEoBg" style="color: #660099; cursor: pointer; text-decoration: none;">finalize method in java <b>javatpoint</b></a></div>
<div class="_e4b" style="padding-top: 5px;">
<a href="https://www.google.co.in/search?bih=589&biw=1366&espv=2&q=finalize+method+in+java+oracle&sa=X&ved=0ahUKEwi9lYHFuNLPAhVC0WMKHabFABoQ1QIIhgEoBw" style="color: #660099; cursor: pointer; text-decoration: none;">finalize method in java <b>oracle</b></a></div>
</div>
</div>
</div>
</div>
Patelwalahttp://www.blogger.com/profile/12814606641177309811noreply@blogger.com0tag:blogger.com,1999:blog-5058481685038320696.post-86472893602759755712016-10-11T01:52:00.002-07:002016-10-11T02:03:02.170-07:00Java Pass By Value and Pass By Reference<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<h2 style="text-align: center;">
<span style="background-color: orange; color: blue; font-family: "courier new" , "courier" , monospace; font-size: x-large;"> Java Pass By Value and Pass By Reference </span></h2>
<hr />
<br />
<div>
<br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b>Pass by Value</b></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><br /></span>
<br />
<div style="text-align: justify;">
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><span class="Apple-tab-span" style="white-space: pre;"> </span>In java we have a pass by value, when we use primitive type as parameters then it is a pass by value. Thus, what occurs to the parameter that receives the argument has no affect outside the method.</span></div>
<div style="text-align: justify;">
<span class="Apple-tab-span" style="white-space: pre;"><span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"> </span></span></div>
<div style="text-align: justify;">
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><span class="Apple-tab-span" style="white-space: pre;"> </span>This method is copy of the passed-in variable is copied into the argument. Any changes to the argument do not affect the original one.</span></div>
<div style="text-align: justify;">
<span class="Apple-tab-span" style="white-space: pre;"><span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"> </span></span></div>
<div style="text-align: justify;">
<span style="color: purple;"><span style="font-family: "courier new" , "courier" , monospace; font-size: large;"><span class="Apple-tab-span" style="white-space: pre;"> </span>Actual parameter expressions that are passed to a method are evaluated and a </span><span style="font-family: "courier new" , "courier" , monospace; font-size: large;">value is derived. Then this value is stored in a location and then it becomes the formal </span><span style="font-family: "courier new" , "courier" , monospace; font-size: large;">parameter to the invoked method. This mechanism is called pass by value and Java </span><span style="font-family: "courier new" , "courier" , monospace; font-size: large;">uses it.</span></span></div>
<span class="Apple-tab-span" style="white-space: pre;"><span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"> </span></span><br />
<span class="Apple-tab-span" style="white-space: pre;"><span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"> </span></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidOvUoQgbtFwTiuhPg64jZvaoVddNWfwLhm265syA5sbiV9d0mYVx_-TxUKttFtYRXMjMk_S7nSoF7wiu7Nj3-GSrjI7hh5vh9rdUsqMqfpT20SwHri3q52ezv_6HVPIIOTRUbAVhVHiaB/s1600/QdcG2.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="215" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidOvUoQgbtFwTiuhPg64jZvaoVddNWfwLhm265syA5sbiV9d0mYVx_-TxUKttFtYRXMjMk_S7nSoF7wiu7Nj3-GSrjI7hh5vh9rdUsqMqfpT20SwHri3q52ezv_6HVPIIOTRUbAVhVHiaB/s400/QdcG2.gif" width="400" /></a></div>
<span class="Apple-tab-span" style="white-space: pre;"><span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><br /></span></span>
<span class="Apple-tab-span" style="white-space: pre;"><span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"> </span></span><br />
<span class="Apple-tab-span" style="white-space: pre;"><span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><br /></span></span>
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b>Pass by Reference</b></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><br /></span>
<br />
<div style="text-align: justify;">
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><span class="Apple-tab-span" style="white-space: pre;"> </span>In java we use the reference type as parameters in a method then it become a pass by value for the reference value. The reference type refer to an object, so when we use the reference data type as a parameter, a copy of the reference value is made available to the invoked method, which enables the invoked method to work on the same object as the one reference by the invoking method.</span></div>
<div style="text-align: justify;">
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><br /></span></div>
<div style="text-align: justify;">
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><span class="Apple-tab-span" style="white-space: pre;"> </span>In pass by reference, the formal parameter is just an alias to the actual parameter. It refers to the actual argument. Any changes done to the formal argument will reflect in actual argument .</span></div>
<span class="Apple-tab-span" style="white-space: pre;"><span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"> </span></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><br /></span>
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b>We have a method defined as follows:</b></span><br />
<span class="Apple-tab-span" style="white-space: pre;"><span style="font-family: "courier new" , "courier" , monospace; font-size: large;"> </span></span><br />
<b><span style="color: #20124d; font-family: "courier new" , "courier" , monospace; font-size: large;"> public void method(Account ac,int i)</span></b><br />
<b><span style="color: #20124d; font-family: "courier new" , "courier" , monospace; font-size: large;"> {</span></b><br />
<b><span style="color: #20124d; font-family: "courier new" , "courier" , monospace; font-size: large;"><span class="Apple-tab-span" style="white-space: pre;"> </span> i+=100;</span></b><br />
<b><span style="color: #20124d; font-family: "courier new" , "courier" , monospace; font-size: large;"><span class="Apple-tab-span" style="white-space: pre;"> </span> ac.deposit(10000);</span></b><br />
<b><span style="color: #20124d; font-family: "courier new" , "courier" , monospace; font-size: large;"><span class="Apple-tab-span" style="white-space: pre;"> </span> i+=100;</span></b><br />
<b><span style="color: #20124d; font-family: "courier new" , "courier" , monospace; font-size: large;"><br /></span></b>
<div style="text-align: center;">
<div style="text-align: left;">
<b><span style="color: #20124d; font-family: "courier new" , "courier" , monospace; font-size: large;"><span class="Apple-tab-span" style="white-space: pre;"> </span> ac = new CurrentAccount</span></b></div>
<div style="text-align: left;">
<b><span style="color: #20124d; font-family: "courier new" , "courier" , monospace; font-size: large;"> (1005, “tom”,4000);</span></b></div>
<div style="text-align: left;">
<b><span style="color: #20124d; font-family: "courier new" , "courier" , monospace; font-size: large;"><br /></span></b></div>
</div>
<b><span style="color: #20124d; font-family: "courier new" , "courier" , monospace; font-size: large;"><span class="Apple-tab-span" style="white-space: pre;"> </span> i+=100;</span></b><br />
<b><span style="color: #20124d; font-family: "courier new" , "courier" , monospace; font-size: large;"><span class="Apple-tab-span" style="white-space: pre;"> </span> ac.deposit(3000);</span></b><br />
<b><span style="color: #20124d; font-family: "courier new" , "courier" , monospace; font-size: large;"> }<span class="Apple-tab-span" style="white-space: pre;"> </span></span></b><br />
<span style="color: purple;"><b><br /></b>
</span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;">This method is beging used from another code as follows:</span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><br /></span>
<br />
<div style="text-align: justify;">
<div style="text-align: right;">
<div style="text-align: left;">
<span style="color: purple;"><span style="font-family: "courier new" , "courier" , monospace; font-size: large;"><span class="Apple-tab-span" style="white-space: pre;"> </span><b>1 Account ac = </b></span></span></div>
<div style="text-align: left;">
<span style="color: purple;"><span style="font-family: "courier new" , "courier" , monospace; font-size: large;"><b> new CurrentAccount</b></span><span style="font-family: "courier new" , "courier" , monospace; font-size: large;"><b>(1005, “tom”, 2000);</b></span></span></div>
</div>
</div>
<div style="text-align: justify;">
<div style="text-align: left;">
<span style="font-family: "courier new" , "courier" , monospace; font-size: large;"><span style="color: purple;"><b><br /></b></span></span></div>
</div>
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>2 int a = 100;</b></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b><br /></b></span>
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>3 ac.deposit(3000);</b></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b><br /></b></span>
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>4 method(ac,a);</b></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b><br /></b></span>
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>5 System.out.println</b></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b> (ac.getBalance()+”, “+a);</b></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><br /></span>
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><span class="Apple-tab-span" style="white-space: pre;"> </span><b>It prints “15000, 100”</b></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><br /></span>
<br />
<div style="text-align: justify;">
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><span class="Apple-tab-span" style="white-space: pre;"> </span>Since primitive types are pass by value, the value of a is unchanged. In line 1, balance in Account(ac) is 2000, in line 3 balance in ac 5000. Now the reference to ac is copied to the parameter ac in method, so ac in method refers to the same object ac which is declared in line 1. In line 7, the balance would be 15000, now line 9 makes ac in the method ac in method refer to a new object, so the object refered by ac in line 1 is unaffected. line 9 would make the method loose the reference to the object which was passed as a parameter in line 4.</span></div>
<div style="text-align: justify;">
<span class="Apple-tab-span" style="white-space: pre;"><span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"> </span></span></div>
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b>Example:</b></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b><br /></b></span>
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b>class A</b></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b>{</b></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>void print(int i) </b></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b> //pass by value</b></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>{</b></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println(i);</b></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>}</b></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>public String toString()</b></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>{</b></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>return "Class A";</b></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>}</b></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>void toPrint(A obj) </b></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b> //pass by reference</b></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>{</b></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println(obj);</b></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>}</b></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b>}</b></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b>class B extends A</b></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b>{</b></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>public static void main(String[] str)</b></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>{</b></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>B obj = new B();</b></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>obj.print(5); </b></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b> //pass by value</b></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>obj.toPrint(new B()); </b></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b> //pass by reference</b></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b><span class="Apple-tab-span" style="white-space: pre;"> </span>}</b></span><br />
<span style="color: purple; font-family: "courier new" , "courier" , monospace; font-size: large;"><b>}<span class="Apple-tab-span" style="white-space: pre;"> </span></b></span><br />
<b><br /></b>
<b><br /></b>
<br />
<b></b>
<b><br /></b>
<b><br /></b>
<br />
<h3 class="med _wI _kk" style="background-color: white; color: grey; font-family: arial, sans-serif; font-size: 18px; font-weight: normal; height: auto; line-height: 18px; margin: 0px; padding: 0px 0px 7px;">
Searches related to java Pass By Value and Pass By Reference</h3>
<div class="card-section" style="background-color: white; color: #222222; font-family: arial, sans-serif;">
<div class="brs_col" style="display: inline-block; float: left; font-size: 13px; line-height: 20px; margin-top: -1px; padding-bottom: 1px; padding-right: 16px;">
<div class="_e4b" style="padding-top: 5px;">
<a href="https://www.google.co.in/search?bih=589&biw=1366&espv=2&q=java+pass+by+value+and+pass+by+reference+difference&sa=X&ved=0ahUKEwjV2JP2r9LPAhVC92MKHf8DBVsQ1QIIkgEoAA" style="color: #660099; cursor: pointer; text-decoration: none;">java pass by value and pass by reference <b>difference</b></a></div>
<div class="_e4b" style="padding-top: 5px;">
<a href="https://www.google.co.in/search?bih=589&biw=1366&espv=2&q=java+pass+by+value+and+pass+by+reference+example&sa=X&ved=0ahUKEwjV2JP2r9LPAhVC92MKHf8DBVsQ1QIIkwEoAQ" style="color: #660099; cursor: pointer; text-decoration: none;">java pass by value and pass by reference <b>example</b></a></div>
<div class="_e4b" style="padding-top: 5px;">
<a href="https://www.google.co.in/search?bih=589&biw=1366&espv=2&q=call+by+value+and+call+by+reference+in+java&sa=X&ved=0ahUKEwjV2JP2r9LPAhVC92MKHf8DBVsQ1QIIlAEoAg" style="color: #660099; cursor: pointer; text-decoration: none;"><b>call</b> by value and <b>call</b> by reference <b>in</b> java</a></div>
<div class="_e4b" style="padding-top: 5px;">
<a href="https://www.google.co.in/search?bih=589&biw=1366&espv=2&q=java+is+call+by+reference+or+value&sa=X&ved=0ahUKEwjV2JP2r9LPAhVC92MKHf8DBVsQ1QIIlQEoAw" style="color: #660099; cursor: pointer; text-decoration: none;">java <b>is call</b> by reference <b>or</b> value</a></div>
</div>
<div class="brs_col" style="display: inline-block; float: left; font-size: 13px; line-height: 20px; margin-top: -1px; padding-bottom: 1px; padding-right: 16px;">
<div class="_e4b" style="padding-top: 5px;">
<a href="https://www.google.co.in/search?bih=589&biw=1366&espv=2&q=difference+between+call+by+value+and+call+by+reference+in+java&sa=X&ved=0ahUKEwjV2JP2r9LPAhVC92MKHf8DBVsQ1QIIlgEoBA" style="color: #660099; cursor: pointer; text-decoration: none;"><b>difference between call</b> by value and <b>call</b> by reference <b>in</b> java</a></div>
<div class="_e4b" style="padding-top: 5px;">
<a href="https://www.google.co.in/search?bih=589&biw=1366&espv=2&q=java+call+by+reference+vs+call+by+value&sa=X&ved=0ahUKEwjV2JP2r9LPAhVC92MKHf8DBVsQ1QIIlwEoBQ" style="color: #660099; cursor: pointer; text-decoration: none;">java <b>call</b> by reference <b>vs call</b> by value</a></div>
<div class="_e4b" style="padding-top: 5px;">
<a href="https://www.google.co.in/search?bih=589&biw=1366&espv=2&q=difference+between+pass+by+value+and+pass+by+reference+in+java&sa=X&ved=0ahUKEwjV2JP2r9LPAhVC92MKHf8DBVsQ1QIImAEoBg" style="color: #660099; cursor: pointer; text-decoration: none;"><b>difference between</b> pass by value and pass by reference <b>in</b> java</a></div>
<div class="_e4b" style="padding-top: 5px;">
<a href="https://www.google.co.in/search?bih=589&biw=1366&espv=2&q=difference+between+pass+by+value+and+pass+by+reference+in+java+example&sa=X&ved=0ahUKEwjV2JP2r9LPAhVC92MKHf8DBVsQ1QIImQEoBw" style="color: #660099; cursor: pointer; text-decoration: none;"><b style="color: #660099; cursor: pointer; text-decoration: none;">difference between</b><span style="color: #660099;"><span style="cursor: pointer;"> pass by value and pass by reference </span></span><b style="color: #660099; cursor: pointer; text-decoration: none;">in</b><span style="color: #660099;"><span style="cursor: pointer;"> java </span></span><b style="color: #660099; cursor: pointer; text-decoration: none;">example</b></a></div>
<div>
<br /></div>
</div>
</div>
</div>
</div>
Patelwalahttp://www.blogger.com/profile/12814606641177309811noreply@blogger.com0tag:blogger.com,1999:blog-5058481685038320696.post-17118385292516154982016-10-01T08:25:00.001-07:002016-10-01T08:25:56.116-07:00Features of java<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: center;">
<span style="font-family: Courier New, Courier, monospace; font-size: x-large;">Features of java: </span></h2>
<div>
<br /></div>
<div>
<ul style="text-align: left;">
<li style="text-align: left;"><span style="color: blue; font-family: Courier New, Courier, monospace; font-size: large;"><b>The java programming language has a number of features that make it the language Of choice for most developers .The reason why java is so popular that it is object oriented platform independent does not use pointers has support for multi-threading has a robust exception handling mechanism has good security. Features allows us to create applets and Servlets for use on the web.</b></span><span style="font-family: Courier New, Courier, monospace; font-size: x-large;"> </span></li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzU3FHalKz7pnBU5FL79aijOp7FV0-Ap3q4eR-wvW5HkDSvU4epSDRiI7e_5nCWSJUzytGnyA5FHIwCynUVYe04EaHmhUmkWuNi86lhDget1JiLLE3KP4RP3JXLYOGW_Ynecgt6n9FSpRD/s1600/features+of+java.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="326" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzU3FHalKz7pnBU5FL79aijOp7FV0-Ap3q4eR-wvW5HkDSvU4epSDRiI7e_5nCWSJUzytGnyA5FHIwCynUVYe04EaHmhUmkWuNi86lhDget1JiLLE3KP4RP3JXLYOGW_Ynecgt6n9FSpRD/s400/features+of+java.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><b style="background-color: white;">1. Compiled and interpreted:</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> A computer language is either compiled or interpreted.</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> Java combines both features therefore it is two stage system.</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> First java compiler translate source code into byte code and byte code is not machine</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b>instruction therefore interpreter translate byte code into machine code.</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><b style="background-color: white;">2. Platform independent and interpreted:</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> Java programs can be easily moved from one computer system to another system.</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> If you upgrade in any operating system then it will not affect in the java programs.</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><b>3. Object oriented:</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> Java is true object-oriented language.</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> Almost everything in java is an object.</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> Java is an extensive set of classes which are arranged in packages and we can use it by</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b>inheritance.</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><b>4. Robust and secure:</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> Java a robust language because it provide many safeguards to ensure reliable code.</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> It will check data type compile time and runtime.</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> Security becomes an important point for a java programming on internet.</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><b>5. Distributed:</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> Java is designed as a distributed language for creating application on networks.</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> It has the ability to share both data and programs.</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> In java multiple programmers at multiple remote locations to collaborate and work</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b>together on a single project.</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><b>6. Simple small and familiar:</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> Java is a small and simple language.</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> Many features of C and C++ are not come in java so it become small.</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> For example, java does not use pointers, operator overloading, preprocessor header</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b>files, go to statement, multiple inheritance.</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> Java has more feature of C and C++ so that java is familiar to us.</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><b>7. Multithreaded and interactive:</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> Multithreaded means handling multiple tasks simultaneously.</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> Java support multithreaded means we need not wait for the application to finish one</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b>task before beginning another task.</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> For example, we can listen to an audio clip while scrolling a page.</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> This improves interactive program.</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><b>8. High-performance:</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> Java architecture is defined to reduce error and amount of time.</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> So that java gives high performance.</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><b>9. Dynamic and extensible:</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> Java is dynamic language because it is capable of dynamically linking a new class</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b>libraries, method and classes.</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> Java program support functions written in other language such as C and C++.</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> These functions are known as native methods.</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b>10.Monitoring and manageability:</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> Java supports a number of APIs, such as JVM Monitoring and management interface.</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> It manages java programs.</b></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<h3 style="text-align: left;">
<span style="font-size: large;"><span style="font-family: Courier New, Courier, monospace;"><b><br /></b></span><span style="color: blue; font-family: Courier New, Courier, monospace;"><b>Why java is so popular?</b></span></span></h3>
<div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div>
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b>The reason why java is so popular is that it is :</b></span></div>
<div>
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div>
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> object-oriented</b></span></div>
<div>
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div>
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> platform independent</b></span></div>
<div>
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div>
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> Does not use pointer</b></span></div>
<div>
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div>
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> support multi-threading</b></span></div>
<div>
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div>
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> robust exception handling mechanism</b></span></div>
<div>
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div>
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> Full network support</b></span></div>
<div>
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div>
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> Good security</b></span></div>
<div>
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div>
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b> Allows you to create applets and servlets for use on the web.</b></span></div>
<div>
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b><br /></b></span></div>
<div>
<span style="color: purple; font-family: Courier New, Courier, monospace;"><b>However, most importantly java is popular because Java is Easy</b></span></div>
</div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: x-large;"><br /></span></div>
</div>
</div>
Patelwalahttp://www.blogger.com/profile/12814606641177309811noreply@blogger.com0tag:blogger.com,1999:blog-5058481685038320696.post-66406834214999884552016-09-30T08:27:00.000-07:002016-09-30T08:30:52.330-07:00 Initialize Blocks and Class Initialize Java<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: center;">
<b><span style="color: blue; font-family: "courier new" , "courier" , monospace; font-size: x-large;"> Discuss Initialize Blocks and Class Initialize blocks.</span></b></h2>
<br />
<br />
<h3 style="text-align: left;">
<span style="color: blue; font-family: "courier new" , "courier" , monospace; font-size: large;">First of all, there are two types of initialization blocks: </span></h3>
<br />
<h4 style="text-align: left;">
<span style="font-family: "courier new" , "courier" , monospace;"><i>1. Instance Initialization Blocks (Initialization Blocks)<br />2. Static Initialization Blocks (Class Initialization Blocks). </i></span></h4>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZP98r-li8Wrx0ZhZmgT1gmUjeHS1_tmZT9VsvM2ep5v0T8Mr6i4P4Ke2Bh77lIaPkEVyJAns9vTIt5b2zyyaxMghVNazCYxhrirmiiFcMxQkgII2OvxwZ8m3QN2a-bCxFykMgJCofksWF/s1600/java.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="83" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZP98r-li8Wrx0ZhZmgT1gmUjeHS1_tmZT9VsvM2ep5v0T8Mr6i4P4Ke2Bh77lIaPkEVyJAns9vTIt5b2zyyaxMghVNazCYxhrirmiiFcMxQkgII2OvxwZ8m3QN2a-bCxFykMgJCofksWF/s320/java.png" width="320" /></a></div>
<br />
<br />
<h3 style="text-align: left;">
<span style="color: purple; font-family: "courier new" , "courier" , monospace;">1. Initializer block</span></h3>
<br />
<div style="text-align: justify;">
<span style="color: blue; font-family: "courier new" , "courier" , monospace;">In a class definition, we can have a member block with no name. Such a block is known as the initializer block.</span></div>
<div style="text-align: justify;">
<span style="color: blue; font-family: "courier new" , "courier" , monospace;"><br /></span></div>
<div style="text-align: justify;">
<span style="color: blue; font-family: "courier new" , "courier" , monospace;">An initializer block is never invoked by any application directly since it does not have any name. However, it is always invoked on an instance as soon as it is allocated.</span></div>
<div style="text-align: justify;">
<span style="color: blue; font-family: "courier new" , "courier" , monospace;"><br /></span></div>
<div style="text-align: justify;">
<span style="color: blue; font-family: "courier new" , "courier" , monospace;">It is invoked just before the constructor is invoked on the instance. </span></div>
<div style="text-align: justify;">
<span style="color: blue; font-family: "courier new" , "courier" , monospace;"><br /></span></div>
<div style="text-align: justify;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0in;">
<br /></div>
<br />
<table border="1" cellpadding="0" cellspacing="0" class="MsoTable15Grid6ColorfulAccent5" style="border-collapse: collapse; border: none; mso-border-alt: solid #8EAADB .5pt; mso-border-themecolor: accent5; mso-border-themetint: 153; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-yfti-tbllook: 1184;">
<tbody>
<tr>
<td style="border-bottom: solid #8EAADB 1.5pt; border: solid #8EAADB 1.0pt; mso-border-alt: solid #8EAADB .5pt; mso-border-bottom-alt: solid #8EAADB 1.5pt; mso-border-bottom-themecolor: accent5; mso-border-bottom-themecolor: accent5; mso-border-bottom-themetint: 153; mso-border-bottom-themetint: 153; mso-border-themecolor: accent5; mso-border-themecolor: accent5; mso-border-themetint: 153; mso-border-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="margin-bottom: .0001pt; margin: 0in; mso-yfti-cnfc: 5;">
<span style="color: blue; font-size: 13.5pt;">Rectangle(int l, int w)</span><b><span style="font-size: 13.5pt;"><o:p></o:p></span></b></div>
</td>
</tr>
<tr>
<td style="background: #D9E2F3; border-top: none; border: solid #8EAADB 1.0pt; mso-background-themecolor: accent5; mso-background-themetint: 51; mso-border-alt: solid #8EAADB .5pt; mso-border-themecolor: accent5; mso-border-themecolor: accent5; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #8EAADB .5pt; mso-border-top-themecolor: accent5; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="margin-bottom: .0001pt; margin: 0in; mso-yfti-cnfc: 68;">
<span style="color: blue; font-size: 13.5pt;">{</span><b><span style="font-size: 13.5pt;"><o:p></o:p></span></b></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid #8EAADB 1.0pt; mso-border-alt: solid #8EAADB .5pt; mso-border-themecolor: accent5; mso-border-themecolor: accent5; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #8EAADB .5pt; mso-border-top-themecolor: accent5; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="margin-bottom: .0001pt; margin: 0in; mso-yfti-cnfc: 4;">
<span style="color: blue; font-size: 13.5pt;"> // remove the increment of count
from the constructor</span><b><span style="font-size: 13.5pt;"><o:p></o:p></span></b></div>
</td>
</tr>
<tr>
<td style="background: #D9E2F3; border-top: none; border: solid #8EAADB 1.0pt; mso-background-themecolor: accent5; mso-background-themetint: 51; mso-border-alt: solid #8EAADB .5pt; mso-border-themecolor: accent5; mso-border-themecolor: accent5; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #8EAADB .5pt; mso-border-top-themecolor: accent5; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="margin-bottom: .0001pt; margin: 0in; mso-yfti-cnfc: 68;">
<span style="color: blue; font-size: 13.5pt;">setDimensions(l, w);</span><b><span style="font-size: 13.5pt;"><o:p></o:p></span></b></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid #8EAADB 1.0pt; mso-border-alt: solid #8EAADB .5pt; mso-border-themecolor: accent5; mso-border-themecolor: accent5; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #8EAADB .5pt; mso-border-top-themecolor: accent5; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="margin-bottom: .0001pt; margin: 0in; mso-yfti-cnfc: 4;">
<span style="color: blue; font-size: 13.5pt;">}</span><b><span style="font-size: 13.5pt;"><o:p></o:p></span></b></div>
</td>
</tr>
<tr>
<td style="background: #D9E2F3; border-top: none; border: solid #8EAADB 1.0pt; mso-background-themecolor: accent5; mso-background-themetint: 51; mso-border-alt: solid #8EAADB .5pt; mso-border-themecolor: accent5; mso-border-themecolor: accent5; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #8EAADB .5pt; mso-border-top-themecolor: accent5; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="margin-bottom: .0001pt; margin: 0in; mso-yfti-cnfc: 68;">
<span style="color: blue; font-size: 13.5pt;">…</span><b><span style="font-size: 13.5pt;"><o:p></o:p></span></b></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid #8EAADB 1.0pt; mso-border-alt: solid #8EAADB .5pt; mso-border-themecolor: accent5; mso-border-themecolor: accent5; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #8EAADB .5pt; mso-border-top-themecolor: accent5; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="margin-bottom: .0001pt; margin: 0in; mso-yfti-cnfc: 4;">
<span style="color: blue; font-size: 13.5pt;">{</span><b><span style="font-size: 13.5pt;"><o:p></o:p></span></b></div>
</td>
</tr>
<tr>
<td style="background: #D9E2F3; border-top: none; border: solid #8EAADB 1.0pt; mso-background-themecolor: accent5; mso-background-themetint: 51; mso-border-alt: solid #8EAADB .5pt; mso-border-themecolor: accent5; mso-border-themecolor: accent5; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #8EAADB .5pt; mso-border-top-themecolor: accent5; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="margin-bottom: .0001pt; margin: 0in; mso-yfti-cnfc: 68;">
<span style="color: blue; font-size: 13.5pt;"> // initializer block, executed
whenever any instance is</span><b><span style="font-size: 13.5pt;"><o:p></o:p></span></b></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid #8EAADB 1.0pt; mso-border-alt: solid #8EAADB .5pt; mso-border-themecolor: accent5; mso-border-themecolor: accent5; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #8EAADB .5pt; mso-border-top-themecolor: accent5; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="margin-bottom: .0001pt; margin: 0in; mso-yfti-cnfc: 4;">
<span style="color: blue; font-size: 13.5pt;">created.</span><b><span style="font-size: 13.5pt;"><o:p></o:p></span></b></div>
</td>
</tr>
<tr>
<td style="background: #D9E2F3; border-top: none; border: solid #8EAADB 1.0pt; mso-background-themecolor: accent5; mso-background-themetint: 51; mso-border-alt: solid #8EAADB .5pt; mso-border-themecolor: accent5; mso-border-themecolor: accent5; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #8EAADB .5pt; mso-border-top-themecolor: accent5; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="margin-bottom: .0001pt; margin: 0in; mso-yfti-cnfc: 68;">
<span style="color: blue; font-size: 13.5pt;">count++;</span><b><span style="font-size: 13.5pt;"><o:p></o:p></span></b></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid #8EAADB 1.0pt; mso-border-alt: solid #8EAADB .5pt; mso-border-themecolor: accent5; mso-border-themecolor: accent5; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #8EAADB .5pt; mso-border-top-themecolor: accent5; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="margin-bottom: .0001pt; margin: 0in; mso-yfti-cnfc: 4;">
<span style="color: blue; font-size: 13.5pt;"> } </span><b><span style="font-size: 13.5pt;"><o:p></o:p></span></b></div>
</td>
</tr>
</tbody></table>
<div style="text-align: justify;">
<span style="color: blue;"><b><br /></b></span></div>
<div style="text-align: justify;">
<span style="color: blue;"><b><br /></b></span></div>
<div style="text-align: justify;">
<span style="color: blue; font-family: "courier new" , "courier" , monospace;">The initializer block in a class is invoked whenever any of the constructor for the class is invoked. This block is always executed before the constructor code is executed.</span></div>
<div style="text-align: justify;">
<span style="color: blue; font-family: "courier new" , "courier" , monospace;"><br /></span></div>
<div style="text-align: justify;">
<span style="color: blue; font-family: "courier new" , "courier" , monospace;">The initialization process for an instance is thus executed in the following sequence. Whenever any constructor is invoked with the new operator to create a new instance, first the space is allocated for the instance depending on the instance variables declared in the class.</span></div>
<div style="text-align: justify;">
<span style="color: blue; font-family: "courier new" , "courier" , monospace;"><br /></span></div>
<div style="text-align: justify;">
<span style="color: blue; font-family: "courier new" , "courier" , monospace;">When this space is allocated, its instance variables have the default initial valueaccording to the type of variable, i.e. numeric types will be 0, boolean types will be false and reference types will be null; now in case the instance variable declaration has an assignment, then such an assignment will be executed on the instance; for example, in caseof the Rectangle class, if the instance variable length were declared as</span></div>
<div style="text-align: justify;">
<span style="color: blue; font-family: "courier new" , "courier" , monospace;"><br /></span></div>
<div style="text-align: justify;">
<span style="color: blue; font-family: "courier new" , "courier" , monospace;">int length = 7; // instance declaration with assignment</span></div>
<div style="text-align: justify;">
<span style="color: blue; font-family: "courier new" , "courier" , monospace;"><br /></span></div>
<span style="color: blue; font-family: "courier new" , "courier" , monospace;"></span><br />
<div style="text-align: justify;">
<span style="color: blue; font-family: "courier new" , "courier" , monospace;">then the assignment length = 7 would be executed initially. Now after executing instance variable initialization, the initializer block would be executed, and then it is followed by execution of the specific constructor code that is invoked.</span></div>
<div style="text-align: justify;">
<span style="color: blue;"><b><br /></b></span></div>
<span style="color: blue;"><b><br /></b></span>
<span style="color: blue;"><b><br /></b></span>
<span style="color: blue;"><b><br /></b></span>
<br />
<h3>
<span style="color: blue; font-family: "courier new" , "courier" , monospace;"><b>2. Class Initializer Block</b></span></h3>
<span style="color: blue;">Just like we have the constructor for initializing the instance variables, we use the </span><span style="color: blue;">class initializer block to initialize the class variables.</span><br />
<span style="color: blue;"><br /></span>
<span style="color: blue;">A class initializer block is created just like the initializer block, but it is declared to be </span><span style="color: blue;">static. We also call this block as the static block.</span><br />
<span style="color: blue;"><br /></span>
<span style="color: blue;">We also call this block as the static block, e.g. we may declare a static block as given</span><br />
<span style="color: blue;"></span><br />
<span style="color: blue;">below...</span><br />
<div>
<br /></div>
<div>
<br /></div>
<div>
<table border="1" cellpadding="0" cellspacing="0" class="MsoTable15Grid6ColorfulAccent2" style="border-collapse: collapse; border: none; mso-border-alt: solid #F4B083 .5pt; mso-border-themecolor: accent2; mso-border-themetint: 153; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-yfti-tbllook: 1184;">
<tbody>
<tr>
<td style="border-bottom: solid #F4B083 1.5pt; border: solid #F4B083 1.0pt; mso-border-alt: solid #F4B083 .5pt; mso-border-bottom-alt: solid #F4B083 1.5pt; mso-border-bottom-themecolor: accent2; mso-border-bottom-themecolor: accent2; mso-border-bottom-themetint: 153; mso-border-bottom-themetint: 153; mso-border-themecolor: accent2; mso-border-themecolor: accent2; mso-border-themetint: 153; mso-border-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 5;">
<b><span style="color: #c45911; mso-themecolor: accent2; mso-themeshade: 191;">class Rectangle<o:p></o:p></span></b></div>
</td>
</tr>
<tr>
<td style="background: #FBE4D5; border-top: none; border: solid #F4B083 1.0pt; mso-background-themecolor: accent2; mso-background-themetint: 51; mso-border-alt: solid #F4B083 .5pt; mso-border-themecolor: accent2; mso-border-themecolor: accent2; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #F4B083 .5pt; mso-border-top-themecolor: accent2; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 68;">
<b><span style="color: #c45911; mso-themecolor: accent2; mso-themeshade: 191;">{<o:p></o:p></span></b></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid #F4B083 1.0pt; mso-border-alt: solid #F4B083 .5pt; mso-border-themecolor: accent2; mso-border-themecolor: accent2; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #F4B083 .5pt; mso-border-top-themecolor: accent2; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 4;">
<b><span style="color: #c45911; mso-themecolor: accent2; mso-themeshade: 191;"> static
int count;<o:p></o:p></span></b></div>
</td>
</tr>
<tr>
<td style="background: #FBE4D5; border-top: none; border: solid #F4B083 1.0pt; mso-background-themecolor: accent2; mso-background-themetint: 51; mso-border-alt: solid #F4B083 .5pt; mso-border-themecolor: accent2; mso-border-themecolor: accent2; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #F4B083 .5pt; mso-border-top-themecolor: accent2; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 68;">
<b><span style="color: #c45911; mso-themecolor: accent2; mso-themeshade: 191;"> static<o:p></o:p></span></b></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid #F4B083 1.0pt; mso-border-alt: solid #F4B083 .5pt; mso-border-themecolor: accent2; mso-border-themecolor: accent2; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #F4B083 .5pt; mso-border-top-themecolor: accent2; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 4;">
<b><span style="color: #c45911; mso-themecolor: accent2; mso-themeshade: 191;"> {<o:p></o:p></span></b></div>
</td>
</tr>
<tr>
<td style="background: #FBE4D5; border-top: none; border: solid #F4B083 1.0pt; mso-background-themecolor: accent2; mso-background-themetint: 51; mso-border-alt: solid #F4B083 .5pt; mso-border-themecolor: accent2; mso-border-themecolor: accent2; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #F4B083 .5pt; mso-border-top-themecolor: accent2; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 68;">
<b><span style="color: #c45911; mso-themecolor: accent2; mso-themeshade: 191;"> count
= 0;<o:p></o:p></span></b></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid #F4B083 1.0pt; mso-border-alt: solid #F4B083 .5pt; mso-border-themecolor: accent2; mso-border-themecolor: accent2; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #F4B083 .5pt; mso-border-top-themecolor: accent2; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 4;">
<b><span style="color: #c45911; mso-themecolor: accent2; mso-themeshade: 191;"> System.out.println("Inside
a class initializer<o:p></o:p></span></b></div>
</td>
</tr>
<tr>
<td style="background: #FBE4D5; border-top: none; border: solid #F4B083 1.0pt; mso-background-themecolor: accent2; mso-background-themetint: 51; mso-border-alt: solid #F4B083 .5pt; mso-border-themecolor: accent2; mso-border-themecolor: accent2; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #F4B083 .5pt; mso-border-top-themecolor: accent2; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 68;">
<b><span style="color: #c45911; mso-themecolor: accent2; mso-themeshade: 191;"> block");<o:p></o:p></span></b></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid #F4B083 1.0pt; mso-border-alt: solid #F4B083 .5pt; mso-border-themecolor: accent2; mso-border-themecolor: accent2; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #F4B083 .5pt; mso-border-top-themecolor: accent2; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 4;">
<b><span style="color: #c45911; mso-themecolor: accent2; mso-themeshade: 191;"> }<o:p></o:p></span></b></div>
</td>
</tr>
<tr>
<td style="background: #FBE4D5; border-top: none; border: solid #F4B083 1.0pt; mso-background-themecolor: accent2; mso-background-themetint: 51; mso-border-alt: solid #F4B083 .5pt; mso-border-themecolor: accent2; mso-border-themecolor: accent2; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #F4B083 .5pt; mso-border-top-themecolor: accent2; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 68;">
<b><span style="color: #c45911; mso-themecolor: accent2; mso-themeshade: 191;">}<o:p></o:p></span></b></div>
</td>
</tr>
</tbody></table>
</div>
<span style="color: blue;"><b><br /></b></span>
<span style="color: blue;"><b><br /></b></span>
<br />
<div style="text-align: left;">
</div>
<div style="text-align: justify;">
<span style="font-family: "courier new" , "courier" , monospace;"><b style="color: blue;">Just like the initializer block, the class initializer block does not have a name and is </b><b style="color: blue; text-align: left;"></b></span><br />
<div style="display: inline !important; text-align: justify;">
<span style="font-family: "courier new" , "courier" , monospace;"><b style="color: blue; text-align: left;"><b>not invoked directly by an application. This block is automatically executed whenever the </b></b></span></div>
<span style="font-family: "courier new" , "courier" , monospace;"><b style="color: blue; text-align: left;">
</b><b style="color: blue; text-align: left;"><div style="display: inline !important; text-align: justify;">
<b>class is loaded.</b></div>
</b></span></div>
<span style="font-family: "courier new" , "courier" , monospace;"><span style="color: blue;"></span></span><br />
<div style="text-align: justify;">
<span style="font-family: "courier new" , "courier" , monospace;"><span style="color: blue;"><span style="font-weight: bold;"><br /></span></span></span></div>
<span style="font-family: "courier new" , "courier" , monospace;"><span style="color: blue;">
</span><b style="color: blue;"><div style="text-align: justify;">
<b>A class is normally loaded only once at the runtime. The class would be loaded by </b><b style="text-align: left;"></b><br />
<div style="display: inline !important; text-align: justify;">
<b style="text-align: left;"><b>the JVM only if the class is used in an application.</b></b></div>
<b style="text-align: left;">
</b></div>
</b><span style="color: blue;"><div style="text-align: justify;">
<span style="font-weight: bold;"><br /></span></div>
</span><div style="text-align: justify;">
<b><u><span style="color: purple;">Difference between Initialize Block & Class Init Block</span></u></b></div>
<span style="color: blue;"><div style="text-align: justify;">
<span style="font-weight: bold;"><br /></span></div>
<b><div style="text-align: justify;">
<br /></div>
</b></span><b style="color: blue;"><div style="text-align: justify;">
<b>The static block is only loaded when the class object is created by the JVM for the </b><b style="text-align: left;"></b><br />
<div style="display: inline !important; text-align: justify;">
<b style="text-align: left;"><b>1st time whereas init {} block is loaded every time class object is created. Also first the static </b></b></div>
<b style="text-align: left;">
</b><b style="text-align: left;"><div style="display: inline !important; text-align: justify;">
<b>block is loaded then the init block. </b></div>
</b></div>
</b></span><br />
<span style="color: blue;"><b></b></span><br />
<span style="color: blue;"><b><br /></b></span>
<span style="color: blue;"><b><br /></b></span>
<span style="color: blue;"><b><br /></b></span>
<br />
<table border="1" cellpadding="0" cellspacing="0" class="MsoTable15Grid6ColorfulAccent6" style="border-collapse: collapse; border: none; mso-border-alt: solid #A8D08D .5pt; mso-border-themecolor: accent6; mso-border-themetint: 153; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-yfti-tbllook: 1184;">
<tbody>
<tr>
<td style="border-bottom: solid #A8D08D 1.5pt; border: solid #A8D08D 1.0pt; mso-border-alt: solid #A8D08D .5pt; mso-border-bottom-alt: solid #A8D08D 1.5pt; mso-border-bottom-themecolor: accent6; mso-border-bottom-themecolor: accent6; mso-border-bottom-themetint: 153; mso-border-bottom-themetint: 153; mso-border-themecolor: accent6; mso-border-themecolor: accent6; mso-border-themetint: 153; mso-border-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><b style="color: blue; font-size: 13.5pt;">public class LoadingBlocks {</b></td>
</tr>
<tr>
<td style="background: #E2EFD9; border-top: none; border: solid #A8D08D 1.0pt; mso-background-themecolor: accent6; mso-background-themetint: 51; mso-border-alt: solid #A8D08D .5pt; mso-border-themecolor: accent6; mso-border-themecolor: accent6; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #A8D08D .5pt; mso-border-top-themecolor: accent6; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><b><span style="color: blue; font-size: 13.5pt;"> static</span></b><span style="color: blue; font-size: 13.5pt;"><o:p></o:p></span></td>
</tr>
<tr>
<td style="border-top: none; border: solid #A8D08D 1.0pt; mso-border-alt: solid #A8D08D .5pt; mso-border-themecolor: accent6; mso-border-themecolor: accent6; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #A8D08D .5pt; mso-border-top-themecolor: accent6; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><b><span style="color: blue; font-size: 13.5pt;"> {</span></b><span style="color: blue; font-size: 13.5pt;"><o:p></o:p></span></td>
</tr>
<tr>
<td style="background: #E2EFD9; border-top: none; border: solid #A8D08D 1.0pt; mso-background-themecolor: accent6; mso-background-themetint: 51; mso-border-alt: solid #A8D08D .5pt; mso-border-themecolor: accent6; mso-border-themecolor: accent6; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #A8D08D .5pt; mso-border-top-themecolor: accent6; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><b><span style="color: blue; font-size: 13.5pt;"> System.out.println("Inside
static");</span></b><span style="color: blue; font-size: 13.5pt;"><o:p></o:p></span></td>
</tr>
<tr>
<td style="border-top: none; border: solid #A8D08D 1.0pt; mso-border-alt: solid #A8D08D .5pt; mso-border-themecolor: accent6; mso-border-themecolor: accent6; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #A8D08D .5pt; mso-border-top-themecolor: accent6; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><b><span style="color: blue; font-size: 13.5pt;"> }</span></b><span style="color: blue; font-size: 13.5pt;"><o:p></o:p></span></td>
</tr>
<tr>
<td style="background: #E2EFD9; border-top: none; border: solid #A8D08D 1.0pt; mso-background-themecolor: accent6; mso-background-themetint: 51; mso-border-alt: solid #A8D08D .5pt; mso-border-themecolor: accent6; mso-border-themecolor: accent6; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #A8D08D .5pt; mso-border-top-themecolor: accent6; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><b><span style="color: blue; font-size: 13.5pt;"> {</span></b><span style="color: blue; font-size: 13.5pt;"><o:p></o:p></span></td>
</tr>
<tr>
<td style="border-top: none; border: solid #A8D08D 1.0pt; mso-border-alt: solid #A8D08D .5pt; mso-border-themecolor: accent6; mso-border-themecolor: accent6; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #A8D08D .5pt; mso-border-top-themecolor: accent6; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><b><span style="color: blue; font-size: 13.5pt;"> System.out.println("Inside
init");</span></b><span style="color: blue; font-size: 13.5pt;"><o:p></o:p></span></td>
</tr>
<tr>
<td style="background: #E2EFD9; border-top: none; border: solid #A8D08D 1.0pt; mso-background-themecolor: accent6; mso-background-themetint: 51; mso-border-alt: solid #A8D08D .5pt; mso-border-themecolor: accent6; mso-border-themecolor: accent6; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #A8D08D .5pt; mso-border-top-themecolor: accent6; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><b><span style="color: blue; font-size: 13.5pt;"> }</span></b><span style="color: blue; font-size: 13.5pt;"><o:p></o:p></span></td>
</tr>
<tr>
<td style="border-top: none; border: solid #A8D08D 1.0pt; mso-border-alt: solid #A8D08D .5pt; mso-border-themecolor: accent6; mso-border-themecolor: accent6; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #A8D08D .5pt; mso-border-top-themecolor: accent6; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><b><span style="color: blue; font-size: 13.5pt;"> public static void main(String
args[])</span></b><span style="color: blue; font-size: 13.5pt;"><o:p></o:p></span></td>
</tr>
<tr>
<td style="background: #E2EFD9; border-top: none; border: solid #A8D08D 1.0pt; mso-background-themecolor: accent6; mso-background-themetint: 51; mso-border-alt: solid #A8D08D .5pt; mso-border-themecolor: accent6; mso-border-themecolor: accent6; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #A8D08D .5pt; mso-border-top-themecolor: accent6; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><b><span style="color: blue; font-size: 13.5pt;"> {</span></b><span style="color: blue; font-size: 13.5pt;"><o:p></o:p></span></td>
</tr>
<tr>
<td style="border-top: none; border: solid #A8D08D 1.0pt; mso-border-alt: solid #A8D08D .5pt; mso-border-themecolor: accent6; mso-border-themecolor: accent6; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #A8D08D .5pt; mso-border-top-themecolor: accent6; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><b><span style="color: blue; font-size: 13.5pt;"> new LoadingBlocks();</span></b><span style="color: blue; font-size: 13.5pt;"><o:p></o:p></span></td>
</tr>
<tr>
<td style="background: #E2EFD9; border-top: none; border: solid #A8D08D 1.0pt; mso-background-themecolor: accent6; mso-background-themetint: 51; mso-border-alt: solid #A8D08D .5pt; mso-border-themecolor: accent6; mso-border-themecolor: accent6; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #A8D08D .5pt; mso-border-top-themecolor: accent6; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><b><span style="color: blue; font-size: 13.5pt;"> new LoadingBlocks();</span></b><span style="color: blue; font-size: 13.5pt;"><o:p></o:p></span></td>
</tr>
<tr>
<td style="border-top: none; border: solid #A8D08D 1.0pt; mso-border-alt: solid #A8D08D .5pt; mso-border-themecolor: accent6; mso-border-themecolor: accent6; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #A8D08D .5pt; mso-border-top-themecolor: accent6; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><b><span style="color: blue; font-size: 13.5pt;"> new LoadingBlocks();</span></b><span style="color: blue; font-size: 13.5pt;"><o:p></o:p></span></td>
</tr>
<tr>
<td style="background: #E2EFD9; border-top: none; border: solid #A8D08D 1.0pt; mso-background-themecolor: accent6; mso-background-themetint: 51; mso-border-alt: solid #A8D08D .5pt; mso-border-themecolor: accent6; mso-border-themecolor: accent6; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #A8D08D .5pt; mso-border-top-themecolor: accent6; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><b><span style="color: blue; font-size: 13.5pt;"> }</span></b><span style="color: blue; font-size: 13.5pt;"><o:p></o:p></span></td>
</tr>
<tr>
<td style="border-top: none; border: solid #A8D08D 1.0pt; mso-border-alt: solid #A8D08D .5pt; mso-border-themecolor: accent6; mso-border-themecolor: accent6; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #A8D08D .5pt; mso-border-top-themecolor: accent6; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><b><span style="color: blue; font-size: 13.5pt;">}</span></b><span style="color: blue; font-size: 13.5pt;"><o:p></o:p></span></td>
</tr>
<tr>
<td style="background: #E2EFD9; border-top: none; border: solid #A8D08D 1.0pt; mso-background-themecolor: accent6; mso-background-themetint: 51; mso-border-alt: solid #A8D08D .5pt; mso-border-themecolor: accent6; mso-border-themecolor: accent6; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #A8D08D .5pt; mso-border-top-themecolor: accent6; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><b><span style="color: blue; font-size: 13.5pt;">Output:</span></b><span style="color: blue; font-size: 13.5pt;"><o:p></o:p></span></td>
</tr>
<tr>
<td style="border-top: none; border: solid #A8D08D 1.0pt; mso-border-alt: solid #A8D08D .5pt; mso-border-themecolor: accent6; mso-border-themecolor: accent6; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #A8D08D .5pt; mso-border-top-themecolor: accent6; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><b><span style="color: blue; font-size: 13.5pt;"> Inside static</span></b><span style="color: blue; font-size: 13.5pt;"><o:p></o:p></span></td>
</tr>
<tr>
<td style="background: #E2EFD9; border-top: none; border: solid #A8D08D 1.0pt; mso-background-themecolor: accent6; mso-background-themetint: 51; mso-border-alt: solid #A8D08D .5pt; mso-border-themecolor: accent6; mso-border-themecolor: accent6; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #A8D08D .5pt; mso-border-top-themecolor: accent6; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><b><span style="color: blue; font-size: 13.5pt;"> Inside init</span></b><span style="color: blue; font-size: 13.5pt;"><o:p></o:p></span></td>
</tr>
<tr>
<td style="border-top: none; border: solid #A8D08D 1.0pt; mso-border-alt: solid #A8D08D .5pt; mso-border-themecolor: accent6; mso-border-themecolor: accent6; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #A8D08D .5pt; mso-border-top-themecolor: accent6; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><b><span style="color: blue; font-size: 13.5pt;"> Inside init</span></b><span style="color: blue; font-size: 13.5pt;"><o:p></o:p></span></td>
</tr>
<tr>
<td style="background: #E2EFD9; border-top: none; border: solid #A8D08D 1.0pt; mso-background-themecolor: accent6; mso-background-themetint: 51; mso-border-alt: solid #A8D08D .5pt; mso-border-themecolor: accent6; mso-border-themecolor: accent6; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #A8D08D .5pt; mso-border-top-themecolor: accent6; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div style="margin-bottom: .0001pt; margin: 0in; mso-yfti-cnfc: 68;">
<b><span style="color: blue; font-size: 13.5pt;"> Inside
init</span><span style="color: #538135; mso-themecolor: accent6; mso-themeshade: 191;"><o:p></o:p></span></b></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid #A8D08D 1.0pt; mso-border-alt: solid #A8D08D .5pt; mso-border-themecolor: accent6; mso-border-themecolor: accent6; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #A8D08D .5pt; mso-border-top-themecolor: accent6; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 4;">
<br /></div>
</td>
</tr>
<tr>
<td style="background: #E2EFD9; border-top: none; border: solid #A8D08D 1.0pt; mso-background-themecolor: accent6; mso-background-themetint: 51; mso-border-alt: solid #A8D08D .5pt; mso-border-themecolor: accent6; mso-border-themecolor: accent6; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #A8D08D .5pt; mso-border-top-themecolor: accent6; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 68;">
<br /></div>
</td>
</tr>
</tbody></table>
<span style="color: blue;"><b><br /></b></span>
<span style="color: blue;"><b><br /></b></span>
<span style="color: blue;"><b><br /></b></span>
<span style="color: blue;"><b><br /></b></span>
<br />
<table border="1" cellpadding="0" cellspacing="0" class="MsoTable15Grid4Accent4" style="border-collapse: collapse; border: none; mso-border-alt: solid #FFD966 .5pt; mso-border-themecolor: accent4; mso-border-themetint: 153; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-yfti-tbllook: 1184;">
<tbody>
<tr>
<td style="background: #FFC000; border: solid #FFC000 1.0pt; mso-background-themecolor: accent4; mso-border-alt: solid #FFC000 .5pt; mso-border-themecolor: accent4; mso-border-themecolor: accent4; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 5;">
<b><span style="color: white; mso-themecolor: background1;">This
code should illustrate in which order they both are executed<o:p></o:p></span></b></div>
</td>
</tr>
<tr>
<td style="background: #FFF2CC; border-top: none; border: solid #FFD966 1.0pt; mso-background-themecolor: accent4; mso-background-themetint: 51; mso-border-alt: solid #FFD966 .5pt; mso-border-themecolor: accent4; mso-border-themecolor: accent4; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #FFD966 .5pt; mso-border-top-themecolor: accent4; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 68;">
<b>public class Test <o:p></o:p></b></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid #FFD966 1.0pt; mso-border-alt: solid #FFD966 .5pt; mso-border-themecolor: accent4; mso-border-themecolor: accent4; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #FFD966 .5pt; mso-border-top-themecolor: accent4; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 4;">
<b>{<o:p></o:p></b></div>
</td>
</tr>
<tr>
<td style="background: #FFF2CC; border-top: none; border: solid #FFD966 1.0pt; mso-background-themecolor: accent4; mso-background-themetint: 51; mso-border-alt: solid #FFD966 .5pt; mso-border-themecolor: accent4; mso-border-themecolor: accent4; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #FFD966 .5pt; mso-border-top-themecolor: accent4; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 68;">
<b> static int staticVariable;<o:p></o:p></b></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid #FFD966 1.0pt; mso-border-alt: solid #FFD966 .5pt; mso-border-themecolor: accent4; mso-border-themecolor: accent4; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #FFD966 .5pt; mso-border-top-themecolor: accent4; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 4;">
<b> int nonStaticVariable;<o:p></o:p></b></div>
</td>
</tr>
<tr>
<td style="background: #FFF2CC; border-top: none; border: solid #FFD966 1.0pt; mso-background-themecolor: accent4; mso-background-themetint: 51; mso-border-alt: solid #FFD966 .5pt; mso-border-themecolor: accent4; mso-border-themecolor: accent4; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #FFD966 .5pt; mso-border-top-themecolor: accent4; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 68;">
<b> // Static initialization block:<o:p></o:p></b></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid #FFD966 1.0pt; mso-border-alt: solid #FFD966 .5pt; mso-border-themecolor: accent4; mso-border-themecolor: accent4; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #FFD966 .5pt; mso-border-top-themecolor: accent4; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 4;">
<b> // Runs once (when the class is initialized)<o:p></o:p></b></div>
</td>
</tr>
<tr>
<td style="background: #FFF2CC; border-top: none; border: solid #FFD966 1.0pt; mso-background-themecolor: accent4; mso-background-themetint: 51; mso-border-alt: solid #FFD966 .5pt; mso-border-themecolor: accent4; mso-border-themecolor: accent4; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #FFD966 .5pt; mso-border-top-themecolor: accent4; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 68;">
<b> static <o:p></o:p></b></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid #FFD966 1.0pt; mso-border-alt: solid #FFD966 .5pt; mso-border-themecolor: accent4; mso-border-themecolor: accent4; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #FFD966 .5pt; mso-border-top-themecolor: accent4; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 4;">
<b> { <o:p></o:p></b></div>
</td>
</tr>
<tr>
<td style="background: #FFF2CC; border-top: none; border: solid #FFD966 1.0pt; mso-background-themecolor: accent4; mso-background-themetint: 51; mso-border-alt: solid #FFD966 .5pt; mso-border-themecolor: accent4; mso-border-themecolor: accent4; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #FFD966 .5pt; mso-border-top-themecolor: accent4; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 68;">
<b> System.out.println("Static
initalization.");<o:p></o:p></b></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid #FFD966 1.0pt; mso-border-alt: solid #FFD966 .5pt; mso-border-themecolor: accent4; mso-border-themecolor: accent4; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #FFD966 .5pt; mso-border-top-themecolor: accent4; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 4;">
<b> staticVariable
= 5;<o:p></o:p></b></div>
</td>
</tr>
<tr>
<td style="background: #FFF2CC; border-top: none; border: solid #FFD966 1.0pt; mso-background-themecolor: accent4; mso-background-themetint: 51; mso-border-alt: solid #FFD966 .5pt; mso-border-themecolor: accent4; mso-border-themecolor: accent4; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #FFD966 .5pt; mso-border-top-themecolor: accent4; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 68;">
<b> }<o:p></o:p></b></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid #FFD966 1.0pt; mso-border-alt: solid #FFD966 .5pt; mso-border-themecolor: accent4; mso-border-themecolor: accent4; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #FFD966 .5pt; mso-border-top-themecolor: accent4; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 4;">
<b> // Instance initialization block:<o:p></o:p></b></div>
</td>
</tr>
<tr>
<td style="background: #FFF2CC; border-top: none; border: solid #FFD966 1.0pt; mso-background-themecolor: accent4; mso-background-themetint: 51; mso-border-alt: solid #FFD966 .5pt; mso-border-themecolor: accent4; mso-border-themecolor: accent4; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #FFD966 .5pt; mso-border-top-themecolor: accent4; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 68;">
<b> // Runs each time you instantiate an object<o:p></o:p></b></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid #FFD966 1.0pt; mso-border-alt: solid #FFD966 .5pt; mso-border-themecolor: accent4; mso-border-themecolor: accent4; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #FFD966 .5pt; mso-border-top-themecolor: accent4; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 4;">
<b> {<o:p></o:p></b></div>
</td>
</tr>
<tr>
<td style="background: #FFF2CC; border-top: none; border: solid #FFD966 1.0pt; mso-background-themecolor: accent4; mso-background-themetint: 51; mso-border-alt: solid #FFD966 .5pt; mso-border-themecolor: accent4; mso-border-themecolor: accent4; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #FFD966 .5pt; mso-border-top-themecolor: accent4; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 68;">
<b> System.out.println("Instance
initialization.");<o:p></o:p></b></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid #FFD966 1.0pt; mso-border-alt: solid #FFD966 .5pt; mso-border-themecolor: accent4; mso-border-themecolor: accent4; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #FFD966 .5pt; mso-border-top-themecolor: accent4; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 4;">
<b> nonStaticVariable = 7;<o:p></o:p></b></div>
</td>
</tr>
<tr>
<td style="background: #FFF2CC; border-top: none; border: solid #FFD966 1.0pt; mso-background-themecolor: accent4; mso-background-themetint: 51; mso-border-alt: solid #FFD966 .5pt; mso-border-themecolor: accent4; mso-border-themecolor: accent4; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #FFD966 .5pt; mso-border-top-themecolor: accent4; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 68;">
<b> }<o:p></o:p></b></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid #FFD966 1.0pt; mso-border-alt: solid #FFD966 .5pt; mso-border-themecolor: accent4; mso-border-themecolor: accent4; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #FFD966 .5pt; mso-border-top-themecolor: accent4; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 4;">
<b> public Test() <o:p></o:p></b></div>
</td>
</tr>
<tr>
<td style="background: #FFF2CC; border-top: none; border: solid #FFD966 1.0pt; mso-background-themecolor: accent4; mso-background-themetint: 51; mso-border-alt: solid #FFD966 .5pt; mso-border-themecolor: accent4; mso-border-themecolor: accent4; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #FFD966 .5pt; mso-border-top-themecolor: accent4; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 68;">
<b> {<o:p></o:p></b></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid #FFD966 1.0pt; mso-border-alt: solid #FFD966 .5pt; mso-border-themecolor: accent4; mso-border-themecolor: accent4; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #FFD966 .5pt; mso-border-top-themecolor: accent4; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 4;">
<b> System.out.println("Constructor.");<o:p></o:p></b></div>
</td>
</tr>
<tr>
<td style="background: #FFF2CC; border-top: none; border: solid #FFD966 1.0pt; mso-background-themecolor: accent4; mso-background-themetint: 51; mso-border-alt: solid #FFD966 .5pt; mso-border-themecolor: accent4; mso-border-themecolor: accent4; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #FFD966 .5pt; mso-border-top-themecolor: accent4; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 68;">
<b> }<o:p></o:p></b></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid #FFD966 1.0pt; mso-border-alt: solid #FFD966 .5pt; mso-border-themecolor: accent4; mso-border-themecolor: accent4; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #FFD966 .5pt; mso-border-top-themecolor: accent4; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 4;">
<b> public static void main(String[] args) <o:p></o:p></b></div>
</td>
</tr>
<tr>
<td style="background: #FFF2CC; border-top: none; border: solid #FFD966 1.0pt; mso-background-themecolor: accent4; mso-background-themetint: 51; mso-border-alt: solid #FFD966 .5pt; mso-border-themecolor: accent4; mso-border-themecolor: accent4; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #FFD966 .5pt; mso-border-top-themecolor: accent4; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 68;">
<b> {<o:p></o:p></b></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid #FFD966 1.0pt; mso-border-alt: solid #FFD966 .5pt; mso-border-themecolor: accent4; mso-border-themecolor: accent4; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #FFD966 .5pt; mso-border-top-themecolor: accent4; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 4;">
<b> new Test();<o:p></o:p></b></div>
</td>
</tr>
<tr>
<td style="background: #FFF2CC; border-top: none; border: solid #FFD966 1.0pt; mso-background-themecolor: accent4; mso-background-themetint: 51; mso-border-alt: solid #FFD966 .5pt; mso-border-themecolor: accent4; mso-border-themecolor: accent4; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #FFD966 .5pt; mso-border-top-themecolor: accent4; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 68;">
<b> new Test();<o:p></o:p></b></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid #FFD966 1.0pt; mso-border-alt: solid #FFD966 .5pt; mso-border-themecolor: accent4; mso-border-themecolor: accent4; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #FFD966 .5pt; mso-border-top-themecolor: accent4; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 4;">
<b> }<o:p></o:p></b></div>
</td>
</tr>
<tr>
<td style="background: #FFF2CC; border-top: none; border: solid #FFD966 1.0pt; mso-background-themecolor: accent4; mso-background-themetint: 51; mso-border-alt: solid #FFD966 .5pt; mso-border-themecolor: accent4; mso-border-themecolor: accent4; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #FFD966 .5pt; mso-border-top-themecolor: accent4; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 68;">
<b>}<o:p></o:p></b></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid #FFD966 1.0pt; mso-border-alt: solid #FFD966 .5pt; mso-border-themecolor: accent4; mso-border-themecolor: accent4; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #FFD966 .5pt; mso-border-top-themecolor: accent4; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 4;">
<b>Output :<o:p></o:p></b></div>
</td>
</tr>
<tr>
<td style="background: #FFF2CC; border-top: none; border: solid #FFD966 1.0pt; mso-background-themecolor: accent4; mso-background-themetint: 51; mso-border-alt: solid #FFD966 .5pt; mso-border-themecolor: accent4; mso-border-themecolor: accent4; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #FFD966 .5pt; mso-border-top-themecolor: accent4; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 68;">
<b> Static
initalization.<o:p></o:p></b></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid #FFD966 1.0pt; mso-border-alt: solid #FFD966 .5pt; mso-border-themecolor: accent4; mso-border-themecolor: accent4; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #FFD966 .5pt; mso-border-top-themecolor: accent4; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 4;">
<b> Instance
initialization.<o:p></o:p></b></div>
</td>
</tr>
<tr>
<td style="background: #FFF2CC; border-top: none; border: solid #FFD966 1.0pt; mso-background-themecolor: accent4; mso-background-themetint: 51; mso-border-alt: solid #FFD966 .5pt; mso-border-themecolor: accent4; mso-border-themecolor: accent4; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #FFD966 .5pt; mso-border-top-themecolor: accent4; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 68;">
<b> Constructor.<o:p></o:p></b></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid #FFD966 1.0pt; mso-border-alt: solid #FFD966 .5pt; mso-border-themecolor: accent4; mso-border-themecolor: accent4; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #FFD966 .5pt; mso-border-top-themecolor: accent4; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 4;">
<b> Instance
initialization.<o:p></o:p></b></div>
</td>
</tr>
<tr>
<td style="background: #FFF2CC; border-top: none; border: solid #FFD966 1.0pt; mso-background-themecolor: accent4; mso-background-themetint: 51; mso-border-alt: solid #FFD966 .5pt; mso-border-themecolor: accent4; mso-border-themecolor: accent4; mso-border-themetint: 153; mso-border-themetint: 153; mso-border-top-alt: solid #FFD966 .5pt; mso-border-top-themecolor: accent4; mso-border-top-themetint: 153; padding: 0in 5.4pt 0in 5.4pt; width: 467.5pt;" valign="top" width="623"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-yfti-cnfc: 68;">
<b> Constructor.<o:p></o:p></b></div>
</td>
</tr>
</tbody></table>
<br />
<div>
<br /></div>
<div>
<br /></div>
<div>
<b><span style="font-family: "courier new" , "courier" , monospace; font-size: large;"><br /></span></b></div>
<div>
<div>
<b><span style="font-family: "courier new" , "courier" , monospace; font-size: large;">IN SHORT :</span></b></div>
<div>
<br /></div>
<div style="text-align: justify;">
<b><span style="color: purple;"><span style="font-family: "courier new" , "courier" , monospace;">Initializer block is used to define the activity that is required to be carried out </span><span style="font-family: "courier new" , "courier" , monospace;">whenever any instance is created for the class. There can be any number of initializer blocks </span><span style="font-family: "courier new" , "courier" , monospace;">in a class definition. These would be combined and treated as one initializer block. This code </span><span style="font-family: "courier new" , "courier" , monospace;">is executed just before any of the constructor code is executed. </span></span></b></div>
<div style="text-align: justify;">
<span style="color: purple; font-family: "courier new" , "courier" , monospace;"><b><br /></b></span></div>
<div style="text-align: justify;">
<b><span style="color: purple;"><span style="font-family: "courier new" , "courier" , monospace;">Class initializer block is used to initialize the class variables. This block is executed </span><span style="font-family: "courier new" , "courier" , monospace;">only once when the class is loaded, and similar to the initializer block in a class definition we </span><span style="font-family: "courier new" , "courier" , monospace;">can have any number of class initializer blocks, which would be combined and treated as</span></span></b></div>
<div style="text-align: justify;">
<span style="color: purple; font-family: "courier new" , "courier" , monospace;">one.</span></div>
</div>
</div>
Patelwalahttp://www.blogger.com/profile/12814606641177309811noreply@blogger.com0