<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1646033667562929597</id><updated>2024-09-19T05:35:33.897-07:00</updated><title type='text'>Java Interview Questions</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://prasaddusane.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1646033667562929597/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://prasaddusane.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Prasad Dusane</name><uri>http://www.blogger.com/profile/14458198724214537347</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>9</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1646033667562929597.post-8261206165890026877</id><published>2015-01-03T23:17:00.000-08:00</published><updated>2015-01-04T07:53:42.215-08:00</updated><title type='text'>Java 7:Basic Features</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Java 7 features:&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;mso-list: l0 level1 lfo1; text-indent: -.25in;&quot;&gt;
&lt;!--[if !supportLists]--&gt;1.&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;!--[endif]--&gt;Strings allowed in Switch condition. The&amp;nbsp;switch&amp;nbsp;statement
compares the&amp;nbsp;String&amp;nbsp;object in its expression with the expressions
associated with each&amp;nbsp;case&amp;nbsp;label as if it were using the&amp;nbsp;String.equals&amp;nbsp;method;
consequently, the comparison of&amp;nbsp;String&amp;nbsp;objects in&amp;nbsp;switch&amp;nbsp;statements
is case sensitive. The Java compiler generates generally more efficient
bytecode from&amp;nbsp;switch&amp;nbsp;statements that use&amp;nbsp;String&amp;nbsp;objects
than from chained&amp;nbsp;if-then-else&amp;nbsp;statements.&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;mso-list: l0 level1 lfo1; text-indent: -.25in;&quot;&gt;
&lt;!--[if !supportLists]--&gt;2.&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;!--[endif]--&gt;Catch multiple exceptions in single catch block
using ‘|’,hence lesser byte code.&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot;&gt;
e.g. Catch narrower exception then use pipe “|”
and then broader execption.&lt;/div&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoTableGrid&quot; style=&quot;border-collapse: collapse; border: none; margin-left: .5in; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-yfti-tbllook: 1184;&quot;&gt;
 &lt;tbody&gt;
&lt;tr style=&quot;height: 53.65pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;&quot;&gt;
  &lt;td style=&quot;border: solid windowtext 1.0pt; height: 53.65pt; mso-border-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 329.9pt;&quot; valign=&quot;top&quot; width=&quot;440&quot;&gt;&lt;pre style=&quot;line-height: 12.25pt; margin-left: 27.15pt;&quot;&gt;&lt;span style=&quot;color: #444444; font-size: 8.0pt;&quot;&gt;catch (IOException|SQLException ex) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;line-height: 12.25pt; margin-left: 27.15pt;&quot;&gt;&lt;span style=&quot;color: #444444; font-size: 8.0pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; logger.log(ex);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;line-height: 12.25pt; margin-left: 27.15pt;&quot;&gt;&lt;span style=&quot;color: #444444; font-size: 8.0pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; throw ex;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;line-height: 12.25pt; margin-left: 27.15pt;&quot;&gt;&lt;span style=&quot;color: #444444; font-size: 8.0pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;div class=&quot;MsoListParagraph&quot; style=&quot;margin: 0in 0in 0.0001pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class=&quot;MsoListParagraphCxSpFirst&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;mso-list: l0 level1 lfo1; text-indent: -.25in;&quot;&gt;
&lt;!--[if !supportLists]--&gt;3.&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;!--[endif]--&gt;try with resources:&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -.25in;&quot;&gt;
&lt;!--[if !supportLists]--&gt;a.&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;!--[endif]--&gt;Automatic resource management.&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 1.5in; mso-add-space: auto; mso-list: l0 level3 lfo1; mso-text-indent-alt: -9.0pt; text-indent: -1.5in;&quot;&gt;
&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;i.&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;!--[endif]--&gt;Resource is automatically closed after code
exits from try block normally or due to exception. Resource must implement new
interface java.lang.AutoCloseable which is extended by java.io.Closeable&amp;nbsp;,otherwise
code will not compile.&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 1.5in; mso-add-space: auto; mso-list: l0 level3 lfo1; mso-text-indent-alt: -9.0pt; text-indent: -1.5in;&quot;&gt;
&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;ii.&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;!--[endif]--&gt;The main thing to be noted &lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -.25in;&quot;&gt;
&lt;!--[if !supportLists]--&gt;b.&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;!--[endif]--&gt;Due to automatic resource management we don’t
need finally to close the resource connection hence lesser byte code&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -.25in;&quot;&gt;
&lt;!--[if !supportLists]--&gt;c.&lt;span style=&quot;font-size: 7pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;!--[endif]--&gt;In old try-finally if the exception is thrown in
both try and finally the exception which gets propagated to calling method is exception
from finally block not the exception from try block. Whereas in case of try
with resource the exception which gets propagated to calling method is exception
occurred in try block.&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 1.0in; mso-add-space: auto;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;text-indent: .5in;&quot;&gt;
e.g.&lt;/div&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoTableGrid&quot; style=&quot;border-collapse: collapse; border: none; margin-left: 52.65pt; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-yfti-tbllook: 1184;&quot;&gt;
 &lt;tbody&gt;
