<?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:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Pawan Kr. Tiwari on Medium]]></title>
        <description><![CDATA[Stories by Pawan Kr. Tiwari on Medium]]></description>
        <link>https://medium.com/@pawankr.tiwari?source=rss-fb6f4c52cf11------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*FqVin5OTbjtniwN0gLLYVQ.png</url>
            <title>Stories by Pawan Kr. Tiwari on Medium</title>
            <link>https://medium.com/@pawankr.tiwari?source=rss-fb6f4c52cf11------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 08:02:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pawankr.tiwari/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Modifiers in Java: The Gatekeepers of Your Code]]></title>
            <link>https://medium.com/@pawankr.tiwari/modifiers-in-java-the-gatekeepers-of-your-code-09bc8138d96f?source=rss-fb6f4c52cf11------2</link>
            <guid isPermaLink="false">https://medium.com/p/09bc8138d96f</guid>
            <category><![CDATA[final-keyword-in-java]]></category>
            <category><![CDATA[class-modifiers]]></category>
            <category><![CDATA[java-modifiers]]></category>
            <category><![CDATA[access-specifiers]]></category>
            <category><![CDATA[static-keyword]]></category>
            <dc:creator><![CDATA[Pawan Kr. Tiwari]]></dc:creator>
            <pubDate>Wed, 17 Sep 2025 18:27:43 GMT</pubDate>
            <atom:updated>2025-09-17T18:27:43.574Z</atom:updated>
            <content:encoded><![CDATA[<h4>Ever wondered who decides what parts of your code stay private, protected, or public? Let’s decode the invisible shields that shape your class architecture and control visibility like a pro.</h4><p>Keywords used to change the accessibility, behavior, or properties of classes, methods, and variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jiny_MwVDsyT3P1YpgRGPg.png" /></figure><h4>Access Modifiers :</h4><p>It specifies the access of the data( property/method ) and control visibility.</p><ul><li><strong>Public</strong>: Everyone (Accessible from anywhere)</li><li><strong>Private</strong> : only owner (Accessible only within the same class)</li><li><strong>Protected</strong>: All in same package can access. only child class can access in another package.</li></ul><p>💡When we access protected from another package, we have to use child class reference.</p><ul><li><strong>Default / No Modifier (<em>Package-private</em>)</strong> : All in same package can access. No one in another package can access.</li></ul><pre>public class Car {<br>    private String engine;        // Only accessible inside Car class<br>    protected int wheels;         // Accessible in package + subclasses<br>    String brand;                 // default: package-level<br>    public void drive() {}       // Accessible from anywhere<br>}</pre><h4>Non-Access Modifiers (Define behavior &amp; properties)</h4><ul><li><strong>static</strong> – Used with variables and methods.<br>Belongs to the class, not the instance.</li><li><strong>final</strong> – Used with variables, methods, and classes.<br>Cannot be changed or overridden.</li><li><strong>abstract</strong> – Used with classes and methods. <br>Class can&#39;t be instantiated; <br>method must be implemented</li><li><strong>synchronized</strong> – Used with methods and blocks.<br>Ensures thread-safe execution</li><li><strong>volatile</strong> – Used with variables.<br>Guarantees visibility across threads.</li><li><strong>transient</strong> – Used with variables.<br>Skips variable during serialization.</li><li><strong>native</strong> – Used with methods.<br> Method is implemented in native (non-Java) code.</li></ul><pre>final class Shape {}           // Can&#39;t be extended<br>static int count = 0;          // Shared across all objects<br>abstract class Animal {}       // Can&#39;t create object of Animal<br>transient int tempData;        // Won&#39;t be saved during serialization<br>volatile boolean flag = false;    // shared signal</pre><p>With access and non-access modifiers under your belt, it’s time to tackle real interview challenges. <br>Next, we’ll dive into final and static—how they affect variables, methods, and classes, their role in overloading and overriding, and even where static final values live in memory. Let’s decode what interviewers are really testing in next post.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=09bc8138d96f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Constructors in Java: The Hidden Architects of Your Code]]></title>
            <link>https://medium.com/@pawankr.tiwari/constructors-in-java-the-hidden-architects-of-your-code-02eaee714197?source=rss-fb6f4c52cf11------2</link>
            <guid isPermaLink="false">https://medium.com/p/02eaee714197</guid>
            <category><![CDATA[constructor]]></category>
            <category><![CDATA[objects]]></category>
            <category><![CDATA[oops-concepts]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[object-oriented]]></category>
            <dc:creator><![CDATA[Pawan Kr. Tiwari]]></dc:creator>
            <pubDate>Wed, 17 Sep 2025 17:52:02 GMT</pubDate>
            <atom:updated>2025-09-17T17:54:56.397Z</atom:updated>
            <content:encoded><![CDATA[<h4>Ever wondered who lays the foundation before your Java objects come to life? Dive into the world of constructors — where instantiation meets intention, and your classes begin their journey.</h4><p><strong>A Special method used to initialize objects while creating it.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iY2ZqRH4BqKwMcUw8LDlSw.png" /></figure><p>It’s name should be same as that of the class name in which it resides. It is a block of code.</p><pre>Myclass obj = new Myclass();<br><br>//  new = creates the object of class MyClass.<br>//  It invokes the constructor to initialize this newly created object..</pre><ul><li>No return type, not even void.</li><li>If you keep the return type for the constructor, it will be treated as a method.</li><li>Every class should have at least one constructor.</li><li>If you don’t write a constructor for your class, the compiler will give a default constructor.</li></ul><blockquote>Execution order of constructor call → Parent → Child → Grandchild.</blockquote><ul><li>A constructor in Java cannot be abstract, final, static, and Synchronized.</li><li>Access modifiers can be used in constructor declaration to control its access. <strong>i.e.</strong> which other class can call the constructor.</li></ul><blockquote><em>How many Constructors String Class Have? 13</em></blockquote><h3><strong>Types of Constructors:</strong></h3><h4><strong>Parameterized Constructors</strong></h4><ul><li>Accepts <strong>arguments</strong> to initialize the object with specific values at the time of creation.</li><li>Used when we need <strong>custom initialization</strong>.</li></ul><blockquote>Constructors can be overloaded by defining multiple constructors with different parameter lists.</blockquote><h4><strong>Default Constructors</strong></h4><ul><li>It is <strong>automatically provided</strong> if no constructor is explicitly defined.</li><li>Used to initialize an object with <strong>default values</strong>.</li></ul><h4><strong>Copy Constructors</strong></h4><ul><li>Creates a new object by copying values from an <strong>existing object</strong>.</li><li>Helps in <strong>cloning objects</strong>.</li></ul><blockquote>Now Come, let’s put some lights on questions from interviewer:</blockquote><h3><strong>Why constructor name = class name:</strong></h3><p>A constructor’s job is to <strong>create and initialize objects</strong>.</p><ul><li>By giving it the same name as the class, the compiler knows it’s not a regular method but a <strong>constructor. </strong>When you write:</li></ul><p>ClassName variableName = new ClassName(); <br> Ex. Student s = new Student();</p><ul><li>The compiler looks for a <strong>constructor with the name </strong><strong>Student</strong>, not a random method.</li><li>If constructors could have any name, the compiler wouldn’t know which method to call during object creation.<br>Constructors don’t have a return type (not even void)<strong>, only way the compiler can identify a constructor</strong> is by matching its name with the class.</li></ul><h3><strong>Can Abstract Classes Have Constructors And What about Interfaces:</strong></h3><p>Even though abstract classes cannot be instantiated, they can have constructors to initialize fields for subclasses. <br>The constructor of the abstract class is invoked when a subclass is instantiated.</p><h4>Purpose of abstract class constructor:</h4><ul><li>Initialize common fields (e.g., name, id)</li><li>Provide base setup logic.</li></ul><h4>Why interface can’t have constructors</h4><p><strong>Interface = contract</strong></p><ul><li>Interfaces <strong>don’t have state</strong> → no fields to initialize (except public static final constants)</li><li>Interfaces <strong>don’t represent objects</strong> → you don’t create instances of an interface</li><li>The implementing class’s constructor takes care of object creation.</li></ul><p>Let’s Imagine Marvel’s Famous <strong>WHAT IF Series 😉:</strong></p><p><strong>If interface had constructor:</strong></p><ul><li>It would suggest <em>creating an instance of the interface</em>, which violates the purpose of an interface (it’s a contract, not an object).</li></ul><p><strong>If interface had fields needing initialization:</strong></p><ul><li>That would go against the rule that fields in interface are always public static final → constants → must be initialized at declaration.</li></ul><h3><strong>Can we override a constructor?</strong></h3><p>No. Constructors are <strong>not inherited</strong>; therefore, they cannot be overridden.</p><p>Constructors set the stage — but this and super control the spotlight. In the next post, we’ll explore how these keywords shape object behavior and inheritance flow in Java.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=02eaee714197" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“Classes in Java: Everything You Need to Know for Interviews”]]></title>
            <link>https://medium.com/@pawankr.tiwari/classes-in-java-everything-you-need-to-know-for-interviews-a94cc349263d?source=rss-fb6f4c52cf11------2</link>
            <guid isPermaLink="false">https://medium.com/p/a94cc349263d</guid>
            <category><![CDATA[wrapper-class]]></category>
            <category><![CDATA[oops-interview-questions]]></category>
            <category><![CDATA[abstract-class-in-java]]></category>
            <category><![CDATA[java-class]]></category>
            <category><![CDATA[class]]></category>
            <dc:creator><![CDATA[Pawan Kr. Tiwari]]></dc:creator>
            <pubDate>Sun, 31 Aug 2025 13:30:19 GMT</pubDate>
            <atom:updated>2025-09-17T17:08:04.709Z</atom:updated>
            <content:encoded><![CDATA[<h4>The Secret Blueprint Behind Every Powerful Program</h4><p>A Class is a blueprint for creating objects.<br>Class defines the behavior of an object (how it looks, its properties, and its functionalities).</p><ul><li>A class contains <strong>fields</strong> (variables) to store data and <strong>methods</strong> (functions) to define the behavior or functionality of the objects.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ib10EJqMRBSI1WjbL245xA.png" /><figcaption>Class In Java</figcaption></figure><h3>All Important Type of Class in Java :</h3><h3><strong>Concrete class</strong></h3><ul><li>A class that has <strong>complete implementations</strong>.</li><li>Can be instantiated (you can create objects of it).</li></ul><pre>java.lang.String<br>java.util.ArrayList<br>java.util.HashMap<br>java.time.LocalDate<br>java.io.File</pre><p>Often used as Controller, Service, Utility, Manager, etc.</p><h3><strong>POJO</strong> class</h3><ul><li>Simple class used to represent data (model).</li><li>having only <strong>private fields</strong>, <strong>getters/setters</strong>, and maybe toString(), equals() etc and No business logic.</li><li>POJO is always concrete.</li></ul><pre>public class Student {<br>    private String name;<br>    private int age;<br><br>    // Getters and Setters<br>    // No Args Constructors<br>    // toString();<br>    // Constructors<br>}</pre><p>Often used in real-world apps for data transfer, models, Data Transfer Object (DTO), Entity etc.</p><h3><strong>Abstract</strong> class</h3><ul><li>Cannot be instantiated directly.</li><li>Meant to be <strong>inherited</strong> and <strong>partially implemented</strong>.</li></ul><pre>java.util.AbstractList  // Parent class of ArrayList <br>java.util.AbstractMap   // Parent class of HashMap<br>java.util.AbstractSet   // Parent Class of HashSet<br>java.io.Reader<br>java.io.InputStream</pre><h3><strong>Utility/Helper</strong> class</h3><ul><li>All methods are static.</li><li>Can not be instantiated (usually has a private constructor).</li></ul><pre>java.util.Collections<br>java.util.Arrays<br>java.util.Objects<br>java.lang.Math</pre><h3><strong>Final</strong> class</h3><ul><li>A final class <strong>cannot be subclassed (extended)</strong>.</li><li>Once a class is marked final, no other class can inherit from it.</li><li>Cannot be extended (inherited) →classes ,overridden →final , can not be changed →variables.</li><li>Useful when you want to <strong>prevent overriding</strong> or keep behavior fixed.</li></ul><pre>java.lang.String<br>java.lang.Math<br>java.util.Collections<br>java.lang.System<br>java.lang.Integer</pre><p>Often used with utility/helper/data classes. You <strong>can still</strong>:</p><ul><li>Instantiate objects.</li><li>can implement interfaces.</li><li>Include methods, static blocks, variables, constructors as usual.</li><li>Be used as a data type or composition in other classes.</li><li>Wrapper class objects can store null value.</li></ul><h3>Exception/Error Class</h3><pre>java.lang.Exception<br>java.lang.RuntimeException<br>java.io.IOException<br>java.lang.NullPointerException<br>java.lang.ArithmeticException</pre><h3><strong>Wrapper</strong> Class</h3><p>A class that wraps the value of all the primitive types in an object.</p><ul><li>Each primitive type has a corresponding wrapper class in the java.lang.package.</li><li>Wrapper class objects can store null value.</li></ul><pre>java.lang.Integer<br>java.lang.Double<br>java.lang.Boolean<br>java.lang.Character<br>java.lang.Byte</pre><blockquote>Now Come, let’s come to an interesting topic of interviewer’s :</blockquote><h3>Legacy Classes</h3><ul><li>Introduced in <strong>JDK 1.0 / 1.1</strong>.</li><li>Made <strong>synchronized</strong> by default (thread-safe but slower).</li><li>Later <strong>adapted into Collections Framework</strong> (e.g., Vector now implements List, Hashtable implements Map).</li><li>Rarely used in modern applications (except in legacy codebases).</li></ul><p><strong>Vector</strong></p><ul><li>Similar to ArrayList but synchronized.</li><li>Used in older Java code for dynamic arrays.</li><li>Vector&lt;String&gt; v = new Vector&lt;&gt;(); <br>v.add(&quot;Java&quot;); <br>v.add(&quot;Python&quot;);</li></ul><p><strong>Stack</strong> (extends Vector)</p><ul><li>A stack implementation (LIFO).</li><li>Modern alternative: Deque (ArrayDeque).</li><li>Stack&lt;Integer&gt; stack = new Stack&lt;&gt;(); <br>stack.push(10); <br>stack.push(20); <br>System.out.println(stack.pop()); // 20</li></ul><p><strong>Hashtable</strong></p><ul><li>Key-value data structure like HashMap, but synchronized.</li><li>Modern alternative: HashMap or ConcurrentHashMap.</li><li>Hashtable&lt;Integer, String&gt; ht = new Hashtable&lt;&gt;(); <br>ht.put(1, &quot;Java&quot;); <br>ht.put(2, &quot;Python&quot;);</li></ul><p><strong>Enumeration (interface)</strong></p><ul><li>Used for iterating elements before Iterator was introduced.</li><li>Now considered outdated.</li><li>Vector&lt;String&gt; v = new Vector&lt;&gt;(); <br>v.add(&quot;C&quot;); v.add(&quot;C++&quot;); <br>Enumeration&lt;String&gt; e = v.elements();<br>while(e.hasMoreElements()) {<br> System.out.println(e.nextElement()); <br>}</li></ul><p><em>Now that you understand the different types of classes in Java, the next step is to see how they interact through </em><strong><em>Objects and OOP principles (Encapsulation, Inheritance, Polymorphism, Abstraction).</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a94cc349263d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Primitive vs Non-Primitive Data Types in Java: What Every Java Beginner Should Know]]></title>
            <link>https://medium.com/@pawankr.tiwari/primitive-vs-non-primitive-data-types-in-java-what-every-java-beginner-should-know-d6abf4246401?source=rss-fb6f4c52cf11------2</link>
            <guid isPermaLink="false">https://medium.com/p/d6abf4246401</guid>
            <category><![CDATA[primitive-data-types]]></category>
            <category><![CDATA[reference-data-type]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[data-types-in-java]]></category>
            <category><![CDATA[data-type]]></category>
            <dc:creator><![CDATA[Pawan Kr. Tiwari]]></dc:creator>
            <pubDate>Wed, 13 Aug 2025 12:45:19 GMT</pubDate>
            <atom:updated>2025-08-13T12:45:19.007Z</atom:updated>
            <content:encoded><![CDATA[<p>“If everything in Java is an object, why aren’t int, char, or boolean objects?&quot;</p><p>Java is <strong>statically typed programming language </strong>which means variable types are known at the compile time.</p><p>For example “int a = &quot;Medium&quot;;&quot; gives compiler error in Java as we are trying to store string in an integer type.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s0vg-EwqgPHw0OSMCr-Vwg.png" /></figure><h3>What Are Data Types in Java?</h3><p>Data types in Java define the <strong>kind of data</strong> a variable can hold. Every variable in Java must be declared with a type, either <strong>primitive</strong> or <strong>non-primitive</strong>.</p><h3>Primitive Data Types</h3><p>Primitive data types are the <strong>most basic data types</strong> built into the Java language. They are <strong>not objects</strong>, and they store <strong>actual values</strong> in memory.</p><h3>🔍 Characteristics of Primitive Types:</h3><ul><li><strong>Predefined</strong> by Java (not user-defined)</li><li><strong>Not objects</strong> — they don’t belong to any class</li><li><strong>Store values directly on stack.</strong></li><li><strong>Memory efficient and faster</strong></li></ul><p>Data Type Size Example:</p><p><strong>Numeric Type:</strong><br>byte 1 byte byte b = 100; <br>short 2 bytes short s = 10000; <br>int 4 bytes int x = 42; <br>long 8 bytes long l = 123456789L; <br>float 4 bytes float f = 5.75f; <br>double 8 bytes double d = 19.99;</p><p><strong>Non Numeric Type:</strong><br>char 2 bytes char c = &#39;A&#39;; <br>boolean 1 bit boolean isOn = true;</p><blockquote>For <strong>numeric types, </strong>the default is <strong>zero</strong> in their respective format.<br>For <strong>char</strong>, <em>&#39;\u0000&#39;</em> is the <strong>null character</strong> (Unicode code point 0, not the same as <em>null</em> for objects).<br>For <strong>boolean</strong>, the default is <em>false</em>.</blockquote><h3>Non-Primitive Data Types</h3><p>Non-primitive (also called <strong>reference types</strong>) are <strong>not defined by the language directly</strong> but are <strong>built using classes</strong> — either built-in or user-defined. They <strong>refer to objects</strong> stored in memory.</p><blockquote><em>🔎 </em><strong><em>Why are they called non-primitive?</em></strong><em><br> Because they’re based on </em><strong><em>classes (In-built Classes of JAVA) </em></strong><em>and </em><strong><em>hold references to memory locations</em></strong><em> rather than actual values. They offer more functionality, but with a bit more overhead.</em></blockquote><h3>🧠 Examples of Non-Primitive Types:</h3><ul><li><strong>Strings</strong> → String name = &quot;Java&quot;;</li><li><strong>Arrays</strong> → int[] numbers = {1, 2, 3};</li><li><strong>Classes &amp; Objects</strong> → Student s = new Student();</li><li><strong>Interfaces &amp; Enums</strong></li></ul><h3>💡 Characteristics of Non-Primitives:</h3><ul><li>Created using <strong>constructors or literals</strong></li><li><strong>Can be null</strong> (unlike primitives).</li><li><strong>Methods</strong> can be called on them (like name.length())</li><li>Stored as <strong>references</strong> (they don’t store actual data, just the address) on stack<strong>.</strong></li></ul><blockquote><strong>Reference variables</strong> can be in stack or heap (depending on whether they are local or part of an object).<br><strong>Actual objects</strong> (Person, Strings, arrays, etc.) always live in heap.<br>String literals live in the <strong>String Pool</strong> (a part of the heap).</blockquote><p><strong>But I heard about Wrapper Classes, what they are, you can learn about them in below article 👇</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d6abf4246401" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Invisible Wall Between Java Objects and Variables]]></title>
            <link>https://medium.com/@pawankr.tiwari/the-invisible-wall-between-java-objects-and-variables-d66956ba729f?source=rss-fb6f4c52cf11------2</link>
            <guid isPermaLink="false">https://medium.com/p/d66956ba729f</guid>
            <category><![CDATA[objects]]></category>
            <category><![CDATA[objects-in-java]]></category>
            <category><![CDATA[variables]]></category>
            <category><![CDATA[variables-in-java]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Pawan Kr. Tiwari]]></dc:creator>
            <pubDate>Sun, 08 Jun 2025 18:53:17 GMT</pubDate>
            <atom:updated>2025-06-08T18:54:22.575Z</atom:updated>
            <content:encoded><![CDATA[<h4>A Deep &amp; Memory-Level Perspective You Never Knew You Needed</h4><p>You write Java code every day, but do you <em>really</em> understand the difference between an object and a variable?</p><p>Let’s break it down — with memory maps, scope rules, and insights you won’t find in most tutorials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*gd51ErFgFvxguDYxlVr9zA.jpeg" /><figcaption>Object &amp; Variable in Java</figcaption></figure><h3>🟩What Is an Object in Java?</h3><p>Think of a <strong>class</strong> as a blueprint… but it’s the <strong>object</strong> that brings that blueprint to life.</p><ul><li>Objects are <strong>runtime instances</strong> of a class.</li><li>Created using the new keyword.</li><li>Access fields (state) and methods (behavior) of the class.</li><li>Every object has:</li><li>✅ <strong>State</strong> → via fields/attributes</li><li>⚙️ <strong>Behavior</strong> → via methods</li><li>🆔 <strong>Identity</strong> → a unique memory reference</li></ul><pre>Student s1 = new Student();  // ← creates an object of Student in heap</pre><blockquote>Here s1 is the variable that’s holding the real value of Student class object in the heap memory. <br>Read that Again..</blockquote><h3>🟨What Is a Variable Then?</h3><p>A <strong>variable</strong> is just a named container that holds a value. It’s called “variable” because the value it holds can change.</p><pre>int x = 10;                        // x is variable.<br><br>String job;                        // Declaration -- job is variable<br>job = &quot;Java Developer&quot;;            // Assignment<br>String job = &quot;Java Developer&quot;;     // Initialization</pre><p>Every variable has a:</p><ul><li><strong>Data type</strong></li><li><strong>Scope</strong></li><li><strong>Memory footprint</strong></li></ul><p>But hold on, not all variables are the same…</p><h3>🔍1. Based on the Value It Holds: Primitive vs Reference Variables</h3><h3>🔹 Primitive Variables</h3><ul><li>Store simple values (int, char, float, etc.)</li><li>Memory: 🧱 <strong>Stack</strong></li></ul><pre>int x = 10; // Stored directly in stack</pre><h3>🔸Reference Variables</h3><ul><li>Point to <strong>objects</strong> in memory.</li><li>Store: <strong>Address</strong> (not the object itself)</li><li>Memory: 🧱 <strong>Stack (reference) + </strong>🧠<strong>Heap (actual object)</strong></li></ul><pre>String s = &quot;Hello&quot;;      // &#39;s&#39; in stack, &quot;Hello&quot; in heap (string pool)<br>int[] arr = {1,2,3};     // &#39;arr&#39; in stack, array in heap</pre><p>💡 null means the reference isn’t pointing anywhere:</p><pre>String text = null; // No object assigned</pre><h3>🧭2. Based on Scope &amp; Declaration: Local, Instance, Static Variables</h3><h3>🧵 Local Variables</h3><ul><li>Declared inside a method, block, or constructor.</li><li>Lives in 🧱 <strong>Stack Memory</strong>.</li><li>No default values — must be initialized manually.</li></ul><pre>void display() {<br>    int age = 25; // Local → stack memory<br>}</pre><h3>🧩Instance Variables</h3><ul><li>Declared in a class <strong>outside any method</strong>, without static.</li><li>One copy per object → stored in 🧠 <strong>Heap</strong></li><li>JVM provides default values.</li></ul><pre>class Student {<br>    int id;        // instance → heap<br>    String name;   // instance → heap<br><br>void show() {<br>        System.out.println(id); // Accessible directly<br>    }<br>}</pre><p>📌 Access from static methods using an object:</p><pre>Student s = new Student();<br>System.out.println(s.id); // ✅</pre><h3>⚙️Static Variables</h3><ul><li>Marked with static, shared by <strong>all objects</strong>.</li><li>Stored in 🔧 <strong>Method Area</strong> (MetaSpace in Java 8+)</li><li>One copy per class</li></ul><pre>class Test {<br>    static int count = 0;  // Class-level<br><br>public static void main(String[] args) {<br>        System.out.println(Test.count); // Recommended way<br>    }<br>}</pre><p>✅ Can be accessed from both static and instance areas.</p><h3>🧠3. Memory Architecture: Where Things Actually Live</h3><h3>🔸Stack Memory</h3><ul><li>Stores local variables, method frames.</li><li>Fast access, but short-lived.</li><li>Each thread has its own stack.</li></ul><blockquote>If a variable goes out of scope → it vanishes.</blockquote><h3>🔹Heap Memory</h3><ul><li>Stores objects &amp; arrays created via new.</li><li>Shared among all threads.</li><li>Cleaned by the Garbage Collector.</li></ul><pre>Student s = new Student(); // &#39;s&#39; in stack, object in heap</pre><p>Heap also includes:</p><ul><li><strong>String Pool</strong></li><li><strong>Young/Old Generations</strong> (in JVM optimization)</li></ul><h3>🔧 Method Area (MetaSpace)</h3><p>It created at JVM startup and stores:</p><ul><li>Class structure</li><li>Static variables</li><li>Method bytecode</li></ul><pre>static int version = 1;  // lives in Method Area</pre><h3>💬 Final Thought</h3><p>🧩 It’s not just the <strong>data type</strong> that defines where a variable lives — it’s also <strong>how and where it’s declared.</strong></p><blockquote><em>🔥 If you thought Java was “fully object-oriented,” below article should change your perspective.</em></blockquote><blockquote><a href="https://medium.com/@pawankr.tiwari/is-java-really-object-oriented-heres-the-truth-nobody-talks-about-eee0b81565ea">https://medium.com/@pawankr.tiwari/is-java-really-object-oriented-heres-the-truth-nobody-talks-about-eee0b81565ea</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d66956ba729f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Is Java Really Object-Oriented? Here’s the Truth Nobody Talks About]]></title>
            <link>https://medium.com/@pawankr.tiwari/is-java-really-object-oriented-heres-the-truth-nobody-talks-about-eee0b81565ea?source=rss-fb6f4c52cf11------2</link>
            <guid isPermaLink="false">https://medium.com/p/eee0b81565ea</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[object-oriented]]></category>
            <category><![CDATA[javaprogrammingtips]]></category>
            <category><![CDATA[oops-in-java]]></category>
            <dc:creator><![CDATA[Pawan Kr. Tiwari]]></dc:creator>
            <pubDate>Sat, 31 May 2025 17:42:39 GMT</pubDate>
            <atom:updated>2025-08-13T12:47:02.666Z</atom:updated>
            <content:encoded><![CDATA[<h4>Java is object-oriented — but not entirely. Let’s uncover what breaks the rule.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T6ckvpDlmIIjMycdeg20Iw.png" /></figure><p>Java is often praised as an object-oriented programming (OOP) language, but did you know it’s not truly object-oriented? While Java embraces OOP principles, it makes certain compromises for efficiency and flexibility.</p><p>In this article, we’ll explore the five key reasons why Java breaks pure object-oriented programming — and why that’s actually a good thing.</p><blockquote><strong>1. </strong><a href="https://medium.com/@pawankr.tiwari/primitive-vs-non-primitive-data-types-in-java-what-every-java-beginner-should-know-d6abf4246401"><strong>Primitive Data Types</strong></a><strong> Exist (They’re Not Objects!)</strong></blockquote><p>A pure object-oriented language would treat everything as an object. Java, however, includes <strong>primitive types</strong> like `<strong>int</strong>`, `<strong>char</strong>`, and `<strong>boolean</strong>`, which are not objects. <strong>Example</strong>:</p><pre>int num = 10; // Primitive type (not an object)<br>Integer objNum = Integer.valueOf(num); // Wrapper class converts it to an object</pre><p>🔥<strong> Why This Matters:</strong><br>✔ Primitives make Java faster and more memory-efficient, reducing unnecessary overhead. <br>✘ However, this breaks the strictest OOP principle where everything should be an object.</p><blockquote><strong>2. Static Methods Break Encapsulation</strong></blockquote><p>Encapsulation in OOP suggests that methods should belong to objects, not just classes. But in Java, <strong>static</strong> <strong>methods</strong> can be called <strong>without</strong> <strong>creating</strong> an <strong>object</strong>! <strong>Example</strong>:</p><pre>class MathUtils {<br> static int add(int a, int b) {<br> return a + b;<br> }<br>}<br>System.out.println(MathUtils.add(5, 10)); // Called without an object!</pre><p>🔥 Why This Matters: <br>✔ Static methods make utility functions easy to use. <br>✘ However, they go against true OOP by bypassing the need for objects.</p><blockquote><strong>3. No Multiple Inheritance (Interfaces Instead!)</strong></blockquote><p>Java avoids multiple inheritance to prevent ambiguity, instead using interfaces to mimic this behavior. <strong>Example</strong>:</p><pre>interface A {<br> void show();<br>}<br>interface B {<br> void display();<br>}<br>class C implements A, B {<br> public void show() { System.out.println(&quot;Show from A&quot;); }<br> public void display() { System.out.println(&quot;Display from B&quot;); }<br>}</pre><p>🔥Why This Matters: <br>✔ This prevents conflicts caused by multiple inheritance. <br>✘ However, it doesn’t follow traditional OOP, where multiple inheritance is allowed.</p><blockquote><strong>4. The `main()` Method Starts Without an Object</strong></blockquote><p>Java programs start execution with the `main()` method, which is <strong>static</strong>— meaning it runs without needing an object. Example:</p><pre>public class Main {<br> public static void main(String[] args) {<br> System.out.println(&quot;Hello, world!&quot;);<br> }<br>}</pre><p>🔥Why This Matters:<br>✔ This simplifies program execution. <br>✘ But a true OOP language would require an object to start execution.</p><blockquote><strong>5. Primitive Types Are Passed by Value (Not Reference)</strong></blockquote><p>In Java, objects are passed by reference, but primitive types are passed by value. <strong>Example</strong>:</p><pre>void modify(int x) { <br> x = 100; <br>}<br>int num = 10;<br>modify(num);<br>System.out.println(num); // Still prints 10 (not modified)</pre><p>🔥 Why This Matters:<br>✔ Passing by value prevents unintended changes to variables. <br>✘ However, a pure OOP approach would pass everything by reference.</p><h3><strong><em>Final Thoughts — Is This a Problem?</em></strong></h3><p>Java’s deviations from pure OOP aren’t necessarily flaws— they are design choices made for performance, flexibility, and simplicity. While languages like Smalltalk and Ruby are more object-oriented, Java balances OOP with practicality, making it a dominant force in the programming world.</p><p>So, should Java be considered “not truly object-oriented”? Maybe. But should you care? Not really — because these compromises make Java faster, scalable, and more developer-friendly. 🚀</p><p>What do you think? Does this make Java better or worse for your needs? Let me know in the comments! 👇</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eee0b81565ea" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Every Java Developer Should Know About JVM, JRE & JDK]]></title>
            <link>https://medium.com/@pawankr.tiwari/what-every-java-developer-should-know-about-jvm-jre-jdk-2df465d49774?source=rss-fb6f4c52cf11------2</link>
            <guid isPermaLink="false">https://medium.com/p/2df465d49774</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[jre]]></category>
            <category><![CDATA[jdk]]></category>
            <category><![CDATA[jvm]]></category>
            <category><![CDATA[java-architecture]]></category>
            <dc:creator><![CDATA[Pawan Kr. Tiwari]]></dc:creator>
            <pubDate>Sun, 27 Apr 2025 09:19:26 GMT</pubDate>
            <atom:updated>2025-04-27T10:12:03.269Z</atom:updated>
            <content:encoded><![CDATA[<h4>Before You Write Another Line of Java, Understand This First, Ever Wondered What Happens After You Hit ‘Run’ in Java?</h4><p>In this post, we’re going to break down the <strong>Java Architecture</strong> — diving deep into the roles of <strong>JDK, JRE, and JVM</strong>, the <strong>memory areas</strong>, the <strong>class loader</strong>, and the <strong>execution engine</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ql3FTcq1OM6g-TKNrJyUvw.png" /></figure><p><strong>From Code to Execution: The Invisible Journey of Java</strong><br>From writing a .java file to seeing output on your screen — is powered by an entire ecosystem working in perfect sync.</p><blockquote><strong><em>Source Code (.</em></strong><strong><em>java) → Byte Code (</em></strong><strong><em>.class) → Machine Code</em></strong></blockquote><p>Java is compiled into bytecode By <strong><em>Java Compiler</em></strong> and then interpreted or just-in-time compiled into machine code by <strong>JVM</strong>.<br>Now JVM interprets or just-in-time compiles the bytecode into native code appropriate for the host machine. Well How, Let’s see :</p><ul><li><strong>JVM</strong> :<br><strong>Class loader</strong>: Responsible for loading bytecode into main memory.<br><strong>Memory Area</strong>: Allocated memory for running the program (Method area, Heap, Stack).<br><strong>Execution Engine</strong> → Interpreter + JustInTime Compiler + Garbage Collector.</li><li><strong>JRE: JVM + Runtime Libraries.<br>RunTime Libraries:(</strong>e.g. java.lang, java.util, java.io, java.sql, collection, math etc<strong>).</strong></li><li><strong>JDK: JRE+ Development tools.<br>Development tools:</strong>(javac – Java compiler, <br>javadoc – Documentation generator, <br>jdb – Debugger, <br>javap – Bytecode disassembler,<br>jshell – Java REPL / interactive shell)</li></ul><blockquote>Let’s take a quick deep dive All of these Important Terms:</blockquote><ul><li><strong>JVM: </strong>It is <strong>a software</strong> provided by Java to run Java programs or applications.<br>It is <strong>the core component</strong> that runs Java bytecode.<br>Developed using C and C++ languages, so JVM is <strong>a platform-dependent software.</strong></li><li><strong>Interpreter</strong>: One of translator type which converts byte code to native code or machine code.<br>Good for small or short-running programs.</li><li><strong>JustInTime Compiler</strong>: It optimizes the performance of JVM (when it finds the repeated code so it took the code and covert to machine code and give it to interpreter).<br>Great for long-running, compute-heavy apps.</li></ul><blockquote>JVM does not know how to compile .java files or generate docs or debug code — that’s not its job.</blockquote><blockquote>JVM is a runtime, not a development environment.</blockquote><ul><li><strong>Garbage Collector: </strong>Deallocating the unused memory.</li></ul><p>Mastering these foundations means you’re not just writing code; you’re <strong>engineering solutions</strong> with clarity and control.<br>Keep exploring, keep coding, and keep getting closer to Java mastery!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2df465d49774" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java is Platform independent, Really?]]></title>
            <link>https://medium.com/@pawankr.tiwari/java-is-platform-independent-really-ec8882dbe5ee?source=rss-fb6f4c52cf11------2</link>
            <guid isPermaLink="false">https://medium.com/p/ec8882dbe5ee</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[javafeatures]]></category>
            <category><![CDATA[platform-independence]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[java-programming]]></category>
            <dc:creator><![CDATA[Pawan Kr. Tiwari]]></dc:creator>
            <pubDate>Wed, 23 Apr 2025 09:46:01 GMT</pubDate>
            <atom:updated>2025-04-23T11:27:22.469Z</atom:updated>
            <content:encoded><![CDATA[<h4>“Think Java is 100% platform independent? Let’s rethink that as your quick revision.”</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pcgeSB0GEiJL7PONlBENxA.png" /></figure><p>Yeah, I know what you’re thinking — <em>we all know Java is platform independent.</em> Now, is this just clickbait for views, or do you actually have a take?</p><p>But what if I told you —</p><blockquote>Java’s bytecode is platform independent, but it’s <em>JVM dependent.</em></blockquote><p>Let me explain it in 2 minutes and clear up all those questions in your mind. First, let’s understand how Java converts its source code into machine code.</p><blockquote>Java is <strong>compiled</strong> into bytecode and then <strong>interpreted</strong> or <strong>just-in-time compiled</strong> into machine code.</blockquote><p><strong>Source CODE ( </strong><strong>java) → Byte Code (</strong><strong>.class) → Machine Code</strong></p><p>The JVM interprets or just-in-time compiles the bytecode into native code appropriate for the host machine. This bytecode is not specific to Windows — it’s designed to be run by any Java Virtual Machine (JVM).</p><p>Second how do other programming languages work? Is Java the only one that’s platform independent?</p><h4>Python( Interpreted Languages )</h4><blockquote><strong><em>Source Code (</em></strong><strong><em>.py)</em></strong><em> → </em><strong><em>Python Interpreter (</em></strong><strong><em>python)</em></strong><em> → </em><strong><em>Machine Code (JIT or Interpretation)</em></strong></blockquote><h4>C and C++( Compiled Languages )</h4><blockquote><strong><em>.c/.cpp</em></strong><em> → </em><strong><em>Preprocessor</em></strong><em> →</em><strong><em> Compiler → Assembler → Linker → Executable.</em></strong></blockquote><h3>Understanding the Difference</h3><p>Different languages handle code execution differently:</p><ul><li><strong>C/C++</strong> are compiled directly into machine code, making them fast but OS-dependent.</li><li><strong>Python</strong> uses an interpreter to convert bytecode into machine code at runtime — easy to run on any system with Python installed.</li><li><strong>Java</strong> compiles code into bytecode, which runs on the JVM. This makes it platform- independent <em>as long as</em> a JVM exists.</li></ul><figure><img alt="C Vs Python Vs Java" src="https://cdn-images-1.medium.com/max/1024/1*PKOkJypTI4uaPe0-zh6vDg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ec8882dbe5ee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Procedural, OOP, Functional? Which One Should You Learn?]]></title>
            <link>https://medium.com/@pawankr.tiwari/procedural-oop-functional-which-one-should-you-learn-21c47d95151a?source=rss-fb6f4c52cf11------2</link>
            <guid isPermaLink="false">https://medium.com/p/21c47d95151a</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[oops-in-java]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[object-oriented]]></category>
            <dc:creator><![CDATA[Pawan Kr. Tiwari]]></dc:creator>
            <pubDate>Thu, 17 Apr 2025 17:16:50 GMT</pubDate>
            <atom:updated>2025-04-17T17:19:13.440Z</atom:updated>
            <content:encoded><![CDATA[<p>One Size Doesn’t Fit All! Which Coding Style Matches Your Goals..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DaNlwExQZJheRht3D-AeHg.png" /></figure><p>Did you know? The way we categorize programming languages can completely change how we think about coding! 🤯<br> <br>From how close they are to human logic (Abstraction Level) to how they get executed (Translation Method) — understanding these differences can make you a better programmer.</p><p>Programming languages let us communicate with computers. They translate human-readable instructions into machine code (binary).</p><p>Curious to know how programming languages are classified?<br> ✅ By <strong>Translation Method</strong> (compiled vs. interpreted)<br> ✅ By <strong>Abstraction Level</strong> (high-level vs. low-level)<br> ✅ By <strong>Paradigm</strong> (style of programming)</p><h4>Classification by Translation Method</h4><p>🖥️ <strong>Compiled Languages</strong> (Faster execution)</p><ul><li>Examples: C, C++, Rust</li><li>Use Case: Game Dev, System Programming.</li></ul><p>⚡ <strong>Interpreted Languages</strong> (Easier to debug)</p><ul><li>Examples: Python, JavaScript</li><li>Use Case: Scripting, Web Apps.</li></ul><h4>Classification by Abstraction Level</h4><p>📌 <strong>High-Level Languages</strong> (Easier to read &amp; write)</p><ul><li>Examples: Python, JavaScript, C++</li><li>Use Case: Web Development, AI.</li></ul><p>📌 <strong>Low-Level Languages</strong> (Closer to hardware)</p><ul><li>Examples: Assembly, Machine Code</li><li>Use Case: Embedded Systems, OS Development.</li></ul><h4>Classification by Paradigm (One per slide)</h4><p>💡 <strong>Procedural Programming</strong></p><ul><li>Based on a step-by-step approach, where code is executed sequentially.<br> ✅ <strong>Key Features</strong>: Functions, loops, conditionals, and modularization.<br> ✅ <strong>Use Cases</strong>: System software, embedded systems, game development.<br> ✅ <strong>Examples</strong>: C, Pascal, Fortran.</li></ul><p>💡 <strong>Object-Oriented Programming (OOP)</strong></p><ul><li>Organizes code into reusable objects with attributes (data) and methods (functions).<br> ✅ <strong>Key Features</strong>: Encapsulation, Inheritance, Polymorphism, Abstraction.<br> ✅ <strong>Use Cases</strong>: Software development, game engines, mobile applications.<br> ✅ <strong>Examples</strong>: Java, Python, C++, C#.</li></ul><p>💡 <strong>Functional Programming</strong></p><ul><li>Focuses on mathematical functions and avoids changing state (immutable data).<br> ✅ <strong>Key Features</strong>: First-class functions, pure functions, recursion, higher-order functions.<br> ✅ <strong>Use Cases</strong>: Data science, AI/ML, concurrent programming, financial applications.<br> ✅ <strong>Examples</strong>: Haskell, Lisp, Scala, JavaScript (Functional aspects).</li></ul><p><strong>💡 Scripting Languages</strong></p><ul><li>High-level languages used to automate tasks and enhance functionality.<br> ✅ <strong>Key Features</strong>: Interpreted, dynamic typing, ease of use, quick prototyping.<br> ✅ <strong>Use Cases</strong>: Web development, automation, data processing.<br> ✅ <strong>Examples</strong>: JavaScript, Python, PHP, Bash, Ruby.</li></ul><h3>Choosing the Right Language for You!</h3><p>🚀 <strong>Beginner?</strong> Start with Python or JavaScript.<br> 💡 <strong>System Programming?</strong> Go for C or Java.<br> 🕸 <strong>Web Development?</strong> JavaScript + frameworks (React, Angular).<br> 📱 <strong>App Development?</strong> Java/Kotlin (Android), Swift (iOS).<br> 🎮 <strong>Game Dev?</strong> C++ (Unreal Engine), C# (Unity).<br> 🤖 <strong>AI &amp; Data Science?</strong> Python (TensorFlow, Pandas).</p><p>📌 <strong>Key takeaway:</strong> Pick a language based on <strong>your goals, project needs, and learning curve.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=21c47d95151a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Programming Languages in DevOps: A Must or Just a Bonus?]]></title>
            <link>https://medium.com/@pawankr.tiwari/programming-languages-in-devops-a-must-or-just-a-bonus-c34d94b31600?source=rss-fb6f4c52cf11------2</link>
            <guid isPermaLink="false">https://medium.com/p/c34d94b31600</guid>
            <dc:creator><![CDATA[Pawan Kr. Tiwari]]></dc:creator>
            <pubDate>Sun, 13 Oct 2024 16:35:15 GMT</pubDate>
            <atom:updated>2024-10-13T16:35:15.788Z</atom:updated>
            <content:encoded><![CDATA[<p>Can you do DevOps without learning to code? Maybe. Can you thrive in it? Probably not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*z07H21X5S7YKB-rreLsYvA.png" /></figure><p>DevOps is about <strong>automation</strong> and <strong>efficiency</strong>, and in this space, tools and automation are the real MVPs. But where do programming languages fit in?</p><p>As a fresher in the DevOps world, coding might seem intimidating. But here’s the truth: you don’t need to be a full-time developer to thrive. Programming languages like <strong>Python</strong>, <strong>Go</strong>, and <strong>Ruby</strong> are the magic behind automation. Imagine setting up a CI/CD pipeline — having scripting skills makes configuring, deploying, and scaling a breeze.</p><p>For lifelong learners and Freshers, my advice is simple… As someone who’s been in the field, I want to get comfortable with at least one language, preferably Python. It’ll give you a huge edge in solving real-world problems more effectively.</p><p>If you’re starting your DevOps journey, invest time in learning the basics of a programming language. Your future self will thank you!</p><p>Programming in DevOps = Powering Automation ⚡</p><p>“What do you think? Are programming languages non-negotiable in DevOps, or can we automate our way around them? Let’s discuss!”</p><p>#DevOps #Scripting #ProgrammingInDevOps #Efficiency #AutomationTools #CI_CD #PythonForDevOps #DevOpsCommunit0y #LearnToCode # DevOps Journey</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c34d94b31600" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>