<?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-542843703124727712</id><updated>2020-06-28T00:55:20.802-07:00</updated><category term="Java Control Statements"/><title type='text'>Java Stories</title><subtitle type='html'>This Blog is for Beginners, who want to start their life in coding.&#xa;Welcome in and learn about most adorable language Java.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='https://javastories1.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/542843703124727712/posts/default'/><link rel='alternate' type='text/html' href='https://javastories1.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Alpha programming</name><uri>http://www.blogger.com/profile/01668624719714063369</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//2.bp.blogspot.com/-UMN6IyPVjNk/Xbr2Eb5gkOI/AAAAAAAAQiM/R-qqJWSSfW4FjdEsfBGLROFcBACZDEXkgCK4BGAYYCw/s220/IMG_20180206_191342_508.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>8</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-542843703124727712.post-3471995253098063412</id><published>2019-10-31T23:01:00.000-07:00</published><updated>2019-10-31T23:01:22.781-07:00</updated><title type='text'></title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;h2 style=&quot;background-color: white; box-sizing: border-box; color: #444542; font-family: &amp;quot;PT Sans&amp;quot;, &amp;quot;Trebuchet MS&amp;quot;, &amp;quot;Lucida Grande&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 26px; line-height: 1.2; margin: 0px 0px 16px;&quot;&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Nested if statement in Java&lt;/li&gt;&lt;/ul&gt;&lt;/h2&gt;&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #222426; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;When there is an if statement inside another if statement then it is called the&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;nested if statement&lt;/span&gt;.&lt;br style=&quot;box-sizing: border-box;&quot; /&gt;The structure of nested if looks like this:&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: #222426; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;if(condition_1){&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: #222426; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;statement 1(s);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: #222426; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;if(condition_2){&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: #222426; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;statement 2(s);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: #222426; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: #222426; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;}&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #222426; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;Statement1 would execute if the condition_1 is true. Statement2 would only execute if both the conditions( condition_1 and condition_2) are true.&lt;/div&gt;&lt;h3 style=&quot;background-color: white; box-sizing: border-box; color: #444542; font-family: &amp;quot;PT Sans&amp;quot;, &amp;quot;Trebuchet MS&amp;quot;, &amp;quot;Lucida Grande&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 22px; line-height: 1.2; margin: 0px 0px 16px;&quot;&gt;Example of Nested if statement:&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;public class NestedIfExample{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;public static void main(String args[]){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;if(num&amp;lt;100){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;system.out.println(&quot;number is less than 100&quot;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;if(num&amp;gt;50){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;system.out.println(&quot;number is greater than 50&quot;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;&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;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;background-color: white; box-sizing: border-box; font-family: &amp;quot;PT Sans&amp;quot;, &amp;quot;Trebuchet MS&amp;quot;, &amp;quot;Lucida Grande&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 22px; line-height: 1.2; margin: 0px 0px 16px;&quot;&gt;&lt;span style=&quot;color: #444542;&quot;&gt;Out&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;put:&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;number is less than 100&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;number is greater than 50&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;background-color: white; box-sizing: border-box; color: #444542; font-family: &amp;quot;PT Sans&amp;quot;, &amp;quot;Trebuchet MS&amp;quot;, &amp;quot;Lucida Grande&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 26px; line-height: 1.2; margin: 0px 0px 16px;&quot;&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;If else statement in Java&lt;/li&gt;&lt;/ul&gt;&lt;/h2&gt;&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #222426; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;This is how an if-else statement looks:&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: #222426; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;if(condition){&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: #222426; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;statement(s);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: #222426; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: #222426; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;else {&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: #222426; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;statement(s);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: #222426; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #222426; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;The statements inside “if” would execute if the condition is true, and the statements inside “else” would execute if the condition is false.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://1.bp.blogspot.com/-Ky7S9uMfHE0/Xbu_7YLhOJI/AAAAAAAAQjY/baX9wsxHMk0WRRGQeRDBa136ELFU5DT2ACLcBGAsYHQ/s1600/If_else_flow_diagram.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;400&quot; data-original-width=&quot;400&quot; height=&quot;320&quot; src=&quot;https://1.bp.blogspot.com/-Ky7S9uMfHE0/Xbu_7YLhOJI/AAAAAAAAQjY/baX9wsxHMk0WRRGQeRDBa136ELFU5DT2ACLcBGAsYHQ/s320/If_else_flow_diagram.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #222426; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;background-color: white; box-sizing: border-box; color: #444542; font-family: &amp;quot;PT Sans&amp;quot;, &amp;quot;Trebuchet MS&amp;quot;, &amp;quot;Lucida Grande&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 22px; line-height: 1.2; margin: 0px 0px 16px;&quot;&gt;Example of if-else statement:&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;public class IfElseExample {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;public static void main(string args[]){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;int num =120;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;if(num&amp;lt;50){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;system.out,println(&quot;number is less than 50&quot;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;else {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;system.out.println(&quot;number is greater than equal 50&quot;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #222426; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; box-sizing: border-box; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #222426;&quot;&gt;&lt;u&gt;O&lt;/u&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: #222426;&quot;&gt;&lt;u&gt;ut&lt;/u&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;u&gt;put:&amp;nbsp;&lt;/u&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; box-sizing: border-box; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #444444;&quot;&gt;number is greater than or equal 50.&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #222426; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;/div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;color: #444542; font-family: &amp;quot;PT Sans&amp;quot;, &amp;quot;Trebuchet MS&amp;quot;, &amp;quot;Lucida Grande&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 26px;&quot;&gt;&lt;b&gt;if-else-if Statement&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #222426; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;if-else-if statement is used when we need to check multiple conditions. In this statement we have only one “if” and one “else”, however we can have multiple “else if”. It is also known as&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;if else if ladder&lt;/span&gt;. This is how it looks:&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: #222426; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;if(condition_1){&lt;br /&gt;/*if Condition_1 is true execute this&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: #222426; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;statement(s);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: #222426; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: #222426; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;else if(condition_2){&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: #222426; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;/*execute this if condition _1 is not met and&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: #222426; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;/*Condition_2 is met.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: #222426; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;statement(s);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: #222426; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;}//&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: #222426; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;else {&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: #222426; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;/*if none of the condition is true&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: #222426; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;/*then these statements gets executed.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: #222426; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;statement(s);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; color: #222426; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #222426; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;Note:&lt;/span&gt;&amp;nbsp;The most important point to note here is that in if-else-if statement, as soon as the condition is met, the corresponding set of statements get executed, rest gets ignored. If none of the condition is met then the statements inside “else” gets executed.&lt;/div&gt;&lt;h3 style=&quot;background-color: white; box-sizing: border-box; color: #444542; font-family: &amp;quot;PT Sans&amp;quot;, &amp;quot;Trebuchet MS&amp;quot;, &amp;quot;Lucida Grande&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 22px; line-height: 1.2; margin: 0px 0px 16px;&quot;&gt;Example of if-else-if&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;public class IfElseExample{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;public static void main(string args[]){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;int num =1234;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;if(num&amp;lt;100&amp;amp;&amp;amp; num&amp;gt;=1){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;system.out.println(&quot;Its a two digit number&quot;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;else if(num&amp;lt;1000&amp;amp;&amp;amp; num&amp;gt;=100){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;system.out.println(&quot;Its a three digit number&quot;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;else if(num&amp;lt;10000&amp;amp;&amp;amp; num&amp;gt;=1000){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;system.out.println(&quot;Its a four digit number&quot;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;else {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;system.out.println(&quot;number is not between 1 to 99999&quot;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;&amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #222426; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; box-sizing: border-box; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #222426;&quot;&gt;Out&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;put:&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; box-sizing: border-box; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;b&gt;Its a four digits number&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://javastories1.blogspot.com/feeds/3471995253098063412/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://javastories1.blogspot.com/2019/10/nested-if-statement-in-java-when-there.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/542843703124727712/posts/default/3471995253098063412'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/542843703124727712/posts/default/3471995253098063412'/><link rel='alternate' type='text/html' href='https://javastories1.blogspot.com/2019/10/nested-if-statement-in-java-when-there.html' title=''/><author><name>Alpha programming</name><uri>http://www.blogger.com/profile/01668624719714063369</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//2.bp.blogspot.com/-UMN6IyPVjNk/Xbr2Eb5gkOI/AAAAAAAAQiM/R-qqJWSSfW4FjdEsfBGLROFcBACZDEXkgCK4BGAYYCw/s220/IMG_20180206_191342_508.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://1.bp.blogspot.com/-Ky7S9uMfHE0/Xbu_7YLhOJI/AAAAAAAAQjY/baX9wsxHMk0WRRGQeRDBa136ELFU5DT2ACLcBGAsYHQ/s72-c/If_else_flow_diagram.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-542843703124727712.post-1517351071270354012</id><published>2019-10-31T21:38:00.001-07:00</published><updated>2019-10-31T21:38:37.950-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java Control Statements"/><title type='text'></title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;header class=&quot;entry-header&quot; style=&quot;background-color: white; box-sizing: border-box; color: #222426; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px;&quot;&gt;&lt;h1 class=&quot;entry-title&quot; style=&quot;box-sizing: border-box; color: #444542; font-family: &amp;quot;PT Sans&amp;quot;, &amp;quot;Trebuchet MS&amp;quot;, &amp;quot;Lucida Grande&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 30px; line-height: 1.2; margin: 0px 0px 16px;&quot;&gt;If, If..else Statement in Java with Examples&lt;/h1&gt;&lt;/header&gt;&lt;div class=&quot;entry-content&quot; style=&quot;box-sizing: border-box; font-family: &amp;quot;PT Sans&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 17px;&quot;&gt;&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #222426; margin-bottom: 26px; padding: 0px;&quot;&gt;When we need to execute a set of statements based on a condition then we need to use&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;control flow statements&lt;/span&gt;. For example, if a number is greater than zero then we want to print “Positive Number” but if it is less than zero then we want to print “Negative Number”. In this case we have two print statements in the program, but only one print statement executes at a time based on the input value. We will see how to write such type of conditions in the java program using control statements.&lt;/div&gt;&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #222426; margin-bottom: 26px; padding: 0px;&quot;&gt;In this tutorial, we will see four types of control statements that you can use in java programs based on the requirement: In this tutorial we will cover following conditional statements:&lt;/div&gt;&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #222426; margin-bottom: 26px; padding: 0px;&quot;&gt;a) if statement&lt;br style=&quot;box-sizing: border-box;&quot; /&gt;b) nested if statement&lt;br style=&quot;box-sizing: border-box;&quot; /&gt;c) if-else statement&lt;br style=&quot;box-sizing: border-box;&quot; /&gt;d) if-else-if statement&lt;/div&gt;&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #222426; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;background-color: white; box-sizing: border-box; color: #444542; font-family: &amp;quot;PT Sans&amp;quot;, &amp;quot;Trebuchet MS&amp;quot;, &amp;quot;Lucida Grande&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 26px; line-height: 1.2; margin: 0px 0px 16px;&quot;&gt;If statement&lt;/h2&gt;&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #222426; margin-bottom: 26px; padding: 0px;&quot;&gt;If statement consists a condition, followed by statement or a set of statements as shown below:&lt;/div&gt;&lt;div class=&quot;lq&quot; style=&quot;background-color: white; box-sizing: border-box; color: #222426; float: none; margin: 10px 0px; overflow: hidden;&quot;&gt;&lt;div data-format=&quot;300x250&quot; data-publisher=&quot;Beginnersbook.com&quot; data-type=&quot;ad&quot; data-zone=&quot;ros&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: darkblue; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 13px;&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: black; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 13px;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 13px;&quot;&gt;condition&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: black; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 13px;&quot;&gt;){&lt;/span&gt;&lt;/div&gt;&lt;div data-format=&quot;300x250&quot; data-publisher=&quot;Beginnersbook.com&quot; data-type=&quot;ad&quot; data-zone=&quot;ros&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: black; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 13px;&quot;&gt;statement(s);&lt;/span&gt;&lt;/div&gt;&lt;div data-format=&quot;300x250&quot; data-publisher=&quot;Beginnersbook.com&quot; data-type=&quot;ad&quot; data-zone=&quot;ros&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: black; font-family: Consolas, Menlo, Monaco, &amp;quot;Lucida Console&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace, sans-serif; font-size: 13px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #222426; margin-bottom: 26px; padding: 0px;&quot;&gt;The statements gets executed only when the given condition is true. If the condition is false then the statements inside if statement body are completely ignored.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;background-color: white; clear: both; color: #222426; text-align: center;&quot;&gt;&lt;a href=&quot;https://1.bp.blogspot.com/-XtdxK2xv_zg/Xbux68vp8EI/AAAAAAAAQjM/iVcfRZySmHg7BlNf393THDI56SY4r9VNQCLcBGAsYHQ/s1600/if_statement_flow_diagram.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;400&quot; data-original-width=&quot;400&quot; height=&quot;320&quot; src=&quot;https://1.bp.blogspot.com/-XtdxK2xv_zg/Xbux68vp8EI/AAAAAAAAQjM/iVcfRZySmHg7BlNf393THDI56SY4r9VNQCLcBGAsYHQ/s320/if_statement_flow_diagram.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #222426; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;background-color: white; box-sizing: border-box; color: #444542; font-family: &amp;quot;PT Sans&amp;quot;, &amp;quot;Trebuchet MS&amp;quot;, &amp;quot;Lucida Grande&amp;quot;, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 22px; line-height: 1.2; margin: 0px 0px 16px;&quot;&gt;Example of if statement&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;public class IfStatementExample&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;public static void main(string args[])&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;int num=70;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(num&amp;lt;100)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;/* This println Statement will only execute.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;/*If the above condition is true.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #222426; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; box-sizing: border-box; margin-bottom: 26px; padding: 0px;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #222426;&quot;&gt;&lt;u&gt;Out&lt;/u&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;u&gt;put&lt;/u&gt;: &lt;/span&gt;Number is less than 100.&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://javastories1.blogspot.com/feeds/1517351071270354012/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://javastories1.blogspot.com/2019/10/if-if.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/542843703124727712/posts/default/1517351071270354012'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/542843703124727712/posts/default/1517351071270354012'/><link rel='alternate' type='text/html' href='https://javastories1.blogspot.com/2019/10/if-if.html' title=''/><author><name>Alpha programming</name><uri>http://www.blogger.com/profile/01668624719714063369</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//2.bp.blogspot.com/-UMN6IyPVjNk/Xbr2Eb5gkOI/AAAAAAAAQiM/R-qqJWSSfW4FjdEsfBGLROFcBACZDEXkgCK4BGAYYCw/s220/IMG_20180206_191342_508.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://1.bp.blogspot.com/-XtdxK2xv_zg/Xbux68vp8EI/AAAAAAAAQjM/iVcfRZySmHg7BlNf393THDI56SY4r9VNQCLcBGAsYHQ/s72-c/if_statement_flow_diagram.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-542843703124727712.post-6688430527632338832</id><published>2019-10-31T13:26:00.006-07:00</published><updated>2019-10-31T13:44:35.021-07:00</updated><title type='text'></title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div style=&quot;background-color: white; color: #444444; font-family: Verdana, Helvetica, Arial, sans-serif; font-size: 13px; text-align: justify;&quot;&gt;&lt;h2 style=&quot;color: #333333; font-family: &amp;quot;Trebuchet MS&amp;quot;, arial, sans-serif; margin: 1em 0px 0.5em;&quot;&gt;&lt;span style=&quot;color: #0b5394; font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Abstract Classes&lt;/span&gt;&lt;/h2&gt;&lt;h4 style=&quot;color: black; font-family: verdana, arial, helvetica; font-size: 14pt; margin: 1.5em 0px 1em;&quot;&gt;&lt;a href=&quot;https://www.blogger.com/u/1/null&quot; name=&quot;abstractClasses&quot; style=&quot;text-decoration-line: underline;&quot;&gt;&lt;/a&gt;&lt;/h4&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; font-family: verdana, arial, helvetica; font-size: 10pt; text-align: justify;&quot;&gt;An abstract class is a class that is incomplete, in that it describes a set of operations, but is missing the actual implementation of these operations. Abstract classes:&lt;/div&gt;&lt;div style=&quot;background-color: white; font-family: verdana, arial, helvetica; font-size: 13px; text-align: justify;&quot;&gt;&lt;ul style=&quot;font-size: 10pt; padding-bottom: 0em; padding-right: 0em; padding-top: 0em;&quot;&gt;&lt;li&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;Cannot be instantiated.&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;So, can only be used through inheritance.&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; font-family: verdana, arial, helvetica; font-size: 10pt; text-align: justify;&quot;&gt;For example: In the&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;Vehicle&lt;/code&gt;&amp;nbsp;class example previously the&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;draw()&lt;/code&gt;&amp;nbsp;method may be defined as abstract as it is not really possible to draw a generic vehicle. By doing this we are forcing all derived classes to write a&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;draw()&lt;/code&gt;&amp;nbsp;method if they are to be instantiated.&lt;/div&gt;&lt;div style=&quot;background-color: white; font-family: verdana, arial, helvetica; font-size: 10pt; text-align: justify;&quot;&gt;As discussed previously, a class is like a set of plans from which you can create objects. In relation to this analogy, an abstract class is like a set of plans with some part of the plans missing. E.g. it could be a car with no engine - you would not be able to make complete car objects without the missing parts of the plan.&lt;/div&gt;&lt;div style=&quot;background-color: white; color: #d7ca35; font-family: verdana, arial, helvetica; font-size: 13px; padding-bottom: 10pt; padding-top: 10pt; text-align: center;&quot;&gt;&lt;a href=&quot;https://www.blogger.com/u/1/null&quot; name=&quot;abstractDraw&quot; style=&quot;color: black; text-decoration-line: underline;&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;&lt;b style=&quot;color: black; font-family: Verdana, Geneva, Helvetica; font-size: 10pt;&quot;&gt;Figure&amp;nbsp;1.11.&amp;nbsp;The abstract&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;draw()&lt;/code&gt;&amp;nbsp;method in the&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;Vehicle&lt;/code&gt;&amp;nbsp;class.&lt;/b&gt;&lt;/div&gt;&lt;img align=&quot;middle&quot; alt=&quot;The abstract draw() method in the Vehicle class.&quot; src=&quot;https://www.eeng.dcu.ie/~ee553/ee402notes/html/figures/abstractDraw.gif&quot; style=&quot;border-style: none;&quot; /&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; font-family: verdana, arial, helvetica; font-size: 10pt; text-align: justify;&quot;&gt;Figure 1.11&amp;nbsp;illustrates this example. The&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;draw()&lt;/code&gt;&amp;nbsp;has been written in all of the classes and has some functionality. The&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;draw()&lt;/code&gt;&amp;nbsp;in the&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;Vehicle&lt;/code&gt;&amp;nbsp;has been tagged as abstract and so this class cannot be instantiated - i.e. we cannot create an object of the&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;Vehicle&lt;/code&gt;&amp;nbsp;class, as it is incomplete. In Figure 1.11&amp;nbsp;the&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;SaloonCar&lt;/code&gt;&amp;nbsp;has no&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;draw()&lt;/code&gt;&amp;nbsp;method, but it does inherit a&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;draw()&lt;/code&gt;&amp;nbsp;method from the parent&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;Car&lt;/code&gt;&amp;nbsp;class. Therefore, it is possible to create objects of&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;SaloonCar&lt;/code&gt;.&lt;/div&gt;&lt;div style=&quot;background-color: white; font-family: verdana, arial, helvetica; font-size: 10pt; text-align: justify;&quot;&gt;If we required we could also tag the&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;draw()&lt;/code&gt;&amp;nbsp;method as abstract in a derived class, for example we could also have tagged the&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;draw()&lt;/code&gt;&amp;nbsp;as abstract in the&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;Car&lt;/code&gt;&amp;nbsp;class. This would mean that you could not create an object of the&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;Car&lt;/code&gt;&amp;nbsp;class and would pass on responsibility for implementing the&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;draw()&lt;/code&gt;&amp;nbsp;method to its children - see Figure 1.12.&lt;/div&gt;&lt;div style=&quot;padding-bottom: 10pt; padding-top: 10pt; text-align: center;&quot;&gt;&lt;div style=&quot;background-color: white; color: #d7ca35; font-family: verdana, arial, helvetica; font-size: 13px;&quot;&gt;&lt;a href=&quot;https://www.blogger.com/u/1/null&quot; name=&quot;abstractDraw2&quot; style=&quot;color: black; text-decoration-line: underline;&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: white; color: #d7ca35; font-family: verdana, arial, helvetica; font-size: 10pt;&quot;&gt;&lt;b style=&quot;color: black; font-family: Verdana, Geneva, Helvetica; font-size: 10pt;&quot;&gt;Figure&amp;nbsp;1.12.&amp;nbsp;The abstract&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;draw()&lt;/code&gt;&amp;nbsp;method in the&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;Vehicle&lt;/code&gt;&amp;nbsp;and&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;Car&lt;/code&gt;&amp;nbsp;classes.&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; color: #d7ca35; font-family: verdana, arial, helvetica; font-size: 10pt;&quot;&gt;&lt;a href=&quot;https://www.eeng.dcu.ie/~ee553/ee402notes/html/figures/abstractDraw2.gif&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; display: inline !important; font-size: 13px; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img align=&quot;middle&quot; alt=&quot;The abstract draw() method in the Vehicle and Car classes.&quot; border=&quot;0&quot; src=&quot;https://www.eeng.dcu.ie/~ee553/ee402notes/html/figures/abstractDraw2.gif&quot; style=&quot;border-style: none;&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; color: #d7ca35; font-family: verdana, arial, helvetica; font-size: 10pt;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;background-color: white; box-sizing: border-box; font-family: var(--font-family--heading); font-size: var(--font-size--h3); margin: 30px 0px 20px; text-align: left;&quot;&gt;&lt;span id=&quot;abstract-class-in-java-important-points&quot; style=&quot;box-sizing: border-box;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;u&gt;Abstract class in Java Important Points&lt;/u&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div style=&quot;background-color: white; color: #d7ca35; font-family: verdana, arial, helvetica; font-size: 10pt;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;main class=&quot;main__content blog-box&quot; style=&quot;box-sizing: border-box; flex: 1 1 auto; margin: 0px 50px; min-width: 0px; text-align: start;&quot;&gt;&lt;article class=&quot;post-1582 post type-post status-publish format-standard hentry category-java&quot; id=&quot;post-1582&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;div class=&quot;entry-content blog-post__contents&quot; style=&quot;box-sizing: border-box;&quot;&gt;&lt;ol style=&quot;box-sizing: border-box; list-style-position: inside; margin: 0px; padding: 0px 0px 0px 25px;&quot;&gt;&lt;li style=&quot;box-sizing: border-box; list-style: decimal; word-break: break-word;&quot;&gt;&lt;span style=&quot;color: white; font-family: monospace;&quot;&gt;&lt;span style=&quot;background-color: black;&quot;&gt;Abstract&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: var(--color--font--dark); font-family: synthese, sans-serif; font-size: small;&quot;&gt;&amp;nbsp;keyword is used to create an abstract class in java.&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;background-color: white; box-sizing: border-box; color: var(--color--font--dark); font-family: synthese, sans-serif; font-size: medium; list-style: decimal; margin-top: 5px; word-break: break-word;&quot;&gt;Abstract class in java can’t be instantiated.&lt;/li&gt;&lt;li style=&quot;box-sizing: border-box; list-style: decimal; margin-top: 5px; word-break: break-word;&quot;&gt;&lt;span style=&quot;background-color: white; color: var(--color--font--dark); font-family: synthese, sans-serif; font-size: small;&quot;&gt;We can use&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: white; font-family: monospace;&quot;&gt;&lt;span style=&quot;background-color: black;&quot;&gt;Abstract&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: synthese, sans-serif;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: rgba(0, 0, 0, 0);&quot;&gt;&amp;nbsp;&lt;/span&gt;keyword to create an abstract method, an abstract method doesn’t have body.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;background-color: white; box-sizing: border-box; color: var(--color--font--dark); font-family: synthese, sans-serif; font-size: medium; list-style: decimal; margin-top: 5px; word-break: break-word;&quot;&gt;If a class have abstract methods, then the class should also be abstract using abstract keyword, else it will not compile.&lt;/li&gt;&lt;li style=&quot;background-color: white; box-sizing: border-box; color: var(--color--font--dark); font-family: synthese, sans-serif; font-size: medium; list-style: decimal; margin-top: 5px; word-break: break-word;&quot;&gt;It’s not necessary for an abstract class to have abstract method. We can mark a class as abstract even if it doesn’t declare any abstract methods.&lt;/li&gt;&lt;li style=&quot;background-color: white; box-sizing: border-box; color: var(--color--font--dark); font-family: synthese, sans-serif; font-size: medium; list-style: decimal; margin-top: 5px; word-break: break-word;&quot;&gt;If abstract class doesn’t have any method implementation, its better to use interface because java doesn’t support multiple class inheritance.&lt;/li&gt;&lt;li style=&quot;background-color: white; box-sizing: border-box; color: var(--color--font--dark); font-family: synthese, sans-serif; font-size: medium; list-style: decimal; margin-top: 5px; word-break: break-word;&quot;&gt;The subclass of abstract class in java must implement all the abstract methods unless the subclass is also an abstract class.&lt;/li&gt;&lt;li style=&quot;background-color: white; box-sizing: border-box; color: var(--color--font--dark); font-family: synthese, sans-serif; font-size: medium; list-style: decimal; margin-top: 5px; word-break: break-word;&quot;&gt;All the methods in an interface are implicitly abstract unless the interface methods are static or default. Static methods and default methods in interfaces are added in&amp;nbsp;&lt;a href=&quot;https://www.journaldev.com/2389/java-8-features-with-examples&quot; style=&quot;box-sizing: border-box; color: #9b27b0; cursor: pointer; text-decoration-line: none;&quot;&gt;Java 8&lt;/a&gt;, for more details read&amp;nbsp;&lt;a href=&quot;https://www.journaldev.com/2752/java-8-interface-changes-static-method-default-method&quot; style=&quot;box-sizing: border-box; color: #9b27b0; cursor: pointer; text-decoration-line: none;&quot; title=&quot;Java 8 Interface Changes – static methods, default methods, functional Interfaces&quot;&gt;Java 8 interface changes&lt;/a&gt;.&lt;/li&gt;&lt;li style=&quot;background-color: white; box-sizing: border-box; color: var(--color--font--dark); font-family: synthese, sans-serif; font-size: medium; list-style: decimal; margin-top: 5px; word-break: break-word;&quot;&gt;Java Abstract class can implement interfaces without even providing the implementation of interface methods.&lt;/li&gt;&lt;li style=&quot;background-color: white; box-sizing: border-box; color: var(--color--font--dark); font-family: synthese, sans-serif; font-size: medium; list-style: decimal; margin-top: 5px; word-break: break-word;&quot;&gt;Java Abstract class is used to provide common method implementation to all the subclasses or to provide default implementation.&lt;/li&gt;&lt;li style=&quot;background-color: white; box-sizing: border-box; color: var(--color--font--dark); font-family: synthese, sans-serif; font-size: medium; list-style: decimal; margin-top: 5px; word-break: break-word;&quot;&gt;We can run abstract class in java like any other class if it has&amp;nbsp;&lt;code style=&quot;background-color: black; border-radius: 4px; box-sizing: border-box; color: white; font-size: 16px; margin: 0px 5px; padding: 3px;&quot;&gt;main()&lt;/code&gt;&amp;nbsp;method.&lt;/li&gt;&lt;/ol&gt;&lt;div style=&quot;background-color: white; box-sizing: border-box; color: var(--color--font--dark); font-family: synthese, sans-serif; font-size: medium; line-height: 24px; margin-bottom: 10px; margin-top: 10px; word-break: break-word;&quot;&gt;That’s all for an abstract class in Java. If I missed anything important, please let us know through comments.&lt;/div&gt;&lt;h2 style=&quot;background-color: white; box-sizing: border-box; color: var(--color--font--dark); font-family: synthese, sans-serif; font-size: medium; line-height: 24px; margin-bottom: 10px; margin-top: 10px; text-align: left; word-break: break-word;&quot;&gt;Example of abstract:&lt;/h2&gt;&lt;div style=&quot;box-sizing: border-box; line-height: 24px; margin-bottom: 10px; margin-top: 10px; word-break: break-word;&quot;&gt;&lt;span style=&quot;font-family: synthese, sans-serif;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;// An abstract class with constructor&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; line-height: 24px; margin-bottom: 10px; margin-top: 10px; word-break: break-word;&quot;&gt;&lt;span style=&quot;font-family: synthese, sans-serif;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;abstract class Base {&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; line-height: 24px; margin-bottom: 10px; margin-top: 10px; word-break: break-word;&quot;&gt;&lt;span style=&quot;font-family: synthese, sans-serif;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Base() { System.out.println(&quot;Base Constructor Called&quot;); }&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; line-height: 24px; margin-bottom: 10px; margin-top: 10px; word-break: break-word;&quot;&gt;&lt;span style=&quot;font-family: synthese, sans-serif;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;abstract void fun();&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; line-height: 24px; margin-bottom: 10px; margin-top: 10px; word-break: break-word;&quot;&gt;&lt;span style=&quot;font-family: synthese, sans-serif;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;}&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; line-height: 24px; margin-bottom: 10px; margin-top: 10px; word-break: break-word;&quot;&gt;&lt;span style=&quot;font-family: synthese, sans-serif;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;class Derived extends Base {&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; line-height: 24px; margin-bottom: 10px; margin-top: 10px; word-break: break-word;&quot;&gt;&lt;span style=&quot;font-family: synthese, sans-serif;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Derived() { System.out.println(&quot;Derived Constructor Called&quot;); }&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; line-height: 24px; margin-bottom: 10px; margin-top: 10px; word-break: break-word;&quot;&gt;&lt;span style=&quot;font-family: synthese, sans-serif;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;void fun() { System.out.println(&quot;Derived fun() called&quot;); }&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; line-height: 24px; margin-bottom: 10px; margin-top: 10px; word-break: break-word;&quot;&gt;&lt;span style=&quot;font-family: synthese, sans-serif;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;}&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; line-height: 24px; margin-bottom: 10px; margin-top: 10px; word-break: break-word;&quot;&gt;&lt;span style=&quot;font-family: synthese, sans-serif;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;class Main {&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; line-height: 24px; margin-bottom: 10px; margin-top: 10px; word-break: break-word;&quot;&gt;&lt;span style=&quot;font-family: synthese, sans-serif;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static void main(String args[]) {&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; line-height: 24px; margin-bottom: 10px; margin-top: 10px; word-break: break-word;&quot;&gt;&lt;span style=&quot;font-family: synthese, sans-serif;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Derived d = new Derived();&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; line-height: 24px; margin-bottom: 10px; margin-top: 10px; word-break: break-word;&quot;&gt;&lt;span style=&quot;font-family: synthese, sans-serif;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; line-height: 24px; margin-bottom: 10px; margin-top: 10px; word-break: break-word;&quot;&gt;&lt;span style=&quot;font-family: synthese, sans-serif;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;}&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Out&lt;span style=&quot;color: blue;&quot;&gt;put &lt;/span&gt;&lt;span style=&quot;color: #a00031; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;background-color: white; font-size: 15px;&quot;&gt;:&amp;nbsp; Base Constructor called&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;color: #a00031; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;background-color: white; font-size: 15px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Derived Constructor called&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;code-block code-block-6&quot; style=&quot;background-color: white; box-sizing: border-box; clear: both; color: black; font-family: synthese, sans-serif; font-size: medium; margin: 8px auto; text-align: center;&quot;&gt;&lt;ins class=&quot;adsbygoogle&quot; data-ad-client=&quot;ca-pub-6459403732537629&quot; data-ad-format=&quot;autorelaxed&quot; data-ad-slot=&quot;7381719979&quot; data-adsbygoogle-status=&quot;done&quot; style=&quot;box-sizing: border-box; display: block; height: 401px;&quot;&gt;&lt;ins id=&quot;aswift_0_expand&quot; style=&quot;background-color: transparent; border: none; box-sizing: border-box; display: inline-table; height: 401px; margin: 0px; padding: 0px; position: relative; visibility: visible; width: 669px;&quot;&gt;&lt;ins id=&quot;aswift_0_anchor&quot; style=&quot;background-color: transparent; border: none; box-sizing: border-box; display: block; height: 401px; margin: 0px; padding: 0px; position: relative; visibility: visible; width: 669px;&quot;&gt;&lt;iframe allowfullscreen=&quot;true&quot; allowtransparency=&quot;true&quot; frameborder=&quot;0&quot; height=&quot;401&quot; hspace=&quot;0&quot; id=&quot;aswift_0&quot; marginheight=&quot;0&quot; marginwidth=&quot;0&quot; name=&quot;aswift_0&quot; scrolling=&quot;no&quot; style=&quot;border-style: initial; border-width: 0px; box-sizing: border-box; height: 401px; left: 0px; position: absolute; top: 0px; width: 669px;&quot; vspace=&quot;0&quot; width=&quot;669&quot;&gt;&lt;/iframe&gt;&lt;/ins&gt;&lt;/ins&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/div&gt;&lt;/article&gt;&lt;div class=&quot;scriptlesssocialsharing&quot; style=&quot;background-color: white; box-sizing: border-box; color: black; font-family: synthese, sans-serif; font-size: medium; margin: 18px auto;&quot;&gt;&lt;div class=&quot;scriptlesssocialsharing__buttons&quot; style=&quot;box-sizing: border-box; display: flex; flex-wrap: wrap;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/main&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://javastories1.blogspot.com/feeds/6688430527632338832/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://javastories1.blogspot.com/2019/10/abstract-classes-abstract-class-is.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/542843703124727712/posts/default/6688430527632338832'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/542843703124727712/posts/default/6688430527632338832'/><link rel='alternate' type='text/html' href='https://javastories1.blogspot.com/2019/10/abstract-classes-abstract-class-is.html' title=''/><author><name>Alpha programming</name><uri>http://www.blogger.com/profile/01668624719714063369</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//2.bp.blogspot.com/-UMN6IyPVjNk/Xbr2Eb5gkOI/AAAAAAAAQiM/R-qqJWSSfW4FjdEsfBGLROFcBACZDEXkgCK4BGAYYCw/s220/IMG_20180206_191342_508.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-542843703124727712.post-3480953138806121681</id><published>2019-10-31T11:44:00.001-07:00</published><updated>2019-10-31T11:44:09.944-07:00</updated><title type='text'></title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div style=&quot;font-family: Verdana, Helvetica, Arial, sans-serif; font-size: 13px; text-align: justify;&quot;&gt;&lt;h1 class=&quot;h1&quot; style=&quot;background-color: white; color: #610b38; font-family: erdana, helvetica, arial, sans-serif; font-size: 29px; line-height: 1.3em; margin-top: 5px; text-align: start;&quot;&gt;Polymorphism in Java&lt;/h1&gt;&lt;h2 style=&quot;background-color: white; color: #333333; font-family: &amp;quot;Trebuchet MS&amp;quot;, arial, sans-serif; margin: 1em 0px 0.5em;&quot;&gt;&lt;div style=&quot;color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400; text-align: start;&quot;&gt;&lt;strong&gt;Polymorphism in Java&lt;/strong&gt;&amp;nbsp;is a concept by which we can perform a&amp;nbsp;&lt;em&gt;single action in different ways&lt;/em&gt;. Polymorphism is derived from 2 Greek words: poly and morphs. The word &quot;poly&quot; means many and &quot;morphs&quot; means forms. So polymorphism means many forms.&lt;/div&gt;&lt;div style=&quot;color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400; text-align: start;&quot;&gt;There are two types of polymorphism in Java: compile-time polymorphism and runtime polymorphism. We can perform polymorphism in java by method overloading and method overriding.&lt;/div&gt;&lt;div style=&quot;color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400; text-align: start;&quot;&gt;If you overload a static method in Java, it is the example of compile time polymorphism. Here, we will focus on runtime polymorphism in java.&lt;/div&gt;&lt;div style=&quot;color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400; text-align: start;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400; text-align: start;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/h2&gt;&lt;h4 style=&quot;background-color: white; color: #610b38; font-family: erdana, helvetica, arial, sans-serif; font-size: 25px; font-weight: 400; line-height: 1.3em; text-align: left;&quot;&gt;Runtime Polymorphism in Java&lt;/h4&gt;&lt;h2 style=&quot;background-color: white; color: #333333; font-family: &amp;quot;Trebuchet MS&amp;quot;, arial, sans-serif; margin: 1em 0px 0.5em;&quot;&gt;&lt;div style=&quot;color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400; text-align: start;&quot;&gt;&lt;strong&gt;Runtime polymorphism&lt;/strong&gt;&amp;nbsp;or&amp;nbsp;&lt;strong&gt;Dynamic Method Dispatch&lt;/strong&gt;&amp;nbsp;is a process in which a call to an overridden method is resolved at runtime rather than compile-time.&lt;/div&gt;&lt;div style=&quot;color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400; text-align: start;&quot;&gt;In this process, an overridden method is called through the reference variable of a superclass. The determination of the method to be called is based on the object being referred to by the reference variable.&amp;nbsp;&lt;/div&gt;&lt;/h2&gt;&lt;h3 class=&quot;h3ex&quot; style=&quot;background-color: white; color: #610b4b; font-family: tahoma; font-size: 22px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: 400; line-height: normal; text-align: start;&quot;&gt;Example of Java Runtime Polymorphism&lt;/h3&gt;&lt;h2 style=&quot;font-family: &amp;quot;Trebuchet MS&amp;quot;, arial, sans-serif; margin: 1em 0px 0.5em;&quot;&gt;&lt;div style=&quot;background-color: white; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400; text-align: start;&quot;&gt;In this example, we are creating two classes Bike and Splendor. Splendor class extends Bike class and overrides its run() method. We are calling the run method by the reference variable of Parent class. Since it refers to the subclass object and subclass method overrides the Parent class method, the subclass method is invoked at runtime.&lt;/div&gt;&lt;div style=&quot;background-color: white; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400; text-align: start;&quot;&gt;Since method invocation is determined by the JVM not compiler, it is known as runtime polymorphism.&lt;/div&gt;&lt;div style=&quot;background-color: white; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400; text-align: start;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400; text-align: start;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;class Bike {&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400; text-align: start;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400; text-align: start;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;void run()system.out.println(&quot;running&quot;);}&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400; text-align: start;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400; text-align: start;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;class Hayabusha extends Bike {&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400; text-align: start;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;void run()&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400; text-align: start;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400; text-align: start;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;system.out.println(&quot;running safely with 60km&quot;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400; text-align: start;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400; text-align: start;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;public static void main(string args[])&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400; text-align: start;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400; text-align: start;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;Bike b = new Hayabusha();&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400; text-align: start;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;b.run();&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400; text-align: start;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400; text-align: start;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400; text-align: start;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; text-align: start;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;Out&lt;span style=&quot;color: blue;&quot;&gt;put : &lt;/span&gt;running safely with 60km&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400; text-align: start;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/h2&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://javastories1.blogspot.com/feeds/3480953138806121681/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://javastories1.blogspot.com/2019/10/polymorphism-in-java-polymorphism-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/542843703124727712/posts/default/3480953138806121681'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/542843703124727712/posts/default/3480953138806121681'/><link rel='alternate' type='text/html' href='https://javastories1.blogspot.com/2019/10/polymorphism-in-java-polymorphism-in.html' title=''/><author><name>Alpha programming</name><uri>http://www.blogger.com/profile/01668624719714063369</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//2.bp.blogspot.com/-UMN6IyPVjNk/Xbr2Eb5gkOI/AAAAAAAAQiM/R-qqJWSSfW4FjdEsfBGLROFcBACZDEXkgCK4BGAYYCw/s220/IMG_20180206_191342_508.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-542843703124727712.post-6892658796410503416</id><published>2019-10-31T10:33:00.000-07:00</published><updated>2019-10-31T10:33:02.141-07:00</updated><title type='text'></title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;h4 style=&quot;box-sizing: border-box; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 18px; line-height: 1.1; margin-bottom: 10px; margin-top: 10px; text-align: left;&quot;&gt;&lt;u style=&quot;background-color: #999999;&quot;&gt;Object Oriented Programming in JAVA&lt;/u&gt;&lt;/h4&gt;&lt;div&gt;&lt;div style=&quot;background-color: white; font-family: verdana, arial, helvetica; font-size: 13px; line-height: normal; text-align: justify;&quot;&gt;&lt;span style=&quot;background-image: none; color: #404040; font-size: 10pt; font-weight: bold;&quot;&gt;Object-Oriented Programming (OOP)&lt;/span&gt;&amp;nbsp;is the term used to describe a programming approach based on&amp;nbsp;&lt;span style=&quot;background-image: none; color: #404040; font-size: 10pt; font-weight: bold;&quot;&gt;objects&lt;/span&gt;&amp;nbsp;and&amp;nbsp;&lt;span style=&quot;background-image: none; color: #404040; font-size: 10pt; font-weight: bold;&quot;&gt;classes&lt;/span&gt;. The object-oriented example allows us to organised software as a collection of objects that consist of both data and behaviour. This is in contrast to conventional functional programming practice that only loosely connects data and behaviour.&lt;/div&gt;&lt;div style=&quot;background-color: white; font-family: verdana, arial, helvetica; font-size: 13px; line-height: normal; text-align: justify;&quot;&gt;Since the 1980&#39;s the word &#39;&lt;b&gt;object&lt;/b&gt;&#39; has appeared in relation to programming languages, with almost all languages developed since 1990 having object-oriented features. Some languages have even had object-oriented features retro-fitted. It is widely accepted that object-oriented programming is the most important and powerful way of creating software.&lt;/div&gt;&lt;div style=&quot;background-color: white; font-family: verdana, arial, helvetica; font-size: 13px; line-height: normal; text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; font-family: verdana, arial, helvetica; font-size: 13px; line-height: normal; text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;font-family: verdana, arial, helvetica; font-size: 13px; line-height: normal; text-align: justify;&quot;&gt;&lt;b style=&quot;background-color: #f4cccc;&quot;&gt;Notes :&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; font-family: verdana, arial, helvetica; font-size: 13px; line-height: normal; text-align: justify;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;ul style=&quot;background-color: white; font-family: verdana, arial, helvetica; font-size: 10pt; padding-bottom: 0em; padding-right: 0em; padding-top: 0em; text-align: justify;&quot;&gt;&lt;li&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;Modularisation : where the application can be decomposed into modules.&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;Software re-use: where an application can be composed from existing and new modules.&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot;;&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;div style=&quot;background-color: white; font-family: verdana, arial, helvetica; font-size: 13px; line-height: normal;&quot;&gt;&lt;u&gt;&lt;b&gt;An object-oriented programming language generally supports five main features&lt;/b&gt;&lt;/u&gt;:&lt;/div&gt;&lt;div style=&quot;line-height: normal;&quot;&gt;&lt;ul style=&quot;background-color: white; color: black; font-family: verdana, arial, helvetica; font-size: 10pt; padding-bottom: 0em; padding-right: 0em; padding-top: 0em;&quot;&gt;&lt;li&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;Classes&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;background-color: white; color: black; font-family: verdana, arial, helvetica; font-size: 10pt; padding-bottom: 0em; padding-right: 0em; padding-top: 0em;&quot;&gt;&lt;li&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;Objects&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;background-color: white; color: black; font-family: verdana, arial, helvetica; font-size: 10pt; padding-bottom: 0em; padding-right: 0em; padding-top: 0em;&quot;&gt;&lt;li&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;Classification&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;background-color: white; color: black; font-family: verdana, arial, helvetica; font-size: 10pt; padding-bottom: 0em; padding-right: 0em; padding-top: 0em;&quot;&gt;&lt;li&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;Polymorphism&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h4 style=&quot;background-color: white;&quot;&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;Inheritance&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;/div&gt;&lt;/h4&gt;&lt;h2 style=&quot;border-style: none; border-width: medium; clear: both; font-family: verdana, arial, helvetica; font-size: 14pt; line-height: 19px; margin: 8px 0px 10px; text-align: left;&quot;&gt;&lt;span style=&quot;background-color: black; color: lime;&quot;&gt;An Object-Oriented Class&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;div style=&quot;background-color: white; font-family: verdana, arial, helvetica; font-size: 13px;&quot;&gt;&lt;h2 style=&quot;border-style: none; border-width: medium; clear: both; font-size: 14pt; line-height: 19px; margin: 8px 0px 10px; text-align: left;&quot;&gt;&lt;/h2&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; font-family: verdana, arial, helvetica; font-size: 13px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;If we think of a real-world object, such as a television as in figure 1.1 , it will have several&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;features and properties:&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;background-color: white; font-family: verdana, arial, helvetica; font-size: 10pt; padding-bottom: 0em; padding-right: 0em; padding-top: 0em;&quot;&gt;&lt;li&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;We do not have to open the case to use it.&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;We have some controls to use it (buttons on the box, or a remote control).&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;We can still understand the concept of a television, even if it is connected to a DVD player.&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;It is complete when we purchase it, with any external requirements well documented.&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;The TV will not crash!&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style=&quot;background-color: white; font-family: verdana, arial, helvetica;&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; font-family: verdana, arial, helvetica;&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;background-color: white; clear: both; font-family: verdana, arial, helvetica; text-align: center;&quot;&gt;&lt;a href=&quot;https://1.bp.blogspot.com/-YQyASD2FN1Q/XbsSPdN5kFI/AAAAAAAAQi0/lCCOrm2fORQmy1v-v678Y0z6aStSGkN9ACLcBGAsYHQ/s1600/tv.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;863&quot; data-original-width=&quot;1023&quot; height=&quot;269&quot; src=&quot;https://1.bp.blogspot.com/-YQyASD2FN1Q/XbsSPdN5kFI/AAAAAAAAQi0/lCCOrm2fORQmy1v-v678Y0z6aStSGkN9ACLcBGAsYHQ/s320/tv.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; font-family: verdana, arial, helvetica;&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; font-family: verdana, arial, helvetica;&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&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; Television Figure 1.1&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; font-family: verdana, arial, helvetica;&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; font-family: verdana, arial, helvetica;&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; font-family: verdana, arial, helvetica;&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: white; font-family: verdana, arial, helvetica; font-size: 13px;&quot;&gt;A class should:&lt;/div&gt;&lt;div style=&quot;background-color: white; font-family: verdana, arial, helvetica; font-size: 13px;&quot;&gt;&lt;ul style=&quot;font-size: 10pt; padding-bottom: 0em; padding-right: 0em; padding-top: 0em;&quot;&gt;&lt;li&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;Provide a well-defined interface - such as the remote control of the television.&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;Represent a clear concept - such as the concept of a television.&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;Be complete and well-documented - the television should have a plug and should have a manual that documents all features.&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;The code should be robust - it should not crash, like the television.&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; font-family: verdana, arial, helvetica; font-size: 13px;&quot;&gt;With a functional programming language (like C) we would have the component parts of the television scattered everywhere and we would be responsible for making them work correctly - there would be no case surrounding the electronic components.&lt;/div&gt;&lt;div style=&quot;background-color: white; font-family: verdana, arial, helvetica; font-size: 13px;&quot;&gt;Humans use class based descriptions all the time - what is a duck? (Think about this, we will discuss it soon.)&lt;/div&gt;&lt;div style=&quot;background-color: white; font-family: verdana, arial, helvetica; font-size: 13px;&quot;&gt;Classes allow us a way to represent complex structures within a programming language. They have two components:&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;background-color: white; font-family: verdana, arial, helvetica; font-size: 10pt; padding-bottom: 0em; padding-right: 0em; padding-top: 0em;&quot;&gt;&lt;li&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;&lt;span style=&quot;background-image: none; font-size: 10pt; font-weight: bold;&quot;&gt;&lt;span style=&quot;color: #e06666;&quot;&gt;States&lt;/span&gt;&lt;/span&gt;&amp;nbsp;- (or data) are the values that the object has.&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;&lt;span style=&quot;background-image: none; font-size: 10pt; font-weight: bold;&quot;&gt;&lt;span style=&quot;color: #e06666;&quot;&gt;Methods&lt;/span&gt;&lt;/span&gt;&amp;nbsp;- (or behaviour) are the ways in which the object can interact with its data, the actions.&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style=&quot;background-color: white; font-family: verdana, arial, helvetica;&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; font-family: verdana, arial, helvetica;&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; font-family: verdana, arial, helvetica;&quot;&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;font-family: verdana, arial, helvetica; font-size: 13px;&quot;&gt;&lt;h2 style=&quot;border-style: none; border-width: medium; clear: both; font-size: 14pt; line-height: 19px; margin: 8px 0px 10px; text-align: left;&quot;&gt;&lt;span style=&quot;background-color: black; color: lime;&quot;&gt;An Object&lt;/span&gt;&lt;/h2&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; font-family: verdana, arial, helvetica; font-size: 13px;&quot;&gt;An&amp;nbsp;&lt;span style=&quot;background-image: none; color: #404040; font-size: 10pt; font-weight: bold;&quot;&gt;object&lt;/span&gt;&amp;nbsp;is an instance of a class. You could think of a class as the description of a concept, and an object as the realisation of this description to create an independent distinguishable entity. For example, in the case of the Television, the class is the set of plans (or blueprints) for a generic television, whereas a television object is the realisation of these plans into a real-world physical television. So there would be one set of plans (the class), but there could be thousands of real-world televisions (objects).&lt;/div&gt;&lt;div style=&quot;background-color: white; font-family: verdana, arial, helvetica; font-size: 13px;&quot;&gt;&lt;div style=&quot;clear: right; color: #d7ca35; float: right; margin-bottom: 1em; margin-left: 1em; padding-bottom: 10pt; padding-top: 10pt; text-align: center;&quot;&gt;&lt;a href=&quot;https://www.blogger.com/u/1/null&quot; name=&quot;encapsulation&quot; style=&quot;color: black; text-decoration-line: underline;&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;&lt;b style=&quot;color: black; font-family: Verdana, Geneva, Helvetica; font-size: 10pt;&quot;&gt;&amp;nbsp;class example showing encapsulation.&lt;/b&gt;&lt;/div&gt;&lt;img align=&quot;middle&quot; alt=&quot;The Television class example showing encapsulation.&quot; src=&quot;https://www.eeng.dcu.ie/~ee553/ee402notes/html/figures/encapsulation.gif&quot; style=&quot;border-style: none;&quot; /&gt;&lt;/div&gt;Objects can be concrete (a real-world object, a file on a computer) or could be conceptual (such as a database structure) each with its own individual identity.Figure 1.2 shows an example where the&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;Television&amp;nbsp;&lt;/code&gt;class description is realised into several television objects. These objects should have their own identity and are independent from each other. For example, if the channel is changed on one television it will not change on the other televisions.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://1.bp.blogspot.com/--9et9hXnxKM/XbsVEGAK3VI/AAAAAAAAQjA/DRi5fTa6mso3azi4Xl59iiaWl_1SfdNJQCLcBGAsYHQ/s1600/televisionObjects.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;281&quot; data-original-width=&quot;528&quot; height=&quot;170&quot; src=&quot;https://1.bp.blogspot.com/--9et9hXnxKM/XbsVEGAK3VI/AAAAAAAAQjA/DRi5fTa6mso3azi4Xl59iiaWl_1SfdNJQCLcBGAsYHQ/s320/televisionObjects.gif&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&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; &lt;br /&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; Figure 1.2&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;padding-bottom: 10pt; padding-top: 10pt; text-align: center;&quot;&gt;&lt;div&gt;&lt;div style=&quot;background-color: white; color: black; font-family: verdana, arial, helvetica; font-size: 13px; text-align: justify;&quot;&gt;&lt;h2 style=&quot;color: #333333; font-family: &amp;quot;Trebuchet MS&amp;quot;, arial, sans-serif; margin: 1em 0px 0.5em;&quot;&gt;&lt;u&gt;Encapsulation:&lt;/u&gt;&lt;/h2&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; color: black; font-family: verdana, arial, helvetica; font-size: 10pt; text-align: justify;&quot;&gt;The object-oriented paradigm encourages encapsulation. Encapsulation is used to hide the mechanics of the object, allowing the actual implementation of the object to be hidden, so that we don&#39;t need to understand how the object works. All we need to understand is the interface that is provided for us.&lt;/div&gt;&lt;div style=&quot;background-color: white; color: black; font-family: verdana, arial, helvetica; font-size: 10pt; text-align: justify;&quot;&gt;You can think of this in the case of the&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;Television&lt;/code&gt;&amp;nbsp;class, where the functionality of the television is hidden from us, but we are provided with a remote control, or set of controls for interacting with the television, providing a high level of abstraction. So, as in Figure 1.3 there is no requirement to understand how the signal is decoded from the aerial and converted into a picture to be displayed on the screen before you can use the television.&lt;/div&gt;&lt;div style=&quot;background-color: white; color: black; font-family: verdana, arial, helvetica; font-size: 10pt; text-align: justify;&quot;&gt;There is a sub-set of functionality that the user is allowed to call, termed the interface. In the case of the television, this would be the functionality that we could use through the remote control or buttons on the front of the television.&lt;/div&gt;&lt;div style=&quot;background-color: white; color: black; font-family: verdana, arial, helvetica; font-size: 10pt; text-align: justify;&quot;&gt;The full implemenation of a class is the sum of the public interface plus the private implementation.&lt;/div&gt;&lt;div style=&quot;background-color: white; color: #d7ca35; font-family: verdana, arial, helvetica; font-size: 13px; padding-bottom: 10pt; padding-top: 10pt;&quot;&gt;&lt;a href=&quot;https://www.blogger.com/u/1/null&quot; name=&quot;televisionInterface&quot; style=&quot;color: black; text-decoration-line: underline;&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;&lt;b style=&quot;color: black; font-family: Verdana, Geneva, Helvetica; font-size: 10pt;&quot;&gt;Figure&amp;nbsp;1.3.&amp;nbsp;The&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;Television&lt;/code&gt;&amp;nbsp;interface example.&lt;/b&gt;&lt;/div&gt;&lt;img align=&quot;middle&quot; alt=&quot;The Television interface example.&quot; src=&quot;https://www.eeng.dcu.ie/~ee553/ee402notes/html/figures/televisionInterface.gif&quot; style=&quot;border-style: none;&quot; /&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; color: black; font-family: verdana, arial, helvetica; font-size: 10pt; text-align: justify;&quot;&gt;Encapsulation is the term used to describe the way that the interface is separated from the implementation. You can think of encapsulation as &quot;data-hiding&quot;, allowing certain parts of an object to be visible, while other parts remain hidden. This has advantages for both the user and the programmer.&lt;/div&gt;&lt;div style=&quot;background-color: white; color: black; font-family: verdana, arial, helvetica; font-size: 10pt; text-align: justify;&quot;&gt;For the user (who could be another programmer):&lt;/div&gt;&lt;div style=&quot;background-color: white; color: black; font-family: verdana, arial, helvetica; font-size: 13px; text-align: justify;&quot;&gt;&lt;ul style=&quot;font-size: 10pt; padding-bottom: 0em; padding-right: 0em; padding-top: 0em;&quot;&gt;&lt;li&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;The user need only understand the interface.&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;The user need not understand how the implementation works or was created.&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; color: black; font-family: verdana, arial, helvetica; font-size: 10pt; text-align: justify;&quot;&gt;For the programmer:&lt;/div&gt;&lt;div style=&quot;background-color: white; color: black; font-family: verdana, arial, helvetica; font-size: 13px; text-align: justify;&quot;&gt;&lt;ul style=&quot;font-size: 10pt; padding-bottom: 0em; padding-right: 0em; padding-top: 0em;&quot;&gt;&lt;li&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;The programmer can change the implementation, but need not notify the user.&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; color: black; font-family: verdana, arial, helvetica; font-size: 10pt; text-align: justify;&quot;&gt;So, providing the programmer does not change the interface in any way, the user will be unaware of any changes, except maybe a minor change in the actual functionality of the application.&lt;/div&gt;&lt;div style=&quot;background-color: white; color: black; font-family: verdana, arial, helvetica; font-size: 10pt; text-align: justify;&quot;&gt;We can identify a level of &#39;hiding&#39; of particular methods or states within a class using the&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;public&lt;/code&gt;,&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;private&lt;/code&gt;&amp;nbsp;and&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;protected&lt;/code&gt;&amp;nbsp;keywords:&lt;/div&gt;&lt;div style=&quot;background-color: white; color: black; font-family: verdana, arial, helvetica; font-size: 13px; text-align: justify;&quot;&gt;&lt;ul style=&quot;font-size: 10pt; padding-bottom: 0em; padding-right: 0em; padding-top: 0em;&quot;&gt;&lt;li&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;&lt;code style=&quot;color: #006000;&quot;&gt;public&lt;/code&gt;&amp;nbsp;methods - describe the interface.&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;&lt;code style=&quot;color: #006000;&quot;&gt;private&lt;/code&gt;&amp;nbsp;methods - describe the implementation.&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; color: black; font-family: verdana, arial, helvetica; font-size: 10pt; text-align: justify;&quot;&gt;Figure 1.4 shows encapsulation as it relates to the&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;Television&lt;/code&gt;&amp;nbsp;class. According to UML notation private methods are denoted with a minus sign and public methods are denoted with a plus sign. The private methods would be methods written that are part of the inner workings of the television, but need not be understood by the user. For example, the user would need to call the&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;powerOn()&lt;/code&gt;&amp;nbsp;method but the private&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;displayPicture()&lt;/code&gt;&amp;nbsp;method would also be called, but internally as required, not directly by the user. This method is therefore not added to the interface, but hidden internally in the implementation by using the&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;private&lt;/code&gt;&amp;nbsp;keyword.&lt;/div&gt;&lt;div style=&quot;background-color: white; font-size: 10pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-size: 10pt; text-align: center;&quot;&gt;&lt;code&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot;;&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;&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; font-size: 10pt; text-align: justify;&quot;&gt;&lt;span style=&quot;font-size: 10pt; text-align: center;&quot;&gt;&lt;code style=&quot;color: #006000; font-family: Verdana, Geneva, Helvetica; font-weight: bold;&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;Television&lt;/code&gt;&lt;b style=&quot;color: black; font-family: Verdana, Geneva, Helvetica;&quot;&gt;&amp;nbsp;class example showing encapsulation.&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; color: #d7ca35; font-family: verdana, arial, helvetica; font-size: 13px; padding-bottom: 10pt; padding-top: 10pt;&quot;&gt;&lt;img align=&quot;middle&quot; alt=&quot;The Television class example showing encapsulation.&quot; src=&quot;https://www.eeng.dcu.ie/~ee553/ee402notes/html/figures/encapsulation.gif&quot; style=&quot;border-style: none;&quot; /&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; font-family: verdana, arial, helvetica; font-size: 13px; padding-bottom: 10pt; padding-top: 10pt;&quot;&gt;Figure 1.4&lt;/div&gt;&lt;div style=&quot;background-color: white; font-family: verdana, arial, helvetica; font-size: 13px; padding-bottom: 10pt; padding-top: 10pt;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;font-family: &amp;quot;Trebuchet MS&amp;quot;, arial, sans-serif; font-size: 10pt; margin: 1em 0px 0.5em; text-align: justify;&quot;&gt;&lt;span style=&quot;background-color: black; color: lime;&quot;&gt;Inheritance&lt;/span&gt;&lt;/h2&gt;&lt;div style=&quot;background-color: white; font-family: verdana, arial, helvetica; font-size: 13px; padding-bottom: 10pt; padding-top: 10pt;&quot;&gt;If we have several descriptions with some commonality between these descriptions, we can group the descriptions and their commonality using inheritance to provide a compact representation of these descriptions. The object-oriented programming approach allows us to group the commonalities and create classes that can describe their differences from other classes.&lt;/div&gt;&lt;div style=&quot;background-color: white; font-family: verdana, arial, helvetica; padding-bottom: 10pt; padding-top: 10pt;&quot;&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;Humans use this concept in categorised objects and descriptions. For example you may have answered the question - &quot;What is a duck?&quot;, with &quot;a bird that swims&quot;, or even more accurately, &quot;a bird that swims, with webbed feet, and a bill instead of a beak&quot;. So we could say that a Duck is a Bird that swims, so we could describe this as in Figure 1.5. This figure illustrates the inheritance relationship between a&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;Duck&lt;/code&gt;&amp;nbsp;and a&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;Bird&lt;/code&gt;. In effect we can say that a&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;Duck&lt;/code&gt;&amp;nbsp;is a special type of&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;Bird&lt;/code&gt;.&lt;/div&gt;&lt;div style=&quot;color: #d7ca35; font-size: 13px; padding-bottom: 10pt; padding-top: 10pt;&quot;&gt;&lt;a href=&quot;https://www.blogger.com/u/1/null&quot; name=&quot;duckinheritance&quot; style=&quot;color: black; text-decoration-line: underline;&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;&lt;b style=&quot;color: black; font-family: Verdana, Geneva, Helvetica; font-size: 10pt;&quot;&gt;Figure&amp;nbsp;1.5.&amp;nbsp;The&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;Duck&lt;/code&gt;&amp;nbsp;class showing inheritance.&lt;/b&gt;&lt;/div&gt;&lt;img align=&quot;middle&quot; alt=&quot;The Duck class showing inheritance.&quot; src=&quot;https://www.eeng.dcu.ie/~ee553/ee402notes/html/figures/duckinheritance.gif&quot; style=&quot;border-style: none;&quot; /&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;For example: if were to be given an unstructured group of descriptions such as Car, Saloon, Estate, Van, Vehicle, Motorbike and Scooter, and asked to organise these descriptions by their differences. You might say that a Saloon car is a Car but has a long boot, whereas an Estate car is a car with a very large boot.&amp;nbsp;Figure 1.6 shows an example of how we may organise these descriptions using inheritance.&lt;/div&gt;&lt;div style=&quot;color: #d7ca35; font-size: 13px; padding-bottom: 10pt; padding-top: 10pt;&quot;&gt;&lt;a href=&quot;https://www.blogger.com/u/1/null&quot; name=&quot;groupOfClasses&quot; style=&quot;color: black; text-decoration-line: underline;&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;&lt;b style=&quot;color: black; font-family: Verdana, Geneva, Helvetica; font-size: 10pt;&quot;&gt;Figure&amp;nbsp;1.6.&amp;nbsp;The grouped set of classes.&lt;/b&gt;&lt;/div&gt;&lt;img align=&quot;middle&quot; alt=&quot;The grouped set of classes.&quot; src=&quot;https://www.eeng.dcu.ie/~ee553/ee402notes/html/figures/groupOfClasses.gif&quot; style=&quot;border-style: none;&quot; /&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;So we can describe this relationship as a child/parent relationship, where Figure 1.7 illustrates the relationship between a base class and a derived class. A derived class inherits from a base class, so in Figure 1.6 the&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;Car&lt;/code&gt;&amp;nbsp;class is a child of the&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;Vehicle&lt;/code&gt;&amp;nbsp;class, so&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;Car&lt;/code&gt;&amp;nbsp;inherits from&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;Vehicle&lt;/code&gt;.&lt;/div&gt;&lt;div style=&quot;color: #d7ca35; font-size: 13px; padding-bottom: 10pt; padding-top: 10pt;&quot;&gt;&lt;a href=&quot;https://www.blogger.com/u/1/null&quot; name=&quot;baseClass&quot; style=&quot;color: black; text-decoration-line: underline;&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;&lt;b style=&quot;color: black; font-family: Verdana, Geneva, Helvetica; font-size: 10pt;&quot;&gt;Figure&amp;nbsp;1.7.&amp;nbsp;The Base class and Derived class.&lt;/b&gt;&lt;/div&gt;&lt;img align=&quot;middle&quot; alt=&quot;The Base class and Derived class.&quot; src=&quot;https://www.eeng.dcu.ie/~ee553/ee402notes/html/figures/baseClass.gif&quot; style=&quot;border-style: none;&quot; /&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;One way to determine that you have organised your classes correctly is to check them using the&amp;nbsp;&lt;span style=&quot;background-image: none; color: #404040; font-size: 10pt; font-weight: bold;&quot;&gt;&quot;IS-A&quot;&lt;/span&gt;&amp;nbsp;and&amp;nbsp;&lt;span style=&quot;background-image: none; color: #404040; font-size: 10pt; font-weight: bold;&quot;&gt;&quot;IS-A-PART-OF&quot;&lt;/span&gt;&amp;nbsp;relationship checks. It is easy to confuse objects within a class and children of classes when you first begin programming with an OOP methodology. So, to check the previous relationship between&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;Car&lt;/code&gt;&amp;nbsp;and&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;Vehicle&lt;/code&gt;, we can see this in Figure 1.8.&lt;/div&gt;&lt;div style=&quot;color: #d7ca35; font-size: 13px; padding-bottom: 10pt; padding-top: 10pt;&quot;&gt;&lt;a href=&quot;https://www.blogger.com/u/1/null&quot; name=&quot;vehicleISA&quot; style=&quot;color: black; text-decoration-line: underline;&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;&lt;b style=&quot;color: black; font-family: Verdana, Geneva, Helvetica; font-size: 10pt;&quot;&gt;Figure&amp;nbsp;1.8.&amp;nbsp;The IS-A/IS-A-PART-OF relationships and the&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;Vehicle&lt;/code&gt;&amp;nbsp;class.&lt;/b&gt;&lt;/div&gt;&lt;img align=&quot;middle&quot; alt=&quot;The IS-A/IS-A-PART-OF relationships and the Vehicle class.&quot; src=&quot;https://www.eeng.dcu.ie/~ee553/ee402notes/html/figures/vehicleISA.gif&quot; style=&quot;border-style: none;&quot; /&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;The IS-A relationship describes the inheritance in the figure, where we can say, &quot;A Car IS-A Vehicle&quot; and &quot;A SaloonCar IS-A Car&quot;, so all relationships are correct. The IS-A-PART-OF relationship describes the composition (or aggregation) of a class. So in the same figure (Figure 1.9) we can say &quot;An Engine IS-A-PART-OF a Vehicle&quot;, or &quot;An Engine, Colour and Wheels IS-A-PART-OF a Vehicle&quot;. This is the case even though an Engine is also a class! where there could be many different descriptions of an Engine - petrol, diesel, 1.4, 2.0, 16 valve etc.&lt;/div&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;So, using inheritance the programmer can:&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;font-size: 10pt; padding-bottom: 0em; padding-right: 0em; padding-top: 0em;&quot;&gt;&lt;li&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;Inherit a behaviour and add further specialised behaviour - for example a&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;Car&lt;/code&gt;&amp;nbsp;IS A&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;Vehicle&lt;/code&gt;&amp;nbsp;with the addition of four&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;Wheel&lt;/code&gt;&amp;nbsp;objects, Seats etc.&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;Inherit a behaviour and replace it - for example the&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;SaloonCar&lt;/code&gt;&amp;nbsp;class will inherit from&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;Car&lt;/code&gt;&amp;nbsp;and provide a new &quot;boot&quot; implementation.&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;Cut down on the amount of code that needs to be written and debugged - for example in this case only the differences are detailed, a&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;SaloonCar&lt;/code&gt;&amp;nbsp;is essentially identical to the&amp;nbsp;&lt;code style=&quot;color: #006000;&quot;&gt;Car&lt;/code&gt;, with only the differences requiring description.&lt;/div&gt;&lt;div style=&quot;font-size: 10pt;&quot;&gt;&lt;br style=&quot;font-size: 13.3333px; text-align: justify;&quot; /&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 13.3333px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; font-family: verdana, arial, helvetica; font-size: 13px; padding-bottom: 10pt; padding-top: 10pt;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; color: #d7ca35; font-family: verdana, arial, helvetica; font-size: 13px; padding-bottom: 10pt; padding-top: 10pt;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://javastories1.blogspot.com/feeds/6892658796410503416/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://javastories1.blogspot.com/2019/10/object-oriented-programming-in-java.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/542843703124727712/posts/default/6892658796410503416'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/542843703124727712/posts/default/6892658796410503416'/><link rel='alternate' type='text/html' href='https://javastories1.blogspot.com/2019/10/object-oriented-programming-in-java.html' title=''/><author><name>Alpha programming</name><uri>http://www.blogger.com/profile/01668624719714063369</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//2.bp.blogspot.com/-UMN6IyPVjNk/Xbr2Eb5gkOI/AAAAAAAAQiM/R-qqJWSSfW4FjdEsfBGLROFcBACZDEXkgCK4BGAYYCw/s220/IMG_20180206_191342_508.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://1.bp.blogspot.com/-YQyASD2FN1Q/XbsSPdN5kFI/AAAAAAAAQi0/lCCOrm2fORQmy1v-v678Y0z6aStSGkN9ACLcBGAsYHQ/s72-c/tv.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-542843703124727712.post-3759045426809694709</id><published>2019-10-31T09:12:00.007-07:00</published><updated>2019-10-31T09:16:40.995-07:00</updated><title type='text'></title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;h1 id=&quot;h1&quot; style=&quot;background-color: white; color: #610b38; font-family: erdana, helvetica, arial, sans-serif; font-size: 26px; font-weight: 400; line-height: 1.3em; margin-top: 5px;&quot;&gt;Data Types in Java&lt;/h1&gt;&lt;h4 style=&quot;background-color: white; box-sizing: border-box; font-family: Roboto, sans-serif; font-size: 1.5rem; line-height: 1.1; margin-bottom: 10px; margin-top: 10px;&quot;&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400;&quot;&gt;Data types specify the different sizes and values that can be stored in the variable. There are two types of data types in Java:&lt;/div&gt;&lt;ol class=&quot;points&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400;&quot;&gt;&lt;li style=&quot;line-height: 21px; margin-top: 4px; padding: 0.2em;&quot;&gt;&lt;strong&gt;Primitive data types:&lt;/strong&gt;&amp;nbsp;The primitive data types include boolean, char, byte, short, int, long, float and double.&lt;/li&gt;&lt;li style=&quot;line-height: 21px; margin-top: 4px; padding: 0.2em;&quot;&gt;&lt;strong&gt;Non-primitive data types:&lt;/strong&gt;&amp;nbsp;The non-primitive data types include Classes, Interfaces, and Arrays.&lt;/li&gt;&lt;/ol&gt;&lt;/h4&gt;&lt;h2 class=&quot;h2&quot; style=&quot;background-color: white; color: #610b38; font-family: erdana, helvetica, arial, sans-serif; font-size: 25px; font-weight: 400; line-height: 1.3em;&quot;&gt;Java Primitive Data Types&lt;/h2&gt;&lt;h4 style=&quot;box-sizing: border-box; font-family: Roboto, sans-serif; font-size: 1.5rem; line-height: 1.1; margin-bottom: 10px; margin-top: 10px;&quot;&gt;&lt;div style=&quot;background-color: white; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400;&quot;&gt;In Java language, primitive data types are the building blocks of data manipulation. These are the most basic data types available in Java language.&lt;/div&gt;&lt;div style=&quot;background-color: white; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 13px;&quot;&gt;&lt;span style=&quot;background-color: black; color: white;&quot;&gt;Java is a statically-typed programming language . It means,all variable must be declared before its use. That is why we need to declare variables type and name&lt;/span&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 13px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 13px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;There are 8 types of primitive data types:&lt;/span&gt;&lt;/div&gt;&lt;ul class=&quot;points&quot; style=&quot;background-color: white; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: 400; line-height: normal; list-style: circle;&quot;&gt;&lt;li style=&quot;line-height: 21px; margin-top: 4px; padding: 0.2em;&quot;&gt;Boolean data type&lt;/li&gt;&lt;li style=&quot;line-height: 21px; margin-top: 4px; padding: 0.2em;&quot;&gt;byte data type&lt;/li&gt;&lt;li style=&quot;line-height: 21px; margin-top: 4px; padding: 0.2em;&quot;&gt;char data type&lt;/li&gt;&lt;li style=&quot;line-height: 21px; margin-top: 4px; padding: 0.2em;&quot;&gt;short data type&lt;/li&gt;&lt;li style=&quot;line-height: 21px; margin-top: 4px; padding: 0.2em;&quot;&gt;int data type&lt;/li&gt;&lt;li style=&quot;line-height: 21px; margin-top: 4px; padding: 0.2em;&quot;&gt;long data type&lt;/li&gt;&lt;li style=&quot;line-height: 21px; margin-top: 4px; padding: 0.2em;&quot;&gt;float data type&lt;/li&gt;&lt;li style=&quot;line-height: 21px; margin-top: 4px; padding: 0.2em;&quot;&gt;double data type&lt;/li&gt;&lt;/ul&gt;&lt;span style=&quot;background-color: white; height: auto;&quot;&gt;&lt;img alt=&quot;Java Data Types&quot; height=&quot;352&quot; src=&quot;https://static.javatpoint.com/images/java-data-types.png&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400; height: auto; max-width: 100%;&quot; width=&quot;640&quot; /&gt;&lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: &amp;quot;verdana&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: 13px; font-weight: 400;&quot;&gt;&lt;/span&gt;&lt;table class=&quot;alt&quot; style=&quot;background-color: white; border-collapse: collapse; border-spacing: 0px; border: 1px solid rgb(199, 204, 190); color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; width: 869px;&quot;&gt;&lt;tbody&gt;&lt;tr style=&quot;background-color: #eff1eb;&quot;&gt;&lt;th id=&quot;table_dvpt_datatype&quot; style=&quot;background-color: #c7ccbe; font-family: &amp;quot;times new roman&amp;quot;; font-size: 17px; padding: 12px; text-align: left; vertical-align: top;&quot;&gt;&lt;strong&gt;Data Type&lt;/strong&gt;&lt;/th&gt;&lt;th id=&quot;table_dvpt_defaultvalue&quot; style=&quot;background-color: #c7ccbe; font-family: &amp;quot;times new roman&amp;quot;; font-size: 17px; padding: 12px; text-align: left; vertical-align: top;&quot;&gt;&lt;strong&gt;Default Value&lt;/strong&gt;&lt;/th&gt;&lt;th id=&quot;table_dvpt_defaultsize&quot; style=&quot;background-color: #c7ccbe; font-family: &amp;quot;times new roman&amp;quot;; font-size: 17px; padding: 12px; text-align: left; vertical-align: top;&quot;&gt;&lt;strong&gt;Default size&lt;/strong&gt;&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td headers=&quot;table_dvpt_datatype&quot; style=&quot;border: 1px solid rgb(199, 204, 190); font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 23px; margin-left: 20px; padding: 8px; vertical-align: top;&quot;&gt;boolean&lt;/td&gt;&lt;td headers=&quot;table_dvpt_defaultvalue&quot; style=&quot;border: 1px solid rgb(199, 204, 190); font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 23px; margin-left: 20px; padding: 8px; vertical-align: top;&quot;&gt;false&lt;/td&gt;&lt;td headers=&quot;table_dvpt_defaultsize&quot; style=&quot;border: 1px solid rgb(199, 204, 190); font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 23px; margin-left: 20px; padding: 8px; vertical-align: top;&quot;&gt;1 bit&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;background-color: #eff1eb;&quot;&gt;&lt;td headers=&quot;table_dvpt_datatype&quot; style=&quot;border: 1px solid rgb(199, 204, 190); font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 23px; margin-left: 20px; padding: 8px; vertical-align: top;&quot;&gt;char&lt;/td&gt;&lt;td headers=&quot;table_dvpt_defaultvalue&quot; style=&quot;border: 1px solid rgb(199, 204, 190); font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 23px; margin-left: 20px; padding: 8px; vertical-align: top;&quot;&gt;&#39;\u0000&#39;&lt;/td&gt;&lt;td headers=&quot;table_dvpt_defaultsize&quot; style=&quot;border: 1px solid rgb(199, 204, 190); font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 23px; margin-left: 20px; padding: 8px; vertical-align: top;&quot;&gt;2 byte&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td headers=&quot;table_dvpt_datatype&quot; style=&quot;border: 1px solid rgb(199, 204, 190); font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 23px; margin-left: 20px; padding: 8px; vertical-align: top;&quot;&gt;byte&lt;/td&gt;&lt;td headers=&quot;table_dvpt_defaultvalue&quot; style=&quot;border: 1px solid rgb(199, 204, 190); font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 23px; margin-left: 20px; padding: 8px; vertical-align: top;&quot;&gt;0&lt;/td&gt;&lt;td headers=&quot;table_dvpt_defaultsize&quot; style=&quot;border: 1px solid rgb(199, 204, 190); font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 23px; margin-left: 20px; padding: 8px; vertical-align: top;&quot;&gt;1 byte&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;background-color: #eff1eb;&quot;&gt;&lt;td headers=&quot;table_dvpt_datatype&quot; style=&quot;border: 1px solid rgb(199, 204, 190); font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 23px; margin-left: 20px; padding: 8px; vertical-align: top;&quot;&gt;short&lt;/td&gt;&lt;td headers=&quot;table_dvpt_defaultvalue&quot; style=&quot;border: 1px solid rgb(199, 204, 190); font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 23px; margin-left: 20px; padding: 8px; vertical-align: top;&quot;&gt;0&lt;/td&gt;&lt;td headers=&quot;table_dvpt_defaultsize&quot; style=&quot;border: 1px solid rgb(199, 204, 190); font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 23px; margin-left: 20px; padding: 8px; vertical-align: top;&quot;&gt;2 byte&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td headers=&quot;table_dvpt_datatype&quot; style=&quot;border: 1px solid rgb(199, 204, 190); font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 23px; margin-left: 20px; padding: 8px; vertical-align: top;&quot;&gt;int&lt;/td&gt;&lt;td headers=&quot;table_dvpt_defaultvalue&quot; style=&quot;border: 1px solid rgb(199, 204, 190); font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 23px; margin-left: 20px; padding: 8px; vertical-align: top;&quot;&gt;0&lt;/td&gt;&lt;td headers=&quot;table_dvpt_defaultsize&quot; style=&quot;border: 1px solid rgb(199, 204, 190); font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 23px; margin-left: 20px; padding: 8px; vertical-align: top;&quot;&gt;4 byte&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;background-color: #eff1eb;&quot;&gt;&lt;td headers=&quot;table_dvpt_datatype&quot; style=&quot;border: 1px solid rgb(199, 204, 190); font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 23px; margin-left: 20px; padding: 8px; vertical-align: top;&quot;&gt;long&lt;/td&gt;&lt;td headers=&quot;table_dvpt_defaultvalue&quot; style=&quot;border: 1px solid rgb(199, 204, 190); font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 23px; margin-left: 20px; padding: 8px; vertical-align: top;&quot;&gt;0L&lt;/td&gt;&lt;td headers=&quot;table_dvpt_defaultsize&quot; style=&quot;border: 1px solid rgb(199, 204, 190); font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 23px; margin-left: 20px; padding: 8px; vertical-align: top;&quot;&gt;8 byte&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td headers=&quot;table_dvpt_datatype&quot; style=&quot;border: 1px solid rgb(199, 204, 190); font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 23px; margin-left: 20px; padding: 8px; vertical-align: top;&quot;&gt;float&lt;/td&gt;&lt;td headers=&quot;table_dvpt_defaultvalue&quot; style=&quot;border: 1px solid rgb(199, 204, 190); font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 23px; margin-left: 20px; padding: 8px; vertical-align: top;&quot;&gt;0.0f&lt;/td&gt;&lt;td headers=&quot;table_dvpt_defaultsize&quot; style=&quot;border: 1px solid rgb(199, 204, 190); font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 23px; margin-left: 20px; padding: 8px; vertical-align: top;&quot;&gt;4 byte&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;background-color: #eff1eb;&quot;&gt;&lt;td headers=&quot;table_dvpt_datatype&quot; style=&quot;border: 1px solid rgb(199, 204, 190); font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 23px; margin-left: 20px; padding: 8px; vertical-align: top;&quot;&gt;double&lt;/td&gt;&lt;td headers=&quot;table_dvpt_defaultvalue&quot; style=&quot;border: 1px solid rgb(199, 204, 190); font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 23px; margin-left: 20px; padding: 8px; vertical-align: top;&quot;&gt;0.0d&lt;/td&gt;&lt;td headers=&quot;table_dvpt_defaultsize&quot; style=&quot;border: 1px solid rgb(199, 204, 190); font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 23px; margin-left: 20px; padding: 8px; vertical-align: top;&quot;&gt;8 byte&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/h4&gt;&lt;h2 class=&quot;h2&quot; style=&quot;background-color: white; color: #610b38; font-family: erdana, helvetica, arial, sans-serif; font-size: 25px; font-weight: 400; line-height: 1.3em;&quot;&gt;1.Boolean Data Type&lt;/h2&gt;&lt;h4 style=&quot;background-color: white; box-sizing: border-box; font-family: Roboto, sans-serif; font-size: 1.5rem; line-height: 1.1; margin-bottom: 10px; margin-top: 10px;&quot;&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400;&quot;&gt;The Boolean data type is used to store only two possible values: true and false. This data type is used for simple flags that track true/false conditions.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400;&quot;&gt;The Boolean data type specifies one bit of information, but its &quot;size&quot; can&#39;t be defined precisely.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400;&quot;&gt;&lt;strong&gt;Example:&lt;/strong&gt;&amp;nbsp;Boolean one = false&lt;/div&gt;&lt;/h4&gt;&lt;h2 class=&quot;h2&quot; style=&quot;background-color: white; color: #610b38; font-family: erdana, helvetica, arial, sans-serif; font-size: 25px; font-weight: 400; line-height: 1.3em;&quot;&gt;2.Byte Data Type&lt;/h2&gt;&lt;h4 style=&quot;background-color: white; box-sizing: border-box; font-family: Roboto, sans-serif; font-size: 1.5rem; line-height: 1.1; margin-bottom: 10px; margin-top: 10px;&quot;&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400;&quot;&gt;The byte data type is an example of primitive data type. It is an 8-bit signed two&#39;s complement integer. Its value-range lies between -128 to 127 (inclusive). Its minimum value is -128 and maximum value is 127. Its default value is 0.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400;&quot;&gt;The byte data type is used to save memory in large arrays where the memory savings is most required. It saves space because a byte is 4 times smaller than an integer. It can also be used in place of &quot;int&quot; data type.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400;&quot;&gt;&lt;strong&gt;Example:&lt;/strong&gt;&amp;nbsp;byte a = 10, byte b = -20&lt;/div&gt;&lt;/h4&gt;&lt;h2 class=&quot;h2&quot; style=&quot;background-color: white; color: #610b38; font-family: erdana, helvetica, arial, sans-serif; font-size: 25px; font-weight: 400; line-height: 1.3em;&quot;&gt;3.Short Data Type&lt;/h2&gt;&lt;h4 style=&quot;background-color: white; box-sizing: border-box; font-family: Roboto, sans-serif; font-size: 1.5rem; line-height: 1.1; margin-bottom: 10px; margin-top: 10px;&quot;&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400;&quot;&gt;The short data type is a 16-bit signed two&#39;s complement integer. Its value-range lies between -32,768 to 32,767 (inclusive). Its minimum value is -32,768 and maximum value is 32,767. Its default value is 0.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400;&quot;&gt;The short data type can also be used to save memory just like byte data type. A short data type is 2 times smaller than an integer.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400;&quot;&gt;&lt;strong&gt;Example:&lt;/strong&gt;&amp;nbsp;short s = 10000, short r = -5000&lt;/div&gt;&lt;/h4&gt;&lt;h2 class=&quot;h2&quot; style=&quot;background-color: white; color: #610b38; font-family: erdana, helvetica, arial, sans-serif; font-size: 25px; font-weight: 400; line-height: 1.3em;&quot;&gt;4.Int Data Type&lt;/h2&gt;&lt;h4 style=&quot;background-color: white; box-sizing: border-box; font-family: Roboto, sans-serif; font-size: 1.5rem; line-height: 1.1; margin-bottom: 10px; margin-top: 10px;&quot;&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400;&quot;&gt;The int data type is a 32-bit signed two&#39;s complement integer. Its value-range lies between - 2,147,483,648 (-2^31) to 2,147,483,647 (2^31 -1) (inclusive). Its minimum value is - 2,147,483,648 and maximum value is 2,147,483,647. Its default value is 0.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400;&quot;&gt;The int data type is generally used as a default data type for integral values unless if there is no problem about memory.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400;&quot;&gt;&lt;strong&gt;Example:&lt;/strong&gt;&amp;nbsp;int a = 100000, int b = -200000&lt;/div&gt;&lt;/h4&gt;&lt;h2 class=&quot;h2&quot; style=&quot;background-color: white; color: #610b38; font-family: erdana, helvetica, arial, sans-serif; font-size: 25px; font-weight: 400; line-height: 1.3em;&quot;&gt;5.Long Data Type&lt;/h2&gt;&lt;h4 style=&quot;background-color: white; box-sizing: border-box; font-family: Roboto, sans-serif; font-size: 1.5rem; line-height: 1.1; margin-bottom: 10px; margin-top: 10px;&quot;&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400;&quot;&gt;The long data type is a 64-bit two&#39;s complement integer. Its value-range lies between -9,223,372.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400;&quot;&gt;&lt;strong&gt;Example:&lt;/strong&gt;&amp;nbsp;long a = 100000L, long b = -200000L&lt;/div&gt;&lt;/h4&gt;&lt;h2 class=&quot;h2&quot; style=&quot;background-color: white; color: #610b38; font-family: erdana, helvetica, arial, sans-serif; font-size: 25px; font-weight: 400; line-height: 1.3em;&quot;&gt;6.Float Data Type&lt;/h2&gt;&lt;h4 style=&quot;background-color: white; box-sizing: border-box; font-family: Roboto, sans-serif; font-size: 1.5rem; line-height: 1.1; margin-bottom: 10px; margin-top: 10px;&quot;&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400;&quot;&gt;The float data type is a single-precision 32-bit IEEE 754 floating point.Its value range is unlimited. It is recommended to use a float (instead of double) if you need to save memory in large arrays of floating point numbers. The float data type should never be used for precise values, such as currency. Its default value is 0.0F.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400;&quot;&gt;&lt;strong&gt;Example:&lt;/strong&gt;&amp;nbsp;float f1 = 234.5f&lt;/div&gt;&lt;/h4&gt;&lt;h2 class=&quot;h2&quot; style=&quot;background-color: white; color: #610b38; font-family: erdana, helvetica, arial, sans-serif; font-size: 25px; font-weight: 400; line-height: 1.3em;&quot;&gt;7.Double Data Type&lt;/h2&gt;&lt;h4 style=&quot;background-color: white; box-sizing: border-box; font-family: Roboto, sans-serif; font-size: 1.5rem; line-height: 1.1; margin-bottom: 10px; margin-top: 10px;&quot;&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400;&quot;&gt;The double data type is a double-precision 64-bit IEEE 754 floating point. Its value range is unlimited. The double data type is generally used for decimal values just like float. The double data type also should never be used for precise values, such as currency. Its default value is 0.0d.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400;&quot;&gt;&lt;strong&gt;Example:&lt;/strong&gt;&amp;nbsp;double d1 = 12.3&lt;/div&gt;&lt;/h4&gt;&lt;h2 class=&quot;h2&quot; style=&quot;background-color: white; color: #610b38; font-family: erdana, helvetica, arial, sans-serif; font-size: 25px; font-weight: 400; line-height: 1.3em;&quot;&gt;8.Char Data Type&lt;/h2&gt;&lt;h4 style=&quot;background-color: white; box-sizing: border-box; font-family: Roboto, sans-serif; font-size: 1.5rem; line-height: 1.1; margin-bottom: 10px; margin-top: 10px;&quot;&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400;&quot;&gt;The char data type is a single 16-bit Unicode character. Its value-range lies between &#39;\u0000&#39; (or 0) to &#39;\uffff&#39; (or 65,535 inclusive).The char data type is used to store characters.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; font-weight: 400;&quot;&gt;&lt;strong&gt;Example:&lt;/strong&gt;&amp;nbsp;char letterA = &#39;A&#39;.&lt;/div&gt;&lt;/h4&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://javastories1.blogspot.com/feeds/3759045426809694709/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://javastories1.blogspot.com/2019/10/data-types-in-java-data-types-specify.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/542843703124727712/posts/default/3759045426809694709'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/542843703124727712/posts/default/3759045426809694709'/><link rel='alternate' type='text/html' href='https://javastories1.blogspot.com/2019/10/data-types-in-java-data-types-specify.html' title=''/><author><name>Alpha programming</name><uri>http://www.blogger.com/profile/01668624719714063369</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//2.bp.blogspot.com/-UMN6IyPVjNk/Xbr2Eb5gkOI/AAAAAAAAQiM/R-qqJWSSfW4FjdEsfBGLROFcBACZDEXkgCK4BGAYYCw/s220/IMG_20180206_191342_508.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-542843703124727712.post-8658802085858019047</id><published>2019-10-31T02:51:00.002-07:00</published><updated>2019-10-31T08:12:36.238-07:00</updated><title type='text'></title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;h1 class=&quot;entry-title&quot; style=&quot;background-color: white; border: 0px; clear: both; color: rgba(0, 0, 0, 0.84); font-family: Roboto, sans-serif; font-size: 28px; line-height: 1.2; margin: 0px 0px 15px; padding: 0px; text-align: justify; vertical-align: baseline;&quot;&gt;&lt;u&gt;Java programming with Hello World Example.&lt;/u&gt;&lt;/h1&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: white; border: 0px; color: rgba(0, 0, 0, 0.84); font-family: Roboto, sans-serif; font-size: 16px; line-height: 1.71429; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;The process of Java programming can be simplified in three steps:&lt;/div&gt;&lt;ul style=&quot;background-color: white; border: 0px; color: rgba(0, 0, 0, 0.84); font-family: Roboto, sans-serif; font-size: 16px; line-height: 1.71429; list-style-image: initial; list-style-position: outside; margin: 0px 0px 24px; padding: 0px; text-align: justify; vertical-align: baseline;&quot;&gt;&lt;li style=&quot;border: 0px; line-height: 1.58; margin: 0px 0px 0px 36px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;Create the program by typing it into a text editor and saving it to a file – HelloWorld.java.&lt;/li&gt;&lt;li style=&quot;border: 0px; line-height: 1.58; margin: 0px 0px 0px 36px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;Compile it by typing “javac HelloWorld.java” in the terminal window.&lt;/li&gt;&lt;li style=&quot;border: 0px; line-height: 1.58; margin: 0px 0px 0px 36px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;Execute (or run) it by typing “java HelloWorld” in the terminal window.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;span style=&quot;color: rgba(0 , 0 , 0 , 0.83921568627451); font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: white; color: rgba(0 , 0 , 0 , 0.84); font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px;&quot;&gt;Below given &amp;nbsp;program is the simplest program of Java printing “Hello World” to the screen. Let us try to understand every bit of code step by step.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: white; color: rgba(0 , 0 , 0 , 0.84); font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: white; color: rgba(0 , 0 , 0 , 0.84); font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: #a00027; font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&lt;i&gt;/&lt;/i&gt;*This is a Simple Java Program.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: #a00027; font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: #a00027; font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;FileName:&quot;HelloWorld.java&quot;.*&lt;i&gt;/&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: #a00027; font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: #a00027; font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;Class HelloWorld&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: #a00027; font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: #a00027; font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: #a00027; font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Your program starts with a call main()&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: #a00027; font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // Print &quot;Hello,World&quot; to the terminal Window.&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; text-align: justify;&quot;&gt;&lt;span style=&quot;color: #a00027; font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: #a00027; font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;u&gt;public static void main (string args[])&lt;/u&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: #a00027; font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;u&gt;{&lt;/u&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: #a00027; font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;u&gt;system.out.println(&quot;Hello,World);&lt;/u&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: #a00027; font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;u&gt;}&lt;/u&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: #a00027; font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&lt;u&gt;}&lt;/u&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #f6b26b; text-decoration-line: underline;&quot;&gt;Out&lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;&lt;u&gt;put&lt;/u&gt;&amp;nbsp;: &lt;/span&gt;Hello, World&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;div style=&quot;background-color: white; text-align: left;&quot;&gt;&lt;span style=&quot;color: #4c1130;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: rgba(0 , 0 , 0 , 0.84); font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px;&quot;&gt;The “Hello World!”&amp;nbsp;program consists of three primary components&lt;b&gt;:&lt;/b&gt; the HelloWorld class definition, the &lt;/span&gt;&lt;span style=&quot;color: rgba(0 , 0 , 0 , 0.84); font-size: 12px;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot; , &amp;quot;monaco&amp;quot; , &amp;quot;lucida console&amp;quot; , monospace;&quot;&gt;main&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: rgba(0 , 0 , 0 , 0.84); font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px;&quot;&gt;&amp;nbsp;method and source code comments. Following explanation will provide you with a basic understanding of the code:&lt;/span&gt;&lt;span style=&quot;color: rgba(0 , 0 , 0 , 0.84); font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px;&quot;&gt;&quot;.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; text-align: left;&quot;&gt;&lt;span style=&quot;color: rgba(0 , 0 , 0 , 0.84); font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; text-align: left;&quot;&gt;&lt;span style=&quot;color: rgba(0 , 0 , 0 , 0.84); font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; text-align: left;&quot;&gt;&lt;span style=&quot;color: rgba(0 , 0 , 0 , 0.84); font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; text-align: left;&quot;&gt;&lt;strong style=&quot;border: 0px; color: rgba(0, 0, 0, 0.84); font-family: Roboto, sans-serif; font-size: 16px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;1. Class definition:&lt;/strong&gt;&lt;span style=&quot;color: rgba(0 , 0 , 0 , 0.84); font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px;&quot;&gt;This line uses the keyword&amp;nbsp;&lt;/span&gt;&lt;strong style=&quot;border: 0px; color: rgba(0, 0, 0, 0.84); font-family: Roboto, sans-serif; font-size: 16px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;class&amp;nbsp;&lt;/strong&gt;&lt;span style=&quot;color: rgba(0 , 0 , 0 , 0.84); font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px;&quot;&gt;to declare that a new class is being defined.&lt;/span&gt;&lt;span style=&quot;background-color: #e0e0e0; color: rgba(0 , 0 , 0 , 0.9); font-family: &amp;quot;consolas&amp;quot; , monospace; font-size: 15px;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; text-align: left;&quot;&gt;&lt;span style=&quot;color: rgba(0 , 0 , 0 , 0.84); font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&lt;i style=&quot;background-color: #f4cccc;&quot;&gt;&lt;span style=&quot;color: rgba(0 , 0 , 0 , 0.83921568627451);&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;HelloWorld&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; text-align: left;&quot;&gt;&lt;span style=&quot;color: rgba(0 , 0 , 0 , 0.84); font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;background-color: white; border: 0px; font-family: Roboto, sans-serif; font-size: 16px; line-height: 1.71429; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;HelloWorld&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: rgba(0 , 0 , 0 , 0.84);&quot;&gt;&amp;nbsp;is an identifier that is the name of the class. The entire class definition, including all of its members, will be between the opening curly brace &amp;nbsp;&lt;strong style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/strong&gt;&amp;nbsp;&amp;nbsp;and the closing curly brace&lt;strong style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;nbsp;&amp;nbsp;}&lt;/strong&gt;&amp;nbsp;.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; border: 0px; font-family: Roboto, sans-serif; font-size: 16px; line-height: 1.71429; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;strong style=&quot;border: 0px; color: rgba(0, 0, 0, 0.84); margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;2. main method:&amp;nbsp;&lt;/strong&gt;&lt;span style=&quot;color: rgba(0 , 0 , 0 , 0.84);&quot;&gt;In Java programming language, every application must contain a&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;border: 0px; color: rgba(0, 0, 0, 0.84); font-family: Consolas, Monaco, &amp;quot;Lucida Console&amp;quot;, monospace; font-size: 12px; line-height: 2; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;main&lt;/code&gt;&lt;span style=&quot;color: rgba(0 , 0 , 0 , 0.84);&quot;&gt;&amp;nbsp;method whose signature is&lt;b&gt;:&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;border: 0px; font-family: Roboto, sans-serif; font-size: 16px; line-height: 1.71429; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc; color: rgba(0 , 0 , 0 , 0.84);&quot;&gt;&lt;b&gt;public static void main(string[] args) :-&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;border: 0px; font-family: Roboto, sans-serif; font-size: 16px; line-height: 1.71429; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;&lt;span style=&quot;color: rgba(0 , 0 , 0 , 0.84);&quot;&gt;&lt;b&gt;public : &lt;/b&gt;So that &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;JVM &lt;/span&gt;can execute the method from anywhere.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;border: 0px; font-family: Roboto, sans-serif; font-size: 16px; line-height: 1.71429; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;&lt;b&gt;static : &lt;/b&gt;Main method is to be called without object.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;border: 0px; font-family: Roboto, sans-serif; font-size: 16px; line-height: 1.71429; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;The modifiers public and static can be written in either order.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;border: 0px; font-family: Roboto, sans-serif; font-size: 16px; line-height: 1.71429; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;&lt;b&gt;void : &lt;/b&gt;The main method doesn&#39;t return anything.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;border: 0px; font-family: Roboto, sans-serif; font-size: 16px; line-height: 1.71429; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;&lt;b&gt;main() : &lt;/b&gt;Name configured in the &lt;span style=&quot;color: red;&quot;&gt;JVM&lt;/span&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;border: 0px; font-family: Roboto, sans-serif; font-size: 16px; line-height: 1.71429; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;&lt;b&gt;String[] : &lt;/b&gt;The main method accepts a single argument ( an array of elements of type string)&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; border: 0px; color: rgba(0, 0, 0, 0.84); font-family: Roboto, sans-serif; font-size: 16px; line-height: 1.71429; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;Like in C/C++, main method is the entry point for your application and will subsequently invoke all the other methods required by your program.&lt;/div&gt;&lt;div style=&quot;background-color: white; border: 0px; color: rgba(0, 0, 0, 0.84); font-family: Roboto, sans-serif; font-size: 16px; line-height: 1.71429; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;b&gt;3. The next line of code is shown here. Notice that it occurs inside main()&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;border: 0px; font-family: Roboto, sans-serif; font-size: 16px; line-height: 1.71429; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;b&gt;&lt;span style=&quot;background-color: white; color: rgba(0 , 0 , 0 , 0.83921568627451);&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;system.out.println(&quot;Hello,World&quot;);&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;border: 0px; font-family: Roboto, sans-serif; font-size: 16px; line-height: 1.71429; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-color: white; color: rgba(0 , 0 , 0 , 0.84);&quot;&gt;This line outputs the string “Hello, World” followed by a new line on the screen. Output is actually accomplished by the built-in println(&lt;/span&gt;&lt;em style=&quot;background-color: white; border: 0px; color: rgba(0, 0, 0, 0.84); margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;nbsp;)&lt;/em&gt;&lt;span style=&quot;background-color: white; color: rgba(0 , 0 , 0 , 0.84);&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: rgba(0 , 0 , 0 , 0.84);&quot;&gt;method.&lt;/span&gt;&lt;span style=&quot;background-color: white; color: rgba(0 , 0 , 0 , 0.84);&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;strong style=&quot;background-color: white; border: 0px; color: rgba(0, 0, 0, 0.84); margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;System&lt;/strong&gt;&lt;span style=&quot;background-color: white; color: rgba(0 , 0 , 0 , 0.84);&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: rgba(0 , 0 , 0 , 0.84);&quot;&gt;is a predefined class that provides access to the system, and&lt;/span&gt;&lt;span style=&quot;background-color: white; color: rgba(0 , 0 , 0 , 0.84);&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;strong style=&quot;background-color: white; border: 0px; color: rgba(0, 0, 0, 0.84); margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;out&lt;/strong&gt;&lt;span style=&quot;background-color: white; color: rgba(0 , 0 , 0 , 0.84);&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: rgba(0 , 0 , 0 , 0.84);&quot;&gt;is the variable of type output stream that is connected to the console.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; border: 0px; color: rgba(0, 0, 0, 0.84); font-family: Roboto, sans-serif; font-size: 16px; line-height: 1.71429; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;strong style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; border: 0px; font-family: Roboto, sans-serif; font-size: 16px; line-height: 1.71429; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;strong style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;color: rgba(0 , 0 , 0 , 0.83921568627451);&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #6aa84f;&quot;&gt;# Points :&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;ul style=&quot;background-color: white; border: 0px; color: rgba(0, 0, 0, 0.84); font-family: Roboto, sans-serif; font-size: 16px; line-height: 1.71429; list-style-image: initial; list-style-position: outside; margin: 0px 0px 24px; padding: 0px; text-align: justify; vertical-align: baseline;&quot;&gt;&lt;li style=&quot;border: 0px; line-height: 1.58; margin: 0px 0px 0px 36px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;The name of the class defined by the program is HelloWorld, which is same as name of file(HelloWorld.java). This is not a coincidence. In Java, all codes must reside inside a class and there is at most one public class which contain main() method.&lt;/li&gt;&lt;li style=&quot;border: 0px; line-height: 1.58; margin: 0px 0px 0px 36px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;By convention, the name of the main class(class which contain main method) should match the name of the file that holds the program.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;span style=&quot;color: rgba(0, 0, 0, 0.83921568627451); font-family: roboto, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgba(0, 0, 0, 0.83921568627451); font-family: roboto, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgba(0, 0, 0, 0.83921568627451); font-family: roboto, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;background-color: white; border: 0px; color: rgba(0, 0, 0, 0.84); font-family: Roboto, sans-serif; font-size: 16px; line-height: 1.71429; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;strong style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Compiling the program&amp;nbsp;&lt;/strong&gt;:&lt;/div&gt;&lt;ul style=&quot;background-color: white; border: 0px; color: rgba(0, 0, 0, 0.84); font-family: Roboto, sans-serif; font-size: 16px; line-height: 1.71429; list-style-image: initial; list-style-position: outside; margin: 0px 0px 24px; padding: 0px; text-align: justify; vertical-align: baseline;&quot;&gt;&lt;li style=&quot;border: 0px; line-height: 1.58; margin: 0px 0px 0px 36px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;After successfully&amp;nbsp;setting up the environment, we can open terminal in both Windows/Unix and can go to directory where the&amp;nbsp;file – HelloWorld.java is present.&lt;/li&gt;&lt;li style=&quot;border: 0px; line-height: 1.58; margin: 0px 0px 0px 36px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;Now, to compile the HelloWorld program, execute the compiler&amp;nbsp;–&amp;nbsp;javac , specifying the name of the&amp;nbsp;&lt;strong style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;source&lt;/strong&gt;&amp;nbsp;file on the command line, as shown.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;span style=&quot;color: rgba(0, 0, 0, 0.83921568627451); font-family: Roboto, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Roboto, sans-serif;&quot;&gt; &lt;span style=&quot;background-color: #f4cccc;&quot;&gt;&lt;b&gt;javac&amp;nbsp; &amp;nbsp; &amp;nbsp;HelloWorld.java&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: rgba(0, 0, 0, 0.83921568627451); font-family: Roboto, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;ul style=&quot;background-color: white; border: 0px; color: rgba(0, 0, 0, 0.84); font-family: Roboto, sans-serif; font-size: 16px; line-height: 1.71429; list-style-image: initial; list-style-position: outside; margin: 0px 0px 24px; padding: 0px; text-align: justify; vertical-align: baseline;&quot;&gt;&lt;li style=&quot;border: 0px; line-height: 1.58; margin: 0px 0px 0px 36px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;The compiler creates a file called HelloWorld.class (in present working directory) that contains the bytecode version of the program. Now, to execute our program,&amp;nbsp;&lt;b&gt;JVM&lt;/b&gt;(Java Virtual Machine) needs to be called using java, specifying the name of the&amp;nbsp;&lt;strong style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;class&lt;/strong&gt;&amp;nbsp;file on the command line, as shown.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;span style=&quot;color: rgba(0, 0, 0, 0.83921568627451); font-family: Roboto, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;background-color: #f4cccc; font-family: Roboto, sans-serif;&quot;&gt;&lt;b&gt;java&amp;nbsp; HelloWorld&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc; font-family: Roboto, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: #f4cccc; font-family: Roboto, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: Roboto, sans-serif;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;ul style=&quot;background-color: white; border: 0px; color: rgba(0, 0, 0, 0.84); font-family: Roboto, sans-serif; font-size: 16px; line-height: 1.71429; list-style-image: initial; list-style-position: outside; margin: 0px 0px 24px; padding: 0px; text-align: justify; vertical-align: baseline;&quot;&gt;&lt;li style=&quot;border: 0px; line-height: 1.58; margin: 0px 0px 0px 36px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;This will print “Hello World” to the terminal screen.&lt;/li&gt;&lt;/ul&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;&lt;u&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;roboto&amp;quot; , sans-serif;&quot;&gt;&lt;b&gt;&lt;u&gt;&lt;span style=&quot;color: #f6b26b;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://javastories1.blogspot.com/feeds/8658802085858019047/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://javastories1.blogspot.com/2019/10/java-programming-with-hello-world.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/542843703124727712/posts/default/8658802085858019047'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/542843703124727712/posts/default/8658802085858019047'/><link rel='alternate' type='text/html' href='https://javastories1.blogspot.com/2019/10/java-programming-with-hello-world.html' title=''/><author><name>Alpha programming</name><uri>http://www.blogger.com/profile/01668624719714063369</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//2.bp.blogspot.com/-UMN6IyPVjNk/Xbr2Eb5gkOI/AAAAAAAAQiM/R-qqJWSSfW4FjdEsfBGLROFcBACZDEXkgCK4BGAYYCw/s220/IMG_20180206_191342_508.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-542843703124727712.post-9075813241824366706</id><published>2019-10-31T02:24:00.001-07:00</published><updated>2019-10-31T13:12:27.354-07:00</updated><title type='text'>Basics</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;background-color: white; color: rgba(0 , 0 , 0 , 0.84); font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px;&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;&lt;/span&gt;&lt;br /&gt;&lt;h1 class=&quot;entry-title&quot; style=&quot;background-color: white; border: 0px; box-sizing: border-box; clear: both; color: rgba(0, 0, 0, 0.84); font-family: roboto, sans-serif; font-size: 28px; line-height: 1.2; margin: 0px 0px 15px; padding: 0px; text-align: justify; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;font-weight: 400;&quot;&gt;&amp;nbsp;&lt;/span&gt;Java Programming Basics&lt;/h1&gt;&lt;span style=&quot;background-color: white; color: rgba(0 , 0 , 0 , 0.84); font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: rgba(0 , 0 , 0 , 0.84); font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px;&quot;&gt;Java is one of the most popular and widely used programming language and platform. A platform is an environment that helps to develop and run programs written in any programming language.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;background-color: white; color: rgba(0 , 0 , 0 , 0.84); font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px;&quot;&gt;Java is fast, reliable and secure. From desktop to web applications, scientific supercomputers to gaming consoles, cell phones to the Internet, Java is used in every nook.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;background-color: white; color: rgba(0 , 0 , 0 , 0.84); font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: rgba(0 , 0 , 0 , 0.84); font-family: &amp;quot;roboto&amp;quot; , sans-serif; font-size: 16px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;b style=&quot;background-color: white; border: 0px; box-sizing: border-box; color: rgba(0, 0, 0, 0.84); font-family: Roboto, sans-serif; font-size: 16px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;How to become experienced in Java programming language, you needs to understand the basics of&amp;nbsp; language.&lt;/b&gt;&lt;br /&gt;&lt;b style=&quot;background-color: white; border: 0px; box-sizing: border-box; color: rgba(0, 0, 0, 0.84); font-family: Roboto, sans-serif; font-size: 16px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;br /&gt;&lt;/b&gt;&lt;b style=&quot;background-color: white; border: 0px; box-sizing: border-box; color: rgba(0, 0, 0, 0.84); font-family: Roboto, sans-serif; font-size: 16px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;br /&gt;&lt;/b&gt;&lt;b style=&quot;background-color: white; border: 0px; box-sizing: border-box; color: rgba(0, 0, 0, 0.84); font-family: Roboto, sans-serif; font-size: 16px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;br /&gt;&lt;/b&gt;&lt;b style=&quot;background-color: white; border: 0px; box-sizing: border-box; color: rgba(0, 0, 0, 0.84); font-family: Roboto, sans-serif; font-size: 16px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;br /&gt;&lt;/b&gt;&lt;b style=&quot;background-color: white; border: 0px; box-sizing: border-box; color: rgba(0, 0, 0, 0.84); font-family: Roboto, sans-serif; font-size: 16px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;/b&gt;&lt;br /&gt;&lt;ol style=&quot;background-color: white; border: 0px; box-sizing: border-box; color: rgba(0, 0, 0, 0.84); font-family: Roboto, sans-serif; font-size: 16px; line-height: 1.71429; list-style-image: initial; list-style-position: outside; margin: 0px 0px 24px; padding: 0px; text-align: justify; vertical-align: baseline;&quot;&gt;&lt;li style=&quot;border: 0px; box-sizing: border-box; line-height: 1.58; margin: 0px 0px 0px 36px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;&lt;b&gt;Java Environment&lt;/b&gt;&amp;nbsp;&lt;b&gt;:&lt;/b&gt;&amp;nbsp;The programming environment of Java consists of three components mainly:&lt;ul style=&quot;border: 0px; box-sizing: border-box; line-height: 1.71429; list-style: outside disc; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;li style=&quot;border: 0px; box-sizing: border-box; line-height: 1.58; margin: 0px 0px 0px 36px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;JDK&amp;nbsp;&lt;b&gt;: &lt;/b&gt;(&lt;i&gt;Java Development Kit&lt;/i&gt;)&lt;/li&gt;&lt;li style=&quot;border: 0px; box-sizing: border-box; line-height: 1.58; margin: 0px 0px 0px 36px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;JRE&amp;nbsp;&lt;b&gt;: &lt;/b&gt;(&lt;i&gt;Java Run time Environment&lt;/i&gt;)&lt;/li&gt;&lt;li style=&quot;border: 0px; box-sizing: border-box; line-height: 1.58; margin: 0px 0px 0px 36px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;JVM &lt;b&gt;: &lt;/b&gt;(&lt;i&gt;Java Virtual Machine&lt;/i&gt;)&amp;nbsp;&lt;/li&gt;&lt;/ul&gt;&lt;div style=&quot;border: 0px; box-sizing: border-box; line-height: 1.71429; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;border: 0px; box-sizing: border-box; line-height: 1.58; margin: 0px 0px 0px 36px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;&lt;b&gt;Java Basic Syntax :&lt;/b&gt; Every programming language has its own set of rules to declare, define and work on its components. Reading and learning about all of them together is difficult. Therefore here is a simple task of&amp;nbsp;&lt;b&gt;printing&lt;a href=&quot;https://www.geeksforgeeks.org/beginning-java-programming-with-hello-world-example/&quot; rel=&quot;noopener&quot; style=&quot;border: 0px; box-sizing: border-box; color: #ec4e20; margin: 0px; outline: none; padding: 0px; text-decoration-line: none; vertical-align: baseline;&quot; target=&quot;_blank&quot;&gt;&amp;nbsp;&lt;/a&gt;&quot;HELLO WORLD&quot; in java&lt;/b&gt;. During this process, major components and their syntax are explained clearly.&lt;div style=&quot;border: 0px; box-sizing: border-box; line-height: 1.71429; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;b style=&quot;border: 0px; box-sizing: border-box; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;br style=&quot;box-sizing: border-box;&quot; /&gt;&lt;/b&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;border: 0px; box-sizing: border-box; line-height: 1.58; margin: 0px 0px 0px 36px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;&lt;b style=&quot;border: 0px; box-sizing: border-box; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Comments in Java :&lt;/b&gt;&amp;nbsp;In a program, comments take part in making the program become more human-readable by placing the detail of code involved and proper use of comments makes maintenance easier and finding bugs easily. Comments are ignored by the compiler while compiling the code.&lt;div style=&quot;border: 0px; box-sizing: border-box; line-height: 1.71429; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;border: 0px; box-sizing: border-box; line-height: 1.58; margin: 0px 0px 0px 36px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;&lt;b style=&quot;border: 0px; box-sizing: border-box; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Data Types in Java :&lt;/b&gt;&amp;nbsp;Each variable in Java has an associated data type. Each data type requires different amounts of memory and has some specific operations which can be performed over it.&lt;div style=&quot;border: 0px; box-sizing: border-box; line-height: 1.71429; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;border: 0px; box-sizing: border-box; line-height: 1.58; margin: 0px 0px 0px 36px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;&lt;b style=&quot;border: 0px; box-sizing: border-box; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Variables in Java:&lt;/b&gt;&amp;nbsp;A variable is the name given to a memory location. It is the basic unit of storage in a program.&lt;div style=&quot;border: 0px; box-sizing: border-box; line-height: 1.71429; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;b style=&quot;border: 0px; box-sizing: border-box; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;br style=&quot;box-sizing: border-box;&quot; /&gt;&lt;/b&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;border: 0px; box-sizing: border-box; line-height: 1.58; margin: 0px 0px 0px 36px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;&lt;b style=&quot;border: 0px; box-sizing: border-box; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Keywords in Java :&lt;/b&gt;&amp;nbsp;Keywords or Reserved words are the words in a language that are used for some internal process or represent some predefined actions. These words are therefore not allowed to use as variable names or objects. Doing this will result in a compile-time error.&lt;div style=&quot;border: 0px; box-sizing: border-box; line-height: 1.71429; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;b style=&quot;border: 0px; box-sizing: border-box; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;br style=&quot;box-sizing: border-box;&quot; /&gt;&lt;/b&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;border: 0px; box-sizing: border-box; line-height: 1.58; margin: 0px 0px 0px 36px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;&lt;b style=&quot;border: 0px; box-sizing: border-box; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Operators in Java :&lt;/b&gt;&amp;nbsp;Operators are the foundation of any programming language. Thus the functionality of Java programming language is incomplete without the use of operators. We can define operators as symbols that help us to perform specific mathematical and logical computations on operands. In other words, we can say that an operator operates the operands.&lt;div style=&quot;border: 0px; box-sizing: border-box; line-height: 1.71429; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;b style=&quot;border: 0px; box-sizing: border-box; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;br style=&quot;box-sizing: border-box;&quot; /&gt;&lt;/b&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;border: 0px; box-sizing: border-box; line-height: 1.58; margin: 0px 0px 0px 36px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;&lt;b style=&quot;border: 0px; box-sizing: border-box; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Decision Making (Control Statement) in Java :&lt;/b&gt;&amp;nbsp;Decision Making in programming is similar to decision making in real life. In programming also we face some situations where we want a certain block of code to be executed when some condition is fulfilled.&lt;br style=&quot;box-sizing: border-box;&quot; /&gt;A programming language uses control statements to control the flow of execution of the program based on certain conditions. These are used to cause the flow of execution to advance and branch based on changes to the state of a program.&lt;div style=&quot;border: 0px; box-sizing: border-box; line-height: 1.71429; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;b style=&quot;border: 0px; box-sizing: border-box; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;br style=&quot;box-sizing: border-box;&quot; /&gt;&lt;/b&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;border: 0px; box-sizing: border-box; line-height: 1.58; margin: 0px 0px 0px 36px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;&lt;b style=&quot;border: 0px; box-sizing: border-box; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Loops in Java:&lt;/b&gt;&amp;nbsp;Looping in programming languages is a feature which facilitates the execution of a set of instructions/functions repeatedly while some condition evaluates to true.&lt;br style=&quot;box-sizing: border-box;&quot; /&gt;Java provides three ways for executing the loops. While all the ways provide similar basic functionality, they differ in their syntax and condition checking time.&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://javastories1.blogspot.com/feeds/9075813241824366706/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://javastories1.blogspot.com/2019/10/java-programming-basics-java-is-one-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/542843703124727712/posts/default/9075813241824366706'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/542843703124727712/posts/default/9075813241824366706'/><link rel='alternate' type='text/html' href='https://javastories1.blogspot.com/2019/10/java-programming-basics-java-is-one-of.html' title='Basics'/><author><name>Alpha programming</name><uri>http://www.blogger.com/profile/01668624719714063369</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//2.bp.blogspot.com/-UMN6IyPVjNk/Xbr2Eb5gkOI/AAAAAAAAQiM/R-qqJWSSfW4FjdEsfBGLROFcBACZDEXkgCK4BGAYYCw/s220/IMG_20180206_191342_508.jpg'/></author><thr:total>0</thr:total></entry></feed>