&lt;tr style=&quot;height: 86.25pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;&quot;&gt;
  &lt;td style=&quot;border: solid windowtext 1.0pt; height: 86.25pt; mso-border-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 363.45pt;&quot; valign=&quot;top&quot; width=&quot;485&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 12.25pt; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 8pt;&quot;&gt;static String readFirstLineFromFile(String
  path) throws IOException {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 12.25pt; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 8pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 8pt;&quot;&gt;try (BufferedReader br
  =&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 12.25pt; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 8pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; new BufferedReader(new
  FileReader(path)))&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 8pt;&quot;&gt; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 12.25pt; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 8pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
  return br.readLine();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 12.25pt; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 8pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 12.25pt; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 8pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;margin-left: 1.0in; mso-add-space: auto;&quot;&gt;
&lt;br /&gt;
d. If try contains multiple resources then ,when try block is executed or exception occurs the resources are closed in reverse order to to manage dependency.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
4. Diamond Operator : T&lt;span style=&quot;font-family: Arial, Helvetica, FreeSans, Luxi-sans, &#39;Nimbus Sans L&#39;, sans-serif; font-size: 12px; line-height: 18px;&quot;&gt;ype inference for generic instance creation&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;color: #444444; font-family: &#39;Courier New&#39;, Monaco, Courier, monospace; font-size: 12px; line-height: 18px; margin-left: 40px;&quot;&gt;e.g.&lt;/pre&gt;
&lt;pre style=&quot;color: #444444; font-family: &#39;Courier New&#39;, Monaco, Courier, monospace; font-size: 12px; line-height: 18px; margin-left: 40px;&quot;&gt;List&amp;lt;String&amp;gt; list = new ArrayList&amp;lt;&amp;gt;();&lt;/pre&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 1.0in; mso-add-space: auto;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://prasaddusane.blogspot.com/feeds/8261206165890026877/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://prasaddusane.blogspot.com/2015/01/java-7basic-features.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1646033667562929597/posts/default/8261206165890026877'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1646033667562929597/posts/default/8261206165890026877'/><link rel='alternate' type='text/html' href='http://prasaddusane.blogspot.com/2015/01/java-7basic-features.html' title='Java 7:Basic Features'/><author><name>Prasad Dusane</name><uri>http://www.blogger.com/profile/14458198724214537347</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1646033667562929597.post-1636456653029310322</id><published>2014-12-27T23:57:00.003-08:00</published><updated>2015-01-04T07:56:24.633-08:00</updated><title type='text'>SOAP_VS_REST</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;border-collapse: collapse; width: 624px;&quot;&gt;
 &lt;colgroup&gt;&lt;col style=&quot;mso-width-alt: 2084; mso-width-source: userset; width: 43pt;&quot; width=&quot;134&quot;&gt;&lt;/col&gt;
 &lt;col style=&quot;mso-width-alt: 9252; mso-width-source: userset; width: 190pt;&quot; width=&quot;249&quot;&gt;&lt;/col&gt;
 &lt;col style=&quot;mso-width-alt: 9362; mso-width-source: userset; width: 192pt;&quot; width=&quot;241&quot;&gt;&lt;/col&gt;
 &lt;/colgroup&gt;&lt;tbody&gt;
&lt;tr height=&quot;40&quot; style=&quot;height: 30.0pt;&quot;&gt;
  &lt;td class=&quot;xl63&quot; height=&quot;40&quot; style=&quot;background-color: #c5d9f1; border-image: none; border: 0.5pt solid windowtext; height: 30pt; width: 43pt;&quot; width=&quot;134&quot;&gt;Sr.
  No.&lt;/td&gt;
  &lt;td class=&quot;xl63&quot; style=&quot;background-color: #c5d9f1; border-color: windowtext windowtext windowtext black; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt 0px; width: 190pt;&quot; width=&quot;249&quot;&gt;SOAP(Simple
  object access protocol)&lt;/td&gt;
  &lt;td class=&quot;xl63&quot; style=&quot;background-color: #c5d9f1; border-color: windowtext windowtext windowtext black; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt 0px; width: 192pt;&quot; width=&quot;241&quot;&gt;REST(Representational
  State Transfer)&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr height=&quot;20&quot; style=&quot;height: 45.0pt;&quot;&gt;
  &lt;td class=&quot;xl64&quot; height=&quot;60&quot; style=&quot;background-color: transparent; border-color: black windowtext windowtext; border-style: none solid solid; border-width: 0px 0.5pt 0.5pt; height: 15pt;&quot; width=&quot;134&quot;&gt;1&lt;/td&gt;
  &lt;td class=&quot;xl65&quot; style=&quot;background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px; width: 190pt;&quot; width=&quot;249&quot;&gt;Soap
  is protocol&lt;/td&gt;
  &lt;td class=&quot;xl65&quot; style=&quot;background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px; width: 192pt;&quot; width=&quot;241&quot;&gt;REST
  is architectural style&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr height=&quot;40&quot; style=&quot;height: 30.0pt;&quot;&gt;
  &lt;td class=&quot;xl64&quot; height=&quot;80&quot; rowspan=&quot;2&quot; style=&quot;background-color: transparent; border-color: black windowtext windowtext; border-style: none solid solid; border-width: 0px 0.5pt 0.5pt; height: 30pt;&quot; width=&quot;134&quot;&gt;2&lt;/td&gt;
  &lt;td class=&quot;xl65&quot; style=&quot;background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px; width: 190pt;&quot; width=&quot;249&quot;&gt;Function
  driven.&lt;/td&gt;
  &lt;td class=&quot;xl65&quot; style=&quot;background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px; width: 192pt;&quot; width=&quot;241&quot;&gt;Data
  driven.&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr height=&quot;40&quot; style=&quot;height: 30.0pt;&quot;&gt;
  &lt;td class=&quot;xl65&quot; height=&quot;40&quot; style=&quot;border-left: none; border-top: none; height: 30.0pt; width: 187pt;&quot; width=&quot;249&quot;&gt;To login, add/delete data we have different
  services&lt;/td&gt;
  &lt;td class=&quot;xl65&quot; style=&quot;border-left: none; border-top: none; width: 181pt;&quot; width=&quot;241&quot;&gt;Login
  add/delete can be done in single service&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr height=&quot;20&quot; style=&quot;height: 30.0pt;&quot;&gt;
  &lt;td class=&quot;xl64&quot; height=&quot;40&quot; style=&quot;background-color: transparent; border-color: black windowtext windowtext; border-style: none solid solid; border-width: 0px 0.5pt 0.5pt; height: 15pt;&quot; width=&quot;134&quot;&gt;3&lt;/td&gt;
  &lt;td class=&quot;xl65&quot; style=&quot;background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px; width: 190pt;&quot; width=&quot;249&quot;&gt;Use
  WSDL(Web Service Description Language) as contract.&lt;/td&gt;
  &lt;td class=&quot;xl65&quot; style=&quot;background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px; width: 192pt;&quot; width=&quot;241&quot;&gt;WADL(Web
  Application Description Language)&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr height=&quot;60&quot; style=&quot;height: 15.0pt;&quot;&gt;
  &lt;td class=&quot;xl64&quot; height=&quot;100&quot; rowspan=&quot;2&quot; style=&quot;background-color: transparent; border-color: black windowtext windowtext; border-style: none solid solid; border-width: 0px 0.5pt 0.5pt; height: 45pt;&quot; width=&quot;134&quot;&gt;4&lt;/td&gt;
  &lt;td class=&quot;xl65&quot; style=&quot;background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px; width: 190pt;&quot; width=&quot;249&quot;&gt;Stateful.&lt;/td&gt;
  &lt;td class=&quot;xl65&quot; style=&quot;background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px; width: 192pt;&quot; width=&quot;241&quot;&gt;Stateless.&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr height=&quot;80&quot; style=&quot;height: 60.0pt;&quot;&gt;
  &lt;td class=&quot;xl65&quot; height=&quot;80&quot; style=&quot;border-left: none; border-top: none; height: 60.0pt; width: 187pt;&quot; width=&quot;249&quot;&gt;Server maintenance the state of every client
  request as apart of session.&lt;/td&gt;
  &lt;td class=&quot;xl65&quot; style=&quot;border-left: none; border-top: none; width: 181pt;&quot; width=&quot;241&quot;&gt;Server
  does not maintain the state of every client request.State is transferred by
  client to server as part of every request.&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr height=&quot;20&quot; style=&quot;height: 30.0pt;&quot;&gt;
  &lt;td class=&quot;xl64&quot; height=&quot;40&quot; style=&quot;background-color: transparent; border-color: black windowtext windowtext; border-style: none solid solid; border-width: 0px 0.5pt 0.5pt; height: 15pt;&quot; width=&quot;134&quot;&gt;5&lt;/td&gt;
  &lt;td class=&quot;xl65&quot; style=&quot;background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px; width: 190pt;&quot; width=&quot;249&quot;&gt;Heavy
  weight. As depends on XML markup&lt;/td&gt;
  &lt;td class=&quot;xl65&quot; style=&quot;background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px; width: 192pt;&quot; width=&quot;241&quot;&gt;Light
  weight.&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr height=&quot;20&quot; style=&quot;height: 30.0pt;&quot;&gt;
  &lt;td class=&quot;xl64&quot; height=&quot;40&quot; style=&quot;background-color: transparent; border-color: black windowtext windowtext; border-style: none solid solid; border-width: 0px 0.5pt 0.5pt; height: 15pt;&quot; width=&quot;134&quot;&gt;6&lt;/td&gt;
  &lt;td class=&quot;xl65&quot; style=&quot;background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px; width: 190pt;&quot; width=&quot;249&quot;&gt;Supports
  different web protocols like HTTP,TCP,SMTP&lt;/td&gt;
  &lt;td class=&quot;xl65&quot; style=&quot;background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px; width: 192pt;&quot; width=&quot;241&quot;&gt;Support
  only HTTP&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr height=&quot;20&quot; style=&quot;height: 30.0pt;&quot;&gt;
  &lt;td class=&quot;xl64&quot; height=&quot;40&quot; style=&quot;background-color: transparent; border-color: black windowtext windowtext; border-style: none solid solid; border-width: 0px 0.5pt 0.5pt; height: 15pt;&quot; width=&quot;134&quot;&gt;7&lt;/td&gt;
  &lt;td class=&quot;xl65&quot; style=&quot;background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px; width: 190pt;&quot; width=&quot;249&quot;&gt;Support
  only XML format&lt;/td&gt;
  &lt;td class=&quot;xl65&quot; style=&quot;background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px; width: 192pt;&quot; width=&quot;241&quot;&gt;Support
  XML,JSON,TEXT,YAML formats&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr height=&quot;20&quot; style=&quot;height: 30.0pt;&quot;&gt;
  &lt;td class=&quot;xl64&quot; height=&quot;40&quot; style=&quot;background-color: transparent; border-color: black windowtext windowtext; border-style: none solid solid; border-width: 0px 0.5pt 0.5pt; height: 15pt;&quot; width=&quot;134&quot;&gt;8&lt;/td&gt;
  &lt;td class=&quot;xl65&quot; style=&quot;background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px; width: 190pt;&quot; width=&quot;249&quot;&gt;Distributed.Communication
  through multiple endpoints.&lt;/td&gt;
  &lt;td class=&quot;xl65&quot; style=&quot;background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px; width: 192pt;&quot; width=&quot;241&quot;&gt;Point to point communication.&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr height=&quot;20&quot; style=&quot;height: 30.0pt;&quot;&gt;
  &lt;td class=&quot;xl64&quot; height=&quot;40&quot; style=&quot;background-color: transparent; border-color: black windowtext windowtext; border-style: none solid solid; border-width: 0px 0.5pt 0.5pt; height: 15pt;&quot; width=&quot;134&quot;&gt;9&lt;/td&gt;
  &lt;td class=&quot;xl65&quot; style=&quot;background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px; width: 190pt;&quot; width=&quot;249&quot;&gt;SOAP
  has successful/retry logic built in&amp;nbsp;&lt;/td&gt;
  &lt;td class=&quot;xl65&quot; style=&quot;background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px; width: 192pt;&quot; width=&quot;241&quot;&gt;clients
  to deal with communication failures by retrying&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr height=&quot;20&quot; style=&quot;height: 15.0pt;&quot;&gt;
  &lt;td class=&quot;xl64&quot; height=&quot;20&quot; style=&quot;background-color: transparent; border-color: black windowtext windowtext; border-style: none solid solid; border-width: 0px 0.5pt 0.5pt; height: 15pt;&quot; width=&quot;134&quot;&gt;10&lt;/td&gt;
  &lt;td class=&quot;xl65&quot; style=&quot;background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px; width: 190pt;&quot; width=&quot;249&quot;&gt;Strongly
  typed language.&lt;/td&gt;
  &lt;td class=&quot;xl65&quot; style=&quot;background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px; width: 192pt;&quot; width=&quot;241&quot;&gt;Not
  strongly typed.&lt;/td&gt;
 &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://prasaddusane.blogspot.com/feeds/1636456653029310322/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://prasaddusane.blogspot.com/2014/12/soapvsrest.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1646033667562929597/posts/default/1636456653029310322'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1646033667562929597/posts/default/1636456653029310322'/><link rel='alternate' type='text/html' href='http://prasaddusane.blogspot.com/2014/12/soapvsrest.html' title='SOAP_VS_REST'/><author><name>Prasad Dusane</name><uri>http://www.blogger.com/profile/14458198724214537347</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1646033667562929597.post-8853338918988624265</id><published>2012-02-29T18:41:00.003-08:00</published><updated>2014-02-07T22:35:25.848-08:00</updated><title type='text'>Annotations</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;br&gt;&lt;/div&gt;
