<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[AI Graduate]]></title><description><![CDATA[The One-Stop Shop for Product Management, AI, and Technology]]></description><link>https://aigraduate.com/</link><image><url>https://aigraduate.com/favicon.png</url><title>AI Graduate</title><link>https://aigraduate.com/</link></image><generator>Ghost 5.33</generator><lastBuildDate>Sun, 26 Apr 2026 10:20:51 GMT</lastBuildDate><atom:link href="https://aigraduate.com/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[duty-free.cc]]></title><link>https://aigraduate.com/duty-free-cc/</link><guid isPermaLink="false">69dd965da894ee4df82569da</guid><dc:creator><![CDATA[Rishi Sidhu]]></dc:creator><pubDate>Tue, 14 Apr 2026 01:20:29 GMT</pubDate><content:encoded/></item><item><title><![CDATA[Beginners in Java — Getting Started with OOP]]></title><description><![CDATA[
Java is an object oriented programming language — what does that mean?
]]></description><link>https://aigraduate.com/beginners-in-java---getting-started-with-oop/</link><guid isPermaLink="false">5ea89237cac0164a91b5bd13</guid><category><![CDATA[Java]]></category><category><![CDATA[Coding]]></category><category><![CDATA[Programming]]></category><dc:creator><![CDATA[Rishi Sidhu]]></dc:creator><pubDate>Tue, 24 Dec 2019 00:00:00 GMT</pubDate><media:content url="https://images.unsplash.com/photo-1526498460520-4c246339dccb?ixlib=rb-1.2.1&amp;q=80&amp;fm=jpg&amp;crop=entropy&amp;cs=tinysrgb&amp;w=2000&amp;fit=max&amp;ixid=eyJhcHBfaWQiOjExNzczfQ" medium="image"/><content:encoded><![CDATA[<h3 id="java-is-an-object-oriented-programming-language-what-does-that-mean">Java is an object oriented programming language&#x200A;&#x2014;&#x200A;what does that&#xA0;mean?</h3><img src="https://images.unsplash.com/photo-1526498460520-4c246339dccb?ixlib=rb-1.2.1&amp;q=80&amp;fm=jpg&amp;crop=entropy&amp;cs=tinysrgb&amp;w=2000&amp;fit=max&amp;ixid=eyJhcHBfaWQiOjExNzczfQ" alt="Beginners in Java&#x200A;&#x2014;&#x200A;Getting Started with OOP"><p>Whenever a programming methodology is based on objects or classes, instead of just functions and procedures it is called <strong>O</strong>bject <strong>O</strong>riented <strong>P</strong>rogramming (<strong>OOP</strong>).</p><blockquote>All code in Java must be contained within&#xA0;classes</blockquote><p>Objects in an object oriented language are organised into classes or <strong>in simpler terms a </strong>class gives birth to objects. Java is one such programming language.</p><h2 id="classes-and-objects">Classes and&#xA0;Objects</h2><p>Everything in a java program is contained within a class. A class can be considered as a <strong>factory </strong>that produces <strong>objects. </strong>An object contains data inside of it. It can have one data item or many. e.g. a <strong>lunchbox object </strong>might contain 3 data items</p><ol><li>Fries (of the type <strong>solid food</strong>)</li><li>Burger (of the type <strong>solid food</strong>)</li><li>Cold Drink (of the type <strong>liquid food</strong>)</li></ol><p>These 3 different items inside our object are called <strong>fields. Every field must have a type. </strong>In the above example, we have 3 fields but 2 of them have the same type. At the same time we <strong>methods </strong>that act on data. For example, methods can be used to see what data is contained inside an object. These are called accessor methods. We can also have methods that modify the data inside the object. These are known as updater methods.</p><p>Let&#x2019;s say that we have a food factory (<strong>class</strong>). It makes lunch boxes (<strong>objects</strong>). A lunchbox contains 3 different items of food(<strong>fields</strong>). Two of them are the same type (<strong>solid food</strong>) and one is different (<strong>liquid food</strong>). We have 3 people who interact to use this food. The chef <strong>(Method 1) </strong>heats the food, the waiter (<strong>Method 2</strong>) serves the food and the consumer (<strong>Method 3</strong>) eats the food.</p><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://aigraduate.com/content/images/downloaded_images/Beginners-in-Java---Getting-Started-with-OOP/1-6ryHBKWO-QFZ9f-ilcPkYQ.png" class="kg-image" alt="Beginners in Java&#x200A;&#x2014;&#x200A;Getting Started with OOP" loading="lazy"><figcaption>How OOP&#xA0;Works</figcaption></figure><blockquote>In Java programs, the primary &#x201C;actors&#x201D; are <em><strong>objects</strong></em>. Every object is an <em><strong>instance </strong></em>of a class, which serves as the <em><strong>type </strong></em>of the object and as a blueprint, defining the data which the object stores and the methods for accessing and modifying that data.<br>&#x200A;&#x2014;&#x200A;<em>Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser (<strong>Data Structures and Algorithms in Java</strong>)</em></blockquote><h3 id="understanding-objects">Understanding Objects</h3><p>An object is an instance of the class i.e. A class can give rise to many objects. For example</p><h3 id="object-1">Object 1</h3><ol><li>Solid Food Item 1&#x200A;&#x2014;&#x200A;Fries</li><li>Solid Food Item 2&#x200A;&#x2014;&#x200A;Burger</li><li>Liquid Food Item 1&#x200A;&#x2014;&#x200A;Cold Drink</li></ol><h3 id="object-2">Object 2</h3><ol><li>Solid Food Item 1&#x200A;&#x2014;&#x200A;Rice</li><li>Solid Food Item 2&#x200A;&#x2014;&#x200A;Fish</li><li>Liquid Food Item 1&#x200A;&#x2014;&#x200A;Water</li></ol><figure class="kg-card kg-image-card"><img src="https://aigraduate.com/content/images/downloaded_images/Beginners-in-Java---Getting-Started-with-OOP/1-C2mqhSsOQxapAvXz4pBKTg.png" class="kg-image" alt="Beginners in Java&#x200A;&#x2014;&#x200A;Getting Started with OOP" loading="lazy"></figure><h2 id="the-process">The Process</h2><p>Let&#x2019;s try to see how to build a basic Factory Class. Let&#x2019;s first take a look at the complete code.</p><h3 id="filename">Filename</h3><p>The lines <strong>public class Factory{} </strong>enclose the complete code. The file has to be named as the class name. So the filename is also Factory.java.</p><pre><code>public class Factory{
   ...
}</code></pre><h3 id="fields-instance-variables">Fields/Instance Variables</h3><p>Now the top 3 lines give you the 3 items (instance variables) you want in your lunchbox. Right now you can see that all 3 have the same type = <strong>String.</strong> Java gives you the flexibility to create your own <strong>types</strong> which essentially means creating a class by that name. So if you were to create a <strong>SolidFood</strong> class, for example, you would have to write <strong>public class SolidFood{} </strong>and that&#x2019;s all.</p><p>Right now we have 3 instance variables of the type String and names SolidFood1, SolidFood2 and LiquidFood1.</p><pre><code> private String SolidFood1;    // Solid Food 1st Instance Variable
 private String SolidFood2;    // Solid Food 2nd Instance Variable 
 private String LiquidFood1;   // Liquid Food 3rd Instance Variable</code></pre><h3 id="constructors">Constructors</h3><p>The code that creates an object lies inside the <strong>constructor.</strong> A constructor can be an empty one or can take some input arguments that are used to define the object. In our case <strong>sf1, sf2 and lf1 </strong>are the arguments that define what items are contained in our lunchbox.</p><blockquote>In simple words, a constructor defines what the fields of the object look&#xA0;like.</blockquote><pre><code>public Factory(){}      // 0-arg constructor (Not used)
