<?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-7072328287385305382</id><updated>2020-02-29T10:30:31.688+05:30</updated><category term="java"/><category term="programming"/><category term="coding"/><category term="core java"/><category term="java beginner"/><category term="inheritence"/><title type='text'>Java Guide </title><subtitle type='html'>This site provides all content related to java. This basically contains basic java topics with a clear example. This site is very helpful for java beginner. This basically covers all the topics of java like garbage collection, OOPs, Inheritance, Abstraction, Encapsulation, static, synchronization, Method Overloading, Method Overriding, Multithreading, Exception Handling, etc. &#xa;</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='https://basicjavatutorialsforbeginner.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/7072328287385305382/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='https://basicjavatutorialsforbeginner.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Abhishek Singh</name><uri>http://www.blogger.com/profile/00955915184460219032</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//1.bp.blogspot.com/-O1ColsxMvl8/Xf_UtpC9srI/AAAAAAAAA48/OohC6lf1baEcdJGr0a0nfyFtMWLr8BEXACK4BGAYYCw/s220/download.png'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>4</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7072328287385305382.post-7009625476069257758</id><published>2020-02-14T01:19:00.003+05:30</published><updated>2020-02-29T10:30:31.631+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="inheritence"/><category scheme="http://www.blogger.com/atom/ns#" term="java"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><title type='text'>Inheritance in Java by Abhishek Singh</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;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;&lt;b&gt;Inheritance In Java&lt;/b&gt;&lt;/h2&gt;&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;Inheritance is one of the important mechanisms of &lt;b&gt;OOPs(Object-Oriented Programming Systems)&lt;/b&gt; in java. It is a mechanism in which one object acquires all the properties of its parent object.&lt;/div&gt;&lt;div style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: left;&quot;&gt;&lt;/div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;It is basically used for code reusability in java.&lt;/li&gt;&lt;li&gt;The concept behind inheritance in java is that you can create new classes that will contain all the properties of its parent class.&lt;/li&gt;&lt;li&gt;When you inherit a class named A in another class named B then you can access all the methods of class A in class B.&lt;/li&gt;&lt;li&gt;In java, it is used to &lt;b&gt;achieve runtime polymorphism.&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;Multiple inheritances in java are not possible&lt;/b&gt; through the class because of the diamond problem.&lt;/li&gt;&lt;li&gt;Inheritance in java is used in &lt;b&gt;method overriding also&lt;/b&gt;.&lt;/li&gt;&lt;li&gt;Inheritance is also known as &lt;b&gt;IS-A relationship in java&lt;/b&gt; which basically means parent-child relationship.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;u&gt;What is the use of inheritance in java-&lt;/u&gt;&lt;/b&gt;&lt;/h3&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;In java, inheritance is basically used for code reusability.&lt;/li&gt;&lt;li&gt;It is basically used to &lt;b&gt;achieve runtime polymorphism in object-oriented programming&lt;/b&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;u&gt;Main keywords used in inheritance-&lt;/u&gt;&lt;/b&gt;&lt;/h3&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;u&gt;Class-&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;It is basically known as the collection of objects.&lt;/li&gt;&lt;li&gt;It represents or contains the methods that are common to all objects of similar type.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;u&gt;Sub Class/Child Class-&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Sub Class/Child Class is the class that inherits the other class(known as the parent class) in java.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;u&gt;Super Class/Parent Class-&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;The class which is inherited by child class is known as Super Class in Java.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;u&gt;Syntax of inheritance in Java-&lt;/u&gt;&lt;/h3&gt;&lt;div&gt;&lt;b&gt;1-&amp;nbsp; class Subclassname extends Superclassname{&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;2-&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;//Methods, variables or fields&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;3-&amp;nbsp; &amp;nbsp;}&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The extends keyword here indicates that we are creating a new class from the existing class&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;u&gt;Example of inheritance in Java-&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;1- package Java_Test;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;2- class Superclass{&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;3-&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void A() {&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;4-&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.out.println(&quot;Method A&quot;);&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;5-&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;6- }&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;7- class Subclass extends Superclass{&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;8-&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void B() {&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;9-&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.out.println(&quot;Method B&quot;);&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;10-&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;11- }&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;12- public class Inheritance_In_Java {&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;13-&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static void main(String[] args) {&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;14-&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Subclass obj=new Subclass();&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;15-&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;obj.A();&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;16-&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;obj.B();&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;17-&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;18- }&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://basicjavatutorialsforbeginner.blogspot.com/feeds/7009625476069257758/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=7072328287385305382&amp;postID=7009625476069257758' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/7072328287385305382/posts/default/7009625476069257758'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/7072328287385305382/posts/default/7009625476069257758'/><link rel='alternate' type='text/html' href='https://basicjavatutorialsforbeginner.blogspot.com/2020/02/inheritance-in-java-by-abhishek-singh.html' title='Inheritance in Java by Abhishek Singh'/><author><name>Abhishek Singh</name><uri>http://www.blogger.com/profile/00955915184460219032</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//1.bp.blogspot.com/-O1ColsxMvl8/Xf_UtpC9srI/AAAAAAAAA48/OohC6lf1baEcdJGr0a0nfyFtMWLr8BEXACK4BGAYYCw/s220/download.png'/></author><thr:total>0</thr:total><georss:featurename>Indirapuram, Ghaziabad, Uttar Pradesh, India</georss:featurename><georss:point>28.6460176 77.3695166</georss:point><georss:box>28.5902791 77.2888356 28.7017561 77.4501976</georss:box><gd:extendedProperty name="commentSource" value="1"/><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD"/></entry><entry><id>tag:blogger.com,1999:blog-7072328287385305382.post-1506201897490556236</id><published>2020-01-26T23:04:00.002+05:30</published><updated>2020-01-26T23:04:37.427+05:30</updated><title type='text'>Garbage Collection In Java</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;background-color: white; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;u&gt;Introduction to Garbage Collection-&lt;/u&gt;&lt;/h2&gt;In C or C++, the programmer is responsible for the creation and destruction of objects but in java programmer need not worry about the creation and destruction of objects. The garbage collector will take responsibility for this. &lt;b&gt;Garbage Collector&lt;/b&gt; can also be called as daemon thread(low priority thread that runs in the background). Garbage collector checks and frees up the heap memory by destroying the unreachable objects.&lt;br /&gt;Unreachable objects are the objects that are no longer referenced or used in the program.&lt;br /&gt;In C language garbage collection is done by using the free() function and in C++ it is done by using delete() function but in java, it is done automatically.&lt;br /&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;u&gt;Garbage Collection Advantage in Java-&lt;/u&gt;&lt;/h3&gt;1-Garbage Collection makes java memory-efficient because of garbage collector delete the unreferenced objects from heap memory.&lt;br /&gt;2-It is performed by the garbage collector automatically.&lt;br /&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;u&gt;&lt;b&gt;The possibilities when an object be unreferenced&lt;/b&gt;-&lt;/u&gt;&lt;/h3&gt;&amp;nbsp;1-By assigning a reference to another&lt;br /&gt;&amp;nbsp;2-By nulling the reference&lt;br /&gt;&amp;nbsp;3-By anonymous object&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;u&gt;1-By assigning a reference to another-&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;&amp;nbsp;Student obj1=new Student();&amp;nbsp;&lt;br /&gt;&amp;nbsp;Student obj2=new Student();&amp;nbsp;&lt;br /&gt;&amp;nbsp;obj1=obj2;//now the first object referred by obj1 is available for garbage collection&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;u&gt;2-By nulling the reference-&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;&amp;nbsp;Student obj1=new Student();&amp;nbsp;&lt;br /&gt;&amp;nbsp;obj1=null;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;u&gt;3-By anonymous object-&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;&amp;nbsp; new Student();&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;u&gt;finalize() method-&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;The finalize() method is invoked each time when the object is garbage collected. Cleanup processing is done by the finalize() method.&lt;br /&gt;&lt;b&gt;&lt;u&gt;Syntax For finalize() method-&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;protected void finalize(){&lt;br /&gt;}&amp;nbsp; &lt;br /&gt;&lt;br /&gt;&lt;b&gt;Note:&lt;/b&gt; The Garbage collector collects the objects which are created by a new keyword. So if you are creating an object without using a new keyword, you can use the finalize method for them.&lt;br /&gt;&lt;b&gt;&lt;u&gt;gc() method-&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;The gc() is present in System and Runtime classes.&lt;br /&gt;public static void gc(){}&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Example of garbage collection in java:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;public class GCExample&lt;br /&gt;{&lt;br /&gt;&amp;nbsp; protected void finalize () throws Throwable&lt;br /&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp; &amp;nbsp; System.out.print (&quot;GC process done&quot;);&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; public void static main (String args ...)&lt;br /&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp; &amp;nbsp; GCExample obj = new GCExample ();&lt;br /&gt;&amp;nbsp; &amp;nbsp; obj = null;&lt;br /&gt;&amp;nbsp; &amp;nbsp; GCExample a1 = new GCExample ();&lt;br /&gt;&amp;nbsp; &amp;nbsp; GCExample a2 = new GCExample ();&lt;br /&gt;&amp;nbsp; &amp;nbsp; a2 = a1;&lt;br /&gt;&amp;nbsp; &amp;nbsp; System.gc ();&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;u&gt;Some Important Point About Garbage Collector :&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;1-Garbage Collector call finalize() method, not JVM. Garbage Collector is a module of JVM.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;yj6qo&quot; style=&quot;-webkit-text-stroke-width: 0px; background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://basicjavatutorialsforbeginner.blogspot.com/feeds/1506201897490556236/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=7072328287385305382&amp;postID=1506201897490556236' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/7072328287385305382/posts/default/1506201897490556236'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/7072328287385305382/posts/default/1506201897490556236'/><link rel='alternate' type='text/html' href='https://basicjavatutorialsforbeginner.blogspot.com/2020/01/garbage-collection-in-java.html' title='Garbage Collection In Java'/><author><name>Abhishek Singh</name><uri>http://www.blogger.com/profile/00955915184460219032</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//1.bp.blogspot.com/-O1ColsxMvl8/Xf_UtpC9srI/AAAAAAAAA48/OohC6lf1baEcdJGr0a0nfyFtMWLr8BEXACK4BGAYYCw/s220/download.png'/></author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1"/><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD"/></entry><entry><id>tag:blogger.com,1999:blog-7072328287385305382.post-3539265547473431643</id><published>2020-01-13T02:24:00.001+05:30</published><updated>2020-01-14T01:33:47.595+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="coding"/><category scheme="http://www.blogger.com/atom/ns#" term="core java"/><category scheme="http://www.blogger.com/atom/ns#" term="java"/><category scheme="http://www.blogger.com/atom/ns#" term="java beginner"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><title type='text'>Access and Non-Access Modifiers in Java</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;What Are Access And Non-Access Modifiers In Java?&lt;/h2&gt;Types of modifiers in java.&lt;br /&gt;1- Access Modifier&lt;br /&gt;2- Non-Access Modifier&lt;br /&gt;&lt;br /&gt;The visibility of a class, method, constructor, and variable is controlled by &lt;b&gt;access modifiers&lt;/b&gt;.&lt;br /&gt;Whereas non-access modifiers are used to provide other functionalities like &lt;b&gt;synchronizing&amp;nbsp;&lt;/b&gt;&lt;br /&gt;a method or block, restricting the &lt;b&gt;serialization &lt;/b&gt;of a variable, etc.&lt;br /&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Access Modifier-&amp;nbsp;&lt;/h3&gt;Types of &lt;b&gt;access modifier&lt;/b&gt; in java-&lt;br /&gt;1-Private&lt;br /&gt;2-Default&lt;br /&gt;3-Protected&lt;br /&gt;4-Public&lt;br /&gt;&lt;b&gt;&lt;u&gt;Private Access Modifier-&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;Private access modifiers are basically used before method, constructor, and variable.&lt;br /&gt;Private access modifiers &lt;b&gt;can not be used with class and interface.&lt;/b&gt; It can be used with the&lt;br /&gt;class when the class in the inner class i.e. class inside another class. Private is the most&lt;br /&gt;restricted level of access.&lt;br /&gt;&lt;b&gt;&lt;u&gt;Important Points About access Modifier-&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;1-The class in which constructor is declared as private, the object can not be created for&lt;br /&gt;that object.&lt;br /&gt;2-The variable which is declared as private can be accessed using the getter method only.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;u&gt;Example-&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;package Java_Test;&lt;br /&gt;//class with private variable&lt;br /&gt;class PrivateModifier {&lt;br /&gt;&amp;nbsp;private int a = 10;&lt;br /&gt;&amp;nbsp;public int getA() {&lt;br /&gt;&amp;nbsp; return a;&lt;br /&gt;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;public void setA(int a) {&lt;br /&gt;&amp;nbsp; this.a = a;&lt;br /&gt;&amp;nbsp;}&lt;br /&gt;}&lt;br /&gt;public class AccessModifiers {&lt;br /&gt;&amp;nbsp;public static void main(String[] args) {&lt;br /&gt;&amp;nbsp; PrivateModifier pm = new PrivateModifier();&lt;br /&gt;&amp;nbsp; System.out.println(pm.getA());&lt;br /&gt;&amp;nbsp;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;u&gt;Default Access Modifier-&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;Default access modifiers are basically used before method, constructor, and&lt;br /&gt;variable(If we are not declaring any modifier then it is considered as default access modifier). If we declare any method, constructor or variable as default then it will be accessed from any class within the package.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;u&gt;Protected Access Modifier-&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;Protected access modifiers are basically used before method, constructor, and variable.&lt;br /&gt;Protected can not be used with the class. If we declare any method, constructor or variable&lt;br /&gt;as protected then it will be accessed from any class within the package and outside the&lt;br /&gt;package through child class.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;u&gt;Public Access Modifier-&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;A public access modifier is accessible anywhere.&lt;br /&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Non Access Modifier-&amp;nbsp;&lt;/h3&gt;There are various non-access modifiers in java. They are used to provide some information&lt;br /&gt;to JVM.&lt;br /&gt;1-final&lt;br /&gt;2-static&lt;br /&gt;3-synchronized&lt;br /&gt;4-abstract&lt;br /&gt;5-transient&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;u&gt;final-&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;It can be used with class, variable, and method.&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;The class which is declared as final can not be inherited.&lt;/li&gt;&lt;li&gt;The method which is declared as final can not be overridden.&lt;/li&gt;&lt;li&gt;The variable which is declared as final can not be changed once assigned.&lt;/li&gt;&lt;/ul&gt;&lt;b&gt;&lt;u&gt;static-&amp;nbsp;&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;It can be used with block, variable and method and nested class.&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;When a variable is declared as static then it is initialized when class is loaded.&amp;nbsp;&lt;/li&gt;&lt;li&gt;The static variable gets memory only once at the time of class loading.&lt;/li&gt;&lt;li&gt;The method which is declared as static can be called directly with the class name.&lt;/li&gt;&lt;/ul&gt;&lt;b&gt;&lt;u&gt;synchronized-&amp;nbsp;&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;The synchronized keyword is used to control the access of multiple threads to any&lt;br /&gt;shared resource.&lt;br /&gt;&lt;b&gt;&lt;u&gt;abstract-&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;The class has at least one unimplemented method(not mandatory) and declared as abstract is known as abstract class.&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;An abstract class is used to achieve abstraction.&lt;/li&gt;&lt;/ul&gt;&lt;b&gt;&lt;u&gt;transient-&amp;nbsp;&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Java transient keyword is used in serialization.&amp;nbsp;&lt;/li&gt;&lt;li&gt;The data member declared as transient will not be serialized.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://basicjavatutorialsforbeginner.blogspot.com/feeds/3539265547473431643/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=7072328287385305382&amp;postID=3539265547473431643' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/7072328287385305382/posts/default/3539265547473431643'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/7072328287385305382/posts/default/3539265547473431643'/><link rel='alternate' type='text/html' href='https://basicjavatutorialsforbeginner.blogspot.com/2020/01/access-and-non-access-modifiers-in-java.html' title='Access and Non-Access Modifiers in Java'/><author><name>Abhishek Singh</name><uri>http://www.blogger.com/profile/00955915184460219032</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//1.bp.blogspot.com/-O1ColsxMvl8/Xf_UtpC9srI/AAAAAAAAA48/OohC6lf1baEcdJGr0a0nfyFtMWLr8BEXACK4BGAYYCw/s220/download.png'/></author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1"/><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD"/></entry><entry><id>tag:blogger.com,1999:blog-7072328287385305382.post-8619352572128176074</id><published>2019-12-23T01:55:00.000+05:30</published><updated>2020-02-27T23:44:50.147+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="coding"/><category scheme="http://www.blogger.com/atom/ns#" term="core java"/><category scheme="http://www.blogger.com/atom/ns#" term="java"/><category scheme="http://www.blogger.com/atom/ns#" term="java beginner"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><title type='text'>Hello World Program in Java (Beginner)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;Java is an &lt;b&gt;object-oriented programming language&lt;/b&gt;. The very first program that any programmer learns to code is the Hello World Program. So we will learn first a Hello World program. So that we can understand the basics. Because many a time we miss out on the nitty-gritty of the basic syntax. Through the medium of this article, We will get into the details of the Hello World Program in Java.&lt;br /&gt;&lt;br /&gt;Topics which we will cover:&lt;br /&gt;&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;How to write the&amp;nbsp;&lt;b&gt;Hello World program in java&lt;/b&gt;.&lt;/li&gt;&lt;li&gt;&lt;b&gt;Syntax Analysis&lt;/b&gt; to write basic java code.&lt;/li&gt;&lt;li&gt;How to &lt;b&gt;compile a java program&lt;/b&gt;.&lt;/li&gt;&lt;li&gt;How to &lt;b&gt;execute a java program&lt;/b&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;u&gt;Hello World program in Java-&lt;/u&gt;&lt;/b&gt;&lt;/h3&gt;&lt;div&gt;Lets first understand with the coding and see how a basic Hello World program in Java is coded.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;public class HelloWorld{&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;public static void main(String []args){&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; System.out.println(&quot;Hello World&quot;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The above example shows how to write a Hello World program, let&#39;s analyze the program’s syntax in depth.&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;u&gt;Syntax Analysis of Hello World program-&lt;/u&gt;&lt;/b&gt;&lt;/h3&gt;&lt;div&gt;&lt;div&gt;&lt;b&gt;&lt;u&gt;First Line: public class HelloWorld {&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;This line makes use of the keyword class for declaring a &lt;b&gt;new class called HelloWorld&lt;/b&gt;. Since Java is an Object-Oriented Programming (OOP) Language, the entire class definition, including all of its members must be contained in between the opening curly brace { and the closing curly brace }. Also, it is using the &lt;b&gt;public keyword to specify the accessibility of the class from outside the package&lt;/b&gt;.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;b&gt;&lt;u&gt;Second Line: public static void main( String[] args ) {&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;It is called the main method(just like int main() in C ) and acts as the entry point for the Java compiler to begin the execution of the program. In other words, whenever any program is executed in Java, the main method is the first function to be invoked. Other functions in the application are then invoked from the main method. In a standard Java application, one main method is mandatory to trigger the execution.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;public:&lt;/b&gt; it is an access modifier specifies the visibility. It allows JVM to execute the method from anywhere.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;void:&lt;/b&gt; It represents the return type of the method. Since the main method in Java doesn’t return any value its return type is declared as void.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;main():&lt;/b&gt; It is the name of the method that has been configured in the JVM(Java Virtual Machine).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;String[]:&lt;/b&gt; It represents that the Java main method can accept a single line argument of the type String array. This is also known as java command line arguments. Below I have listed down a number of&amp;nbsp; valid java main method signatures:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;public static void main(String args[])&lt;/div&gt;&lt;div&gt;public static void main(String… args)&lt;/div&gt;&lt;div&gt;static public void main(String[] args)&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;public static void main(String[] args)&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div&gt;public static void main(String []args)&lt;/div&gt;&lt;div&gt;public static final void main(String[] args)&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div&gt;final public static void main(String[] args)&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;public static void main(String[] name_arg)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;b&gt;&lt;u&gt;Third Line: System.out.println( “Hello World” );&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;System:&lt;/b&gt; It is a pre-defined class in java.lang package which holds various useful methods and variables.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;out:&lt;/b&gt; It is a static member field of type PrintStream.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;println:&lt;/b&gt; It is a method of PrintStream class and is used for printing the argument that has been passed to the standard console and a newline. You can &lt;b&gt;also use print() method instead of println().&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;h3&gt;&lt;b&gt;&lt;u&gt;How to compile a java program-&lt;/u&gt;&lt;/b&gt;&lt;/h3&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;Now what you need to is type in this program in your text editor save it with the class name that you have used in your program. In my case, I will be saving it as&amp;nbsp; HelloWorld.java&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The next step is to, go to your console window and navigate to the directory where you have saved your program.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now in order to compile the program type in the below command:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;javac HelloWorld.java&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Note:&lt;/b&gt; Java is case-sensitive, thus make sure that you type in the file name in the correct format.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If successfully executed, &lt;b&gt;this command will generate a HelloWorld.class file&lt;/b&gt; which will be machine-independent and portable in nature.&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;u&gt;How to&amp;nbsp;execute a java program-&lt;/u&gt;&lt;/b&gt;&lt;/h3&gt;&lt;div&gt;&lt;div&gt;In order to execute your HelloWorld in Java program on the command line, all you need to do is type in the below code:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;java HelloWorld&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Note:&lt;/b&gt;&amp;nbsp; You can choose any name for the file (. java). there is no matter to what is the name of classes in that file means that class names may be totally different from the file name. you should compile the program with the file name and you should run the program with the class name in which the main method exists.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;line number1 index0 alt2&quot; style=&quot;background: none white !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: white; direction: ltr !important; float: none !important; font-family: Monaco, Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 16px; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;line number1 index0 alt2&quot; style=&quot;background: none white !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: white; direction: ltr !important; float: none !important; font-family: Monaco, Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 16px; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;line number1 index0 alt2&quot; style=&quot;background: none white !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: white; direction: ltr !important; float: none !important; font-family: Monaco, Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 16px; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;line number1 index0 alt2&quot; style=&quot;background: none white !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: white; direction: ltr !important; float: none !important; font-family: Monaco, Consolas, &amp;quot;Bitstream Vera Sans Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: 16px; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&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/-YgUCvdnmJL4/XlgHCsXLcPI/AAAAAAAAA6U/YGBnoP0YTc0IcLS4_huucbFBa2Cjb82LwCLcBGAsYHQ/s1600/WhatsApp%2BImage%2B2020-02-27%2Bat%2B23.43.24.jpeg&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;616&quot; data-original-width=&quot;1279&quot; height=&quot;154&quot; src=&quot;https://1.bp.blogspot.com/-YgUCvdnmJL4/XlgHCsXLcPI/AAAAAAAAA6U/YGBnoP0YTc0IcLS4_huucbFBa2Cjb82LwCLcBGAsYHQ/s320/WhatsApp%2BImage%2B2020-02-27%2Bat%2B23.43.24.jpeg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span id=&quot;goog_1738175399&quot;&gt;&lt;/span&gt;&lt;a href=&quot;https://www.blogger.com/&quot;&gt;&lt;/a&gt;&lt;span id=&quot;goog_1738175400&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://basicjavatutorialsforbeginner.blogspot.com/feeds/8619352572128176074/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=7072328287385305382&amp;postID=8619352572128176074' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/7072328287385305382/posts/default/8619352572128176074'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/7072328287385305382/posts/default/8619352572128176074'/><link rel='alternate' type='text/html' href='https://basicjavatutorialsforbeginner.blogspot.com/2019/12/hello-world-programme-in-java-beginner.html' title='Hello World Program in Java (Beginner)'/><author><name>Abhishek Singh</name><uri>http://www.blogger.com/profile/00955915184460219032</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//1.bp.blogspot.com/-O1ColsxMvl8/Xf_UtpC9srI/AAAAAAAAA48/OohC6lf1baEcdJGr0a0nfyFtMWLr8BEXACK4BGAYYCw/s220/download.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://1.bp.blogspot.com/-YgUCvdnmJL4/XlgHCsXLcPI/AAAAAAAAA6U/YGBnoP0YTc0IcLS4_huucbFBa2Cjb82LwCLcBGAsYHQ/s72-c/WhatsApp%2BImage%2B2020-02-27%2Bat%2B23.43.24.jpeg" height="72" width="72"/><thr:total>1</thr:total><gd:extendedProperty name="commentSource" value="1"/><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD"/></entry></feed>