&lt;br&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;br&gt;&lt;/div&gt;
&lt;br&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 115%; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 9.0pt; mso-bidi-font-weight: normal; mso-bidi-theme-font: minor-bidi; mso-hansi-theme-font: minor-latin;&quot;&gt;What is Annotation?&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10pt; line-height: 115%;&quot;&gt;Annotations are nothing but&amp;nbsp; meta-data&amp;nbsp;added to the Java
Elements.&amp;nbsp;&amp;nbsp; Annotations define a java type exactly similar to Classes,Enums,Interfaces and they can be applied to several
Java Elements.&lt;/span&gt;&lt;/div&gt;
&lt;br&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10pt; line-height: 115%;&quot;&gt;How
Custom Annotation are created?&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;code&gt;&lt;span style=&quot;font-size: 10pt; line-height: 115%; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;&quot;&gt;Annotation
is defined using @ along with interface keyword&lt;/span&gt;&lt;/code&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10pt; line-height: 115%;&quot;&gt;.There
are two meta annotations required to create custom annotationas shown in
example below.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;&lt;br&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10pt; line-height: 115%;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;@Target(ElementType.CLASS)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10pt; line-height: 115%;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;@Retention(RetentionPolicy.CLASS)&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10pt; line-height: 115%;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;public
@interface Author&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10pt; line-height: 115%;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10pt; line-height: 115%;&quot;&gt;&lt;span style=&quot;mso-tab-count: 2;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;String
name();&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10pt; line-height: 115%;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 10pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;The
Meta-Annotations that would be covered in the forthcoming sections are,&lt;/span&gt;&lt;/div&gt;
&lt;ul type=&quot;disc&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 10pt; mso-list: l1 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;Target
     Annotation @Target: It specifies to which java elements annotation can be applied.
     Different java elements to which annotations can be applied are&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt 0.75in; mso-add-space: auto; mso-list: l0 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-indent: -0.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: Verdana;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;1.&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;FIELD