// 3-arg constructor
 public Factory(String sf1, String sf2, String lf1){      
  SolidFood1   = sf1;
  SolidFood2   = sf2;
  LiquidFood1  = lf1;
 }</code></pre><h3 id="methods">Methods</h3><p>Methods are used to either fetch object fields or modify them. In our case, we have only written fields that fetch the item names.</p><pre><code>public String getSF1(){return SolidFood1;} // Method to get the name of 1st Instance Variable
 public String getSF2(){return SolidFood2;} // Method to get the name of 2nd Instance Variable
 public String getLF1(){return LiquidFood1;} // Method to get the name of 3rd Instance Variable</code></pre><p>The main method is the only method that needs to be in every program. It is the only thing that java compiler runs. From inside the main, you can create objects, use methods on these objects and print stuff.</p><h3 id="object-creation">Object Creation</h3><p>Object is created by calling a constructor. Once an object is created you can use various methods at your disposal to understand or modify the object. Here we are just showing how to access field names.</p><pre><code>Factory lunchBox = new Factory(&quot;s1&quot;,&quot;s2&quot;, &quot;l1&quot;); // Object Created Yay!!!</code></pre><h3 id="how-to-run">How to&#xA0;run</h3><p>Just in case you do not have java visit <a href="https://java.com/en/download/help/mac_install.xml">this page.</a></p><p>Assuming you have java installed in your system you should be able to run the program using the following commands.</p><pre><code>&gt; javac Factory.java (This command compiles your code into Machine Readable Code)

&gt; java Factory (Running the Program)</code></pre><p>The output you see looks like this</p><figure class="kg-card kg-image-card"><img src="https://aigraduate.com/content/images/downloaded_images/Beginners-in-Java---Getting-Started-with-OOP/1-oJXatEfH8UOaBa6wH2cCrg.png" class="kg-image" alt="Beginners in Java&#x200A;&#x2014;&#x200A;Getting Started with OOP" loading="lazy"></figure><hr><p>There is a lot more involved in OOP. This was just the beginning. Later articles will include more involved concepts of object oriented programming.</p><h3 id="references">References</h3><ol><li><a href="https://gist.github.com/rishisidhu/291f9786e3b7c0b6c9036461b4e3440c">Gist Link</a></li><li><a href="https://java.com/en/download/help/download_options.xml#mac">Java Download</a></li><li><a href="https://www.wiley.com/en-us/Data+Structures+and+Algorithms+in+Java%2C+6th+Edition-p-9781118771334">Data Structures Book</a></li></ol>]]></content:encoded></item></channel></rss>