:can be applied only to Java Fields &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt 0.75in; mso-add-space: auto; mso-list: l0 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-indent: -0.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: Verdana;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;2.&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;METHOD:
can be applied only to methods. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt 0.75in; mso-add-space: auto; mso-list: l0 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-indent: -0.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: Verdana;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;3.&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;PARAMETER
: can be applied only &lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;to method
parameters &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt 0.75in; mso-add-space: auto; mso-list: l0 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-indent: -0.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: Verdana;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;4.&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;CONSTRUCTOR:
can be applied only to constructor. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt 0.75in; mso-add-space: auto; mso-list: l0 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-indent: -0.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: Verdana;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;5.&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;LOCAL_VARIABLE
: can be appliedonly &lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;to Local variable&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt 0.75in; mso-add-space: auto; mso-list: l0 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-indent: -0.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: Verdana;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;6.&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;TYPE:
can be applied to java Type. e.g. It can be applied to Classes,interfaces,Enum .&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt 0.75in; mso-add-space: auto; mso-list: l0 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-indent: -0.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: Verdana;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;7.&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;ANNOTATION_TYPE:
can be applied only to Annotation Types. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;line-height: normal; margin: 0in 0in 10pt 0.75in; mso-add-space: auto; mso-list: l0 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-indent: -0.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: Verdana;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;8.&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;PACKAGE:
can be applied to a Package.&lt;/span&gt;&lt;/div&gt;
&lt;br&gt;
&lt;ul type=&quot;disc&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 10pt; mso-list: l1 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;Retention
     Annotation @Retention :This meta annotation specifies till what time
     annotations can be retained and when they can be discarded&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt 1in; mso-add-space: auto; mso-list: l2 level1 lfo3; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-indent: -0.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: Verdana;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;1.&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;SOURCE
:Retain annotation in source file and discard them at compile time&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt 1in; mso-add-space: auto; mso-list: l2 level1 lfo3; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-indent: -0.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: Verdana;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;2.&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;CLASS
: Retain annotation in class file and discard them at run time&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;line-height: normal; margin: 0in 0in 10pt 1in; mso-add-space: auto; mso-list: l2 level1 lfo3; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-indent: -0.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: Verdana;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;3.&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;RUNTIME
: Retain annotation at runtime and never discard them&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 10pt 0.5in; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;&quot;&gt;
&lt;br&gt;&lt;/div&gt;
&lt;br&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 115%; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 9.0pt; mso-bidi-font-weight: normal; mso-bidi-theme-font: minor-bidi; mso-hansi-theme-font: minor-latin;&quot;&gt;How annotations are
retrieved or read?&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-weight: normal; line-height: 115%; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 9.0pt; mso-bidi-theme-font: minor-bidi; mso-hansi-theme-font: minor-latin;&quot;&gt;Annoations onece defined and
used in some class we can read them using reflection package methods like
getAnnotations().We have to first obtain the refrence to the class which
contains or uses the Annotaions then we cane write code like given below&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-weight: normal; line-height: 115%; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 9.0pt; mso-bidi-theme-font: minor-bidi; mso-hansi-theme-font: minor-latin;&quot;&gt;Class classObj =
MyAnnotedClass.class;&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-weight: normal; line-height: 115%; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 9.0pt; mso-bidi-theme-font: minor-bidi; mso-hansi-theme-font: minor-latin;&quot;&gt;Annotation[] annotations =
classObj.getAnnotations();&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-weight: normal; line-height: 115%; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 9.0pt; mso-bidi-theme-font: minor-bidi; mso-hansi-theme-font: minor-latin;&quot;&gt;for (Annotation annotation :
annotations) {&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-weight: normal; line-height: 115%; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 9.0pt; mso-bidi-theme-font: minor-bidi; mso-hansi-theme-font: minor-latin;&quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;strong&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-weight: normal; line-height: 115%; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 9.0pt; mso-bidi-theme-font: minor-bidi; mso-hansi-theme-font: minor-latin;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;br&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;br&gt;&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://prasaddusane.blogspot.com/feeds/8853338918988624265/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://prasaddusane.blogspot.com/2012/02/annotations.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1646033667562929597/posts/default/8853338918988624265'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1646033667562929597/posts/default/8853338918988624265'/><link rel='alternate' type='text/html' href='http://prasaddusane.blogspot.com/2012/02/annotations.html' title='Annotations'/><author><name>Prasad Dusane</name><uri>http://www.blogger.com/profile/14458198724214537347</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1646033667562929597.post-2172555267960248428</id><published>2012-02-29T17:57:00.005-08:00</published><updated>2012-02-29T17:57:59.913-08:00</updated><title type='text'>Inner Classes</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;


&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 115%; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 9.0pt; mso-bidi-theme-font: minor-bidi; mso-hansi-theme-font: minor-latin;&quot;&gt;What is inner class and what are types of inner
classes&lt;/span&gt;&lt;/strong&gt;&lt;strong&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 115%; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 9.0pt; mso-bidi-font-weight: normal; mso-bidi-theme-font: minor-bidi; mso-hansi-theme-font: minor-latin;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;span&gt;Inner class is a class which is defined in
other class or method. Inner class shares special
relationship with outer class. As inner class is defined
within class it can access private variables of outer class&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;span&gt;There are four types of inner classes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;span&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;1)
Member Inner Class: First outer class instance needs
to be created then inner class instance is created on outer class instance .i.e
new Outer().new Inner();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt 0.5in;&quot;&gt;
&lt;span&gt;2) Static Inner Class: To access static inner class we
don’t need to create instance of outer class.
Static inner class can be directly accessed as static
variables of class. i.e. new Outer. Inner();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt 0.5in;&quot;&gt;
&lt;span&gt;3) Method local Inner Class:
These classes are defined within method &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt 0.5in;&quot;&gt;
&lt;span&gt;4) Anonymous Inner Class: Anonymous inner classes are
created and instantiated on the fly. They don’t have any name. They can’t use
keywords like extends or implement. Therefore they can either subclass of any
class or implementer of any interface. They are terminated with semicolon.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt 0.5in;&quot;&gt;
&lt;span&gt;e.g.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt 0.5in;&quot;&gt;
&lt;span&gt;Runnable myRunnable=new Runnable(){&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt 1in;&quot;&gt;
&lt;span&gt;public void run()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt 1in;&quot;&gt;
&lt;span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt 1in;&quot;&gt;
&lt;span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt 0.5in;&quot;&gt;
&lt;span&gt;};&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt 0.5in;&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-weight: normal; line-height: 115%; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 9.0pt; mso-bidi-theme-font: minor-bidi; mso-hansi-theme-font: minor-latin;&quot;&gt;We can define new methods in
inner class, but due to polymorphism we can only call methods defined in
supertype reference either interface or class&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt 0.5in;&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-weight: normal; line-height: 115%; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 9.0pt; mso-bidi-theme-font: minor-bidi; mso-hansi-theme-font: minor-latin;&quot;&gt;Anonymous inner class can be
passesd as arguments to methods&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://prasaddusane.blogspot.com/feeds/2172555267960248428/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://prasaddusane.blogspot.com/2012/02/inner-classes.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1646033667562929597/posts/default/2172555267960248428'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1646033667562929597/posts/default/2172555267960248428'/><link rel='alternate' type='text/html' href='http://prasaddusane.blogspot.com/2012/02/inner-classes.html' title='Inner Classes'/><author><name>Prasad Dusane</name><uri>http://www.blogger.com/profile/14458198724214537347</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1646033667562929597.post-7071409418014380779</id><published>2012-02-29T01:18:00.002-08:00</published><updated>2012-02-29T17:55:50.440-08:00</updated><title type='text'>Java Basics</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;strong&gt;What are class declaring rules?&lt;/strong&gt;&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Every Java File has single Public class declared in it&lt;/li&gt;
&lt;li&gt;Java File can have multiple non public classes declared in it&lt;/li&gt;
&lt;li&gt;If there is a Public class declared in Java File then name of java file must be same as Public class name&lt;/li&gt;
&lt;li&gt;If there are only non public classe in java file then name of Java file can be anything&lt;/li&gt;
&lt;li&gt;Java File can have multiple non public classes containing main method in each one of them&lt;/li&gt;
&lt;li&gt;At the top of Java File there is a package statement then thre are import statements and then the class declartaion&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;b&gt;What is constructor?&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Constructor is special kind of method which initialize the instance of class.Constructor don&#39;t have any return type even void also.When class is instatiated constructor is called first and it initialize the instance variables of class.If we don&#39;t provide any constructor jvm provides the default no argumant constructor.The first call in constructor is this() call to same class constructor or super() call to super class constructor.If we add parameterized constructor then jvm don&#39;t provide the default constructor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;Differences between method overloading and method overriding?&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoTableGrid&quot; style=&quot;border-collapse: collapse; border: currentColor; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-yfti-tbllook: 1184;&quot;&gt;&lt;tbody&gt;
&lt;tr style=&quot;mso-yfti-firstrow: yes; mso-yfti-irow: 0;&quot;&gt;&lt;td style=&quot;background-color: transparent; border: 1pt solid windowtext; mso-border-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 159.6pt;&quot; valign=&quot;top&quot; width=&quot;213&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;background-color: transparent; border-color: windowtext windowtext windowtext rgb(0, 0, 0); border-style: solid solid solid none; border-width: 1pt 1pt 1pt 0px; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 159.6pt;&quot; valign=&quot;top&quot; width=&quot;213&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;b&gt;Overloading&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;b&gt;&lt;/b&gt;&lt;/td&gt;&lt;td style=&quot;background-color: transparent; border-color: windowtext windowtext windowtext rgb(0, 0, 0); border-style: solid solid solid none; border-width: 1pt 1pt 1pt 0px; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 159.6pt;&quot; valign=&quot;top&quot; width=&quot;213&quot;&gt;&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;b&gt;Overriding&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 1;&quot;&gt;&lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 159.6pt;&quot; valign=&quot;top&quot; width=&quot;213&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #414141;&quot;&gt;Arguments or Parameters&lt;/span&gt;&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 159.6pt;&quot; valign=&quot;top&quot; width=&quot;213&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;color: #414141;&quot;&gt;Must change&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 159.6pt;&quot; valign=&quot;top&quot; width=&quot;213&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;color: #414141;&quot;&gt;Number and Type of parameters  must be same&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 2;&quot;&gt;&lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 159.6pt;&quot; valign=&quot;top&quot; width=&quot;213&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #414141;&quot;&gt;Return type&lt;/span&gt;&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 159.6pt;&quot; valign=&quot;top&quot; width=&quot;213&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;color: #414141;&quot;&gt;Can change&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 159.6pt;&quot; valign=&quot;top&quot; width=&quot;213&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;No  except Covariant return types which are available from Java 1.5 version&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 3;&quot;&gt;&lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 159.6pt;&quot; valign=&quot;top&quot; width=&quot;213&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #414141;&quot;&gt;Access&lt;/span&gt;&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 159.6pt;&quot; valign=&quot;top&quot; width=&quot;213&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;color: #414141;&quot;&gt;Can change&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 159.6pt;&quot; valign=&quot;top&quot; width=&quot;213&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;Accessibility  cannot be narrowed but it can be broaden.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 4;&quot;&gt;&lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 159.6pt;&quot; valign=&quot;top&quot; width=&quot;213&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #414141;&quot;&gt;Exceptions&lt;/span&gt;&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 159.6pt;&quot; valign=&quot;top&quot; width=&quot;213&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;color: #414141;&quot;&gt;Can change&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 159.6pt;&quot; valign=&quot;top&quot; width=&quot;213&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;Can  throw all,none or only subset of exception thrown by overridden method.Can’t  throw broader or new checked exceptions&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 5; mso-yfti-lastrow: yes;&quot;&gt;&lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 159.6pt;&quot; valign=&quot;top&quot; width=&quot;213&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #414141;&quot;&gt;Method Invocation&lt;/span&gt;&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 159.6pt;&quot; valign=&quot;top&quot; width=&quot;213&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;color: #414141;&quot;&gt;Method invocation happens  at compile time.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 159.6pt;&quot; valign=&quot;top&quot; width=&quot;213&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;color: #414141;&quot;&gt;Method invocation happens  at runtime time.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;b&gt;Can Static methods be overriden?&lt;/b&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;No Static method cann&#39;t be ovveriden&lt;/span&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;b&gt;Can Super Class Method be called from Overriden Method in its Subclass ?&lt;/b&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Yes Using super Keyword in subclass method we can call the super class verison&lt;/span&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;What is super and this&lt;/span&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;o:p&gt;

&lt;/o:p&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 115%; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 9.0pt; mso-bidi-theme-font: minor-bidi; mso-hansi-theme-font: minor-latin;&quot;&gt;If subclass contains extra methods which are
not there in super class tehn can we invoke these methods on superclass &lt;/span&gt;&lt;/strong&gt;&lt;strong&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 115%; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-size: 9.0pt; mso-bidi-font-weight: normal; mso-bidi-theme-font: minor-bidi; mso-hansi-theme-font: minor-latin;&quot;&gt;reference?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;span&gt;No. At compile time we will get error &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;span&gt;e.g.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;span&gt;Class A&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;span&gt;Public void getX(){}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;span&gt;Class B&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;span&gt;Public void getX(){}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;span&gt;Public void getY(){}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;span&gt;A a=new B();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;span&gt;a.getX(); //&lt;strong&gt;Compiles&lt;o:p&gt;&lt;/o:p&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;span&gt;&lt;strong&gt;a.getY();//Compilation fails&lt;o:p&gt;&lt;/o:p&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 10pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;Differentiate between Interface and Abstract class?&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;/div&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoTableGrid&quot; style=&quot;border-collapse: collapse; border: currentColor; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-yfti-tbllook: 1184;&quot;&gt;&lt;tbody&gt;
&lt;tr style=&quot;mso-yfti-firstrow: yes; mso-yfti-irow: 0;&quot;&gt;&lt;td style=&quot;background-color: transparent; border: 1pt solid windowtext; mso-border-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 239.4pt;&quot; valign=&quot;top&quot; width=&quot;319&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Abstract  Class&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;background-color: transparent; border-color: windowtext windowtext windowtext rgb(0, 0, 0); border-style: solid solid solid none; border-width: 1pt 1pt 1pt 0px; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 239.4pt;&quot; valign=&quot;top&quot; width=&quot;319&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Interfaces&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 1;&quot;&gt;&lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 239.4pt;&quot; valign=&quot;top&quot; width=&quot;319&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Abstract class can have both abstract and non  abstarct methods&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 239.4pt;&quot; valign=&quot;top&quot; width=&quot;319&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Interface have only abstract methods&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 2;&quot;&gt;&lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 239.4pt;&quot; valign=&quot;top&quot; width=&quot;319&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;  If class contains one or more abstract methods that class must be declared as  abstract&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 239.4pt;&quot; valign=&quot;top&quot; width=&quot;319&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Interface is by default abstract.All methods are  in interfaces are abstract by default&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 3;&quot;&gt;&lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 239.4pt;&quot; valign=&quot;top&quot; width=&quot;319&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Class can extend single abstract class&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 239.4pt;&quot; valign=&quot;top&quot; width=&quot;319&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Class can implement multiple interfaces&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 4;&quot;&gt;&lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 239.4pt;&quot; valign=&quot;top&quot; width=&quot;319&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Abstract class can be public ,private ,protected&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 239.4pt;&quot; valign=&quot;top&quot; width=&quot;319&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Interface can only be Public&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 5;&quot;&gt;&lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 239.4pt;&quot; valign=&quot;top&quot; width=&quot;319&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Abstract class can contain instance variables&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 239.4pt;&quot; valign=&quot;top&quot; width=&quot;319&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Interface contain only static variable&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 6;&quot;&gt;&lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 239.4pt;&quot; valign=&quot;top&quot; width=&quot;319&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Abstract class has a constructor as it falls in  Object class hierarchy&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 239.4pt;&quot; valign=&quot;top&quot; width=&quot;319&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Interface don’t have constructor&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 7; mso-yfti-lastrow: yes;&quot;&gt;&lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 239.4pt;&quot; valign=&quot;top&quot; width=&quot;319&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Abstract classes are faster&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt; width: 239.4pt;&quot; valign=&quot;top&quot; width=&quot;319&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Interfaces are slow because there is extra level  of indirection in calling the actual class’s method&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 10pt;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;Can Interface implement any other interface or extend any other Interfaces?&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;Interface cannot implement any other interface but Interface can extend any number of other interfaces&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;&lt;b&gt;Can a class be decalred as abstarct withot any abstarct methods?&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;Yes. Abstract class can have zero or more abstract methods&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;&lt;b&gt;Can abstract class contains main() method?&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;Yes as main() method is static it don&#39;t require the instance of class to invoke it&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;&lt;b&gt;Can we declare interface methods as private?&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;No :Implicitly methods of interface are public and member variables are implicitly public static&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;&lt;b&gt;Can we declare interface methods as static?&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
No. Interface contains only non static abstarct methods&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; line-height: 115%;&quot;&gt;What if main method is declared as private?&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%;&quot;&gt;Program compiles fine but at run time ‘Main method not public’ exception will be thrown&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; line-height: 115%;&quot;&gt;What if static is removed from main method?&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%;&quot;&gt;Program compiles and at run time throws error ‘NoSuchMethodError’&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; line-height: 115%;&quot;&gt;What if we declare public void static main()?&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%;&quot;&gt;Nothing order doesn’t matter. Program compiles and runs properly&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; line-height: 115%;&quot;&gt;What happens if we don’t pass string array as argument to main method?&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%;&quot;&gt;Program compiles and at run time throws error ‘NoSuchMethodError’&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; line-height: 115%;&quot;&gt;If we don’t provide the argument to main method at runtime then the String array will be empty or null ?&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%;&quot;&gt;String array will be empty but never null we can test by printing args.length which prints ‘0’&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; line-height: 115%;&quot;&gt;Can there be multiple nonpublic calluses in java file each containing main method&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%;&quot;&gt;Yes&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; line-height: 115%;&quot;&gt;Can abstract class contain main method ?&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%;&quot;&gt;Yes&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; line-height: 115%;&quot;&gt;What is final?&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%;&quot;&gt;Final means constant&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%;&quot;&gt;We can use Final in below three places&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%;&quot;&gt;1) Final Classes: Can’t be sub classed&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%;&quot;&gt;2) Final methods: Can’t be overridden&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%;&quot;&gt;3)Final variables : value once assigned while declaring final variable cannot be changed&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; line-height: 115%;&quot;&gt;If object reference marked as final can we change the state of final object&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%;&quot;&gt;Yes Object reference is marked as final means we cannot assign new object to that object reference.&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%;&quot;&gt;But we can change the internals (state) of object whose reference is marked as final&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%;&quot;&gt;Analogy :We can change the internals of our home but not the address of our home&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://prasaddusane.blogspot.com/feeds/7071409418014380779/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://prasaddusane.blogspot.com/2012/02/java-basics.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1646033667562929597/posts/default/7071409418014380779'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1646033667562929597/posts/default/7071409418014380779'/><link rel='alternate' type='text/html' href='http://prasaddusane.blogspot.com/2012/02/java-basics.html' title='Java Basics'/><author><name>Prasad Dusane</name><uri>http://www.blogger.com/profile/14458198724214537347</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1646033667562929597.post-5252743957007323195</id><published>2012-02-29T01:17:00.000-08:00</published><updated>2012-02-29T01:17:03.043-08:00</updated><title type='text'>Java Execption Handling</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;1) What is Exception hierarchy?&lt;/span&gt;&lt;br /&gt;&lt;/strong&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;At the top there is Throwable class .It has two Su classes Exception and Error.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;Exception: It is defined as some unwanted condition which abnormally terminates the program flow. Recovery from exceptions occurred is possible using java exception handling &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;Error: It is a condition from which recovery is not possible.e.g. OutOFMemor Error&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;2) What are different types of Exception&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;Three are basically two types of Exceptions&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;                1) Checked Exception: Checked Exceptions are those which compiler forces to user  to handle or declare. It excludes RuntimeExceptions and its subclasses&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;                2)Unchecked Exceptions :All exceptions extending RunTimeException are unchecked .As Java programmers cannot judge at compile time whether these Runtime exceptions will occur or not  therefore Runtime Exceptions are unchecked Also Error and its subclasses are unchecked. As recovery from Error is not possible Error is unchecked&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;3) How the exception is handled in java&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;                1) Using try-catch-finally&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;                2) Using throws clause with method&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;                3) Using throw keyword&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;4) What are rule about try-catch-finally&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;
&lt;div style=&quot;text-indent: 0.5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;1) Every try must have either catch or finally&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-indent: 0.5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;2) try-catch-finally must be in sequence i.e first try then catch then finally&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-indent: 0.5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;3) There should not be any piece of code between try block and catch block or finally block&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-indent: 0.5in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;4)If there are multiple catch blocks having parent child relationship of Exception then first subclass exception must be caught then the super class exception is to be caught&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;5) What is finally block&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;Finally block is guaranteed to be executed .All clean up code goes into finally block.e.g.code for  closing database connection&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;6)If try block contains return or break statement as last line whether the finally block executed&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;Yes. Return or break statement will  execute of finally block&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;7) If try block contains System. exit statement as last line whether the finally block executed&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;No.JVM will terminate no further execution after System.exit&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;8) How custom Exceptions are created&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;By extending the Exception class&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;9) What is difference between throw and throws&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;Throw is used to throw exception at any line in java code&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;Throws is use with method to declare that this method doesn’t handle the exception its delegating task of exception handling to calling method&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;
&lt;h3 style=&quot;margin: 12pt 0in;&quot;&gt;
&lt;span style=&quot;font-size: 11pt;&quot;&gt;10)What is difference between &lt;a href=&quot;http://javafanatics.blogspot.com/2007/03/noclassdeffounderror-vs.html&quot;&gt;&lt;span style=&quot;color: #009eb8;&quot;&gt;NoClassDefFoundError Vs ClassNotFoundException&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;br /&gt;
&lt;h3 style=&quot;margin: 12pt 0in;&quot;&gt;
&lt;span style=&quot;font-size: 11pt; font-weight: normal;&quot;&gt;ClassNotFoundException is exception.It occurs when class is not found in classpath&lt;/span&gt;&lt;/h3&gt;
&lt;br /&gt;
&lt;h3 style=&quot;margin: 12pt 0in;&quot;&gt;
&lt;span style=&quot;font-size: 11pt; font-weight: normal;&quot;&gt;NoClassDefFoundError  is an error.It does not mena that the required class not found in classpath. Class was found but it may contain some static block which tries to load some another class whose definition jvm is not able to load at runtime&lt;/span&gt;&lt;/h3&gt;
&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://prasaddusane.blogspot.com/feeds/5252743957007323195/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://prasaddusane.blogspot.com/2012/02/java-execption-handling.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1646033667562929597/posts/default/5252743957007323195'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1646033667562929597/posts/default/5252743957007323195'/><link rel='alternate' type='text/html' href='http://prasaddusane.blogspot.com/2012/02/java-execption-handling.html' title='Java Execption Handling'/><author><name>Prasad Dusane</name><uri>http://www.blogger.com/profile/14458198724214537347</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1646033667562929597.post-135835668275657423</id><published>2012-02-29T01:16:00.002-08:00</published><updated>2012-02-29T01:16:13.884-08:00</updated><title type='text'>Serialization</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;strong&gt;&lt;span&gt;1) What is Serialization?&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt;&quot;&gt;In order to transfer object over network or store the object in file system it must be converted in to byte stream. Serialization converts object to byte steram.To Serialize an object our class must implement Serializable interface.Serializable is a Marker interface i.e. has no methods to override. It must be implemented to tell  the JVM that object of this class must be converted to byte stream&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt;&quot;&gt;2) How to customize serialization&lt;/span&gt;&lt;/b&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt;&quot;&gt;To customize serialization we can implement Externalizable interface and override readExternal() and writeExternal() methods&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt;&quot;&gt;3) Can object having references to no serialized objects be serialized&lt;/span&gt;&lt;/b&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt;&quot;&gt;No.In this case NotSerializableException  will be thrown at runtime.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt;&quot;&gt;4)Whether static variable are also serialized&lt;/span&gt;&lt;/b&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt;&quot;&gt;No. Static variables are not serialized&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt;&quot;&gt;5)What is transient variable&lt;/span&gt;&lt;/b&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt;&quot;&gt;Transient variables are skipped from serialization. Transient variables take default value after deserialization&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt;&quot;&gt;4) If subclass is serializable but super class is not serializable what will happen?&lt;/span&gt;&lt;/b&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt;&quot;&gt;In this case during deserialization super class constructor runs and the inherited variables from super class gets initialized with default values&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt;&quot;&gt;5) If we want to serialize array or collection whether all members needs to be serialized?&lt;/span&gt;&lt;/b&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt;&quot;&gt;Yes&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;
&lt;img alt=&quot;&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/6787712903410731948-2132391965619504499?l=prasad-dusane.blogspot.com&quot; width=&quot;1&quot; /&gt;&lt;/div&gt;
&lt;div class=&quot;article-footer&quot;&gt;
&lt;div class=&quot;publish-info&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://prasaddusane.blogspot.com/feeds/135835668275657423/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://prasaddusane.blogspot.com/2012/02/serialization.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1646033667562929597/posts/default/135835668275657423'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1646033667562929597/posts/default/135835668275657423'/><link rel='alternate' type='text/html' href='http://prasaddusane.blogspot.com/2012/02/serialization.html' title='Serialization'/><author><name>Prasad Dusane</name><uri>http://www.blogger.com/profile/14458198724214537347</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1646033667562929597.post-958537555762136113</id><published>2012-02-29T01:14:00.002-08:00</published><updated>2012-02-29T17:59:45.550-08:00</updated><title type='text'>Object class methods (Overriding equals() and hashCode())</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; line-height: 115%; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-theme-font: minor-bidi;&quot;&gt;&lt;strong&gt;What are the methods in object class&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-weight: bold; mso-bidi-theme-font: minor-bidi;&quot;&gt;equals()&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-weight: bold; mso-bidi-theme-font: minor-bidi;&quot;&gt;toString()&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-weight: bold; mso-bidi-theme-font: minor-bidi;&quot;&gt;hashCode()&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-weight: bold; mso-bidi-theme-font: minor-bidi;&quot;&gt;wait ()&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-weight: bold; mso-bidi-theme-font: minor-bidi;&quot;&gt;notify()&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-weight: bold; mso-bidi-theme-font: minor-bidi;&quot;&gt;notifyAll()&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-weight: bold; mso-bidi-theme-font: minor-bidi;&quot;&gt;clone()&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Verdana;&quot;&gt;finalize()&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; line-height: 115%; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-theme-font: minor-bidi;&quot;&gt;Why toString needs to be overridden&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-weight: bold; mso-bidi-theme-font: minor-bidi;&quot;&gt;If we use the object class’s toString method and try to print our object then it will print something like ClassName@hashcode which doesn’t provide any meaningful information&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-weight: bold; mso-bidi-theme-font: minor-bidi;&quot;&gt;In order to provide meaningful information when object .toString is called toString must be overridden&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; line-height: 115%; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-theme-font: minor-bidi;&quot;&gt;Why equals need to be overridden?&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-weight: bold; mso-bidi-theme-font: minor-bidi;&quot;&gt;If we create two objects having same state and compare it using obj1.equals(obj2) then it will always return false as these two objects are distinct object even though meaningfully they are equal as their state is equal&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-weight: bold; mso-bidi-theme-font: minor-bidi;&quot;&gt;Therefore meaningfully compare two objects on their state we need to override equals method&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; line-height: 115%; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-theme-font: minor-bidi;&quot;&gt;What is hashCode?&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-weight: bold; mso-bidi-theme-font: minor-bidi;&quot;&gt;As per Object class implementation of hashCode,HashCode is memory address of an object mapped to integer &lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; line-height: 115%; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-theme-font: minor-bidi;&quot;&gt;Why we need to override hashCode method?&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-weight: bold; mso-bidi-theme-font: minor-bidi;&quot;&gt;Actual hashCode is in symmetry with equals. There are some rules about symmetry&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-weight: bold; mso-bidi-theme-font: minor-bidi;&quot;&gt;If equals returns true for two objects hashcode must be same&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-weight: bold; mso-bidi-theme-font: minor-bidi;&quot;&gt;If equals returns false then hashCode can be same or different&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-weight: bold; mso-bidi-theme-font: minor-bidi;&quot;&gt;If we are using our custom object as a key in hash base collection then it’s necessary to implement equals and hashCode methods&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-weight: bold; mso-bidi-theme-font: minor-bidi;&quot;&gt;Because when we use put() method &lt;span style=&quot;mso-spacerun: yes;&quot;&gt; &lt;/span&gt;in hash based collection some hashing algorithm is applied over hashCode and the location of bucket to store the key value is identified&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;tab-stops: 156.0pt;&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-weight: bold; mso-bidi-theme-font: minor-bidi;&quot;&gt;When we use get() method of hash based collections then first the location of bucket is found out using hashCode then the equals method is invoked to found out the actual equal object in the bucket&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;tab-stops: 156.0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;tab-stops: 156.0pt;&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; line-height: 115%; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-theme-font: minor-bidi;&quot;&gt;What the bucket implements?&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;tab-stops: 156.0pt;&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-weight: bold; mso-bidi-theme-font: minor-bidi;&quot;&gt;Bucket actually implements the linked list&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;tab-stops: 156.0pt;&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; line-height: 115%; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-theme-font: minor-bidi;&quot;&gt;What if equals method is overriden and hashCode is not overridden?&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;tab-stops: 156.0pt;&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-weight: bold; mso-bidi-theme-font: minor-bidi;&quot;&gt;If equals is overridden but hashCode is not then hashCode will inherit the implementation from Object class.&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-weight: bold; mso-bidi-theme-font: minor-bidi;&quot;&gt;In Object class hashCode() is nothing &lt;span style=&quot;mso-tab-count: 1;&quot;&gt;            &lt;/span&gt;but memory address of an object mapped to integer &lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-weight: bold; mso-bidi-theme-font: minor-bidi;&quot;&gt;Therefore even though two objects are meaningfully equal as equal returns true their hashCode will be always different as these are two different objects with different memory locations.&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-weight: bold; mso-bidi-theme-font: minor-bidi;&quot;&gt;Therefore in hashbased collections if we use such object as a key then we will not able to retrieve the value. We will get null when we try to retrieve the value&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;tab-stops: 156.0pt center 3.25in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;tab-stops: 156.0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;tab-stops: 156.0pt;&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; line-height: 115%; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-theme-font: minor-bidi;&quot;&gt;What if equals method is overriden and returns false and hashCode is overridden but returns the same value 1?&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;tab-stops: 156.0pt;&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-weight: bold; mso-bidi-theme-font: minor-bidi;&quot;&gt;This is perfectly valid.In this case different objects will be placed in same bucket in the next node of linked list&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;tab-stops: 156.0pt;&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-weight: bold; mso-bidi-theme-font: minor-bidi;&quot;&gt;This will affect the performance while retrieving elements using get() from hash based collection&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;tab-stops: 156.0pt;&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;color: #333333; font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 9pt; font-weight: normal; line-height: 115%; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-font-weight: bold; mso-bidi-theme-font: minor-bidi;&quot;&gt;As get() method has to iterate through whole linked list and check the equals() method to find out actual object&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;tab-stops: 156.0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;tab-stops: 156.0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://prasaddusane.blogspot.com/feeds/958537555762136113/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://prasaddusane.blogspot.com/2012/02/object-class-methods-overriding-equals.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1646033667562929597/posts/default/958537555762136113'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1646033667562929597/posts/default/958537555762136113'/><link rel='alternate' type='text/html' href='http://prasaddusane.blogspot.com/2012/02/object-class-methods-overriding-equals.html' title='Object class methods (Overriding equals() and hashCode())'/><author><name>Prasad Dusane</name><uri>http://www.blogger.com/profile/14458198724214537347</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1646033667562929597.post-3068877103309370052</id><published>2012-02-29T01:13:00.005-08:00</published><updated>2012-02-29T01:13:25.453-08:00</updated><title type='text'>OOPS Basics</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;strong&gt;&lt;span class=&quot;que&quot;&gt;&lt;span class=&quot;queIndex&quot;&gt;1.&lt;/span&gt;What are the basic four principle concepts of  OOPS?&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;que&quot;&gt;&lt;/span&gt;&lt;/strong&gt;  The Basic four OOPS Concepts are&lt;br /&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Abstraction :Abstarction means showing only the essential features of a class and hiding the all background details.It is Design Time Concept&lt;/li&gt;
&lt;li&gt;Polymorphism :  Single Name Multiple Forms&lt;/li&gt;
&lt;/ul&gt;
There are three ways by which Polymorphism can be achived in Java &lt;br /&gt;            1)Method Overloading&lt;br /&gt;            2)Method Overriding of Classes&lt;br /&gt;            3)Method  Overriding of Interfaces&lt;br /&gt;&lt;br /&gt;        There are two types of Polymorphism&lt;br /&gt;             1)RunTime Polymorphism:As which methods to call is decided at runtime it is also know as      late binding or Dynamic binding e.g Method Overriding&lt;br /&gt;             2)Compile Time Polymorphism :As call to methods are resolved at compile time it is known as Early Binding or Static binding.e.g. Method Overloading&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Inheritance  :It is a IS-A relationship.Inheritance enables code reuse.Child Class Inherites traits of its Parent class.Thus child class can reuse functionality of its Parent class and can aslo add extr features&lt;/li&gt;
&lt;li&gt;Encapsulation :Encapsulation enables data hiding.Object encapsulates Attributes and Properties.Access to these  Attributes and Properties are restricted from outside world and provided only the appropriate access&lt;/li&gt;
&lt;/ul&gt;
&lt;strong&gt;2.What is Aggreagtion and Composition&lt;/strong&gt;&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;      Aggregation.: Class contains object of another class as its member.Its a HAS-A relationship&lt;/li&gt;
&lt;li&gt;Composition : Its special type of Aggragation.Differnce from Aggragation is that the member object must exist for existance of Main Class object&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://prasaddusane.blogspot.com/feeds/3068877103309370052/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://prasaddusane.blogspot.com/2012/02/oops-basics.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1646033667562929597/posts/default/3068877103309370052'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1646033667562929597/posts/default/3068877103309370052'/><link rel='alternate' type='text/html' href='http://prasaddusane.blogspot.com/2012/02/oops-basics.html' title='OOPS Basics'/><author><name>Prasad Dusane</name><uri>http://www.blogger.com/profile/14458198724214537347</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>