<?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 SaiRoopa Galiveeti on Medium]]></title>
        <description><![CDATA[Stories by SaiRoopa Galiveeti on Medium]]></description>
        <link>https://medium.com/@sairoopagaliveeti09?source=rss-bfc49f969ca3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*QlUuDfCsh6dpjQqEbPFADA.jpeg</url>
            <title>Stories by SaiRoopa Galiveeti on Medium</title>
            <link>https://medium.com/@sairoopagaliveeti09?source=rss-bfc49f969ca3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 23:16:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sairoopagaliveeti09/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[Top event loop interview questions(beginner to advance)]]></title>
            <link>https://medium.com/@sairoopagaliveeti09/top-event-loop-interview-questions-beginner-to-advance-6a9104827cf8?source=rss-bfc49f969ca3------2</link>
            <guid isPermaLink="false">https://medium.com/p/6a9104827cf8</guid>
            <category><![CDATA[event-loop-in-js]]></category>
            <category><![CDATA[javascript-event-loop]]></category>
            <category><![CDATA[event-loop-in-javascript]]></category>
            <category><![CDATA[execution-context]]></category>
            <dc:creator><![CDATA[SaiRoopa Galiveeti]]></dc:creator>
            <pubDate>Mon, 15 Dec 2025 07:10:14 GMT</pubDate>
            <atom:updated>2025-12-15T07:10:14.238Z</atom:updated>
            <content:encoded><![CDATA[<p>Let’s deep dive into event loop in JS</p><p>Before going into deep dives of event loop, let’s have a discussion about What is an event loop?</p><p>Ever wonder how JS is able to run asynchronous code though it is single-threaded (only one task is in progress in call stack during JS execution) and synchronous by default.</p><p>If any part of code runs for longer time, it blocks the execution of subsequent code until it completes.</p><p>To avoid this JS run time environment provides Web APIs (browsers) and Node APIs which can handle asynchronous operations in background while main JS thread continues to execute the synchronous operation.</p><p>When Web API’s or Node API’s complete the async task, associated callback function is placed in the Callback Queue (Task Queue — FIFO)</p><p>Here comes the event loop, it continuously monitors the call stack and callback queue. It checks if call stack is empty, if it is empty the event loop takes the first callback function and places it in call stack for execution. It is repeated until Task Queue is empty.</p><p>Now let’s answer some of the interview questions on Event loop:</p><p><strong>Why Does the Event Loop Exist?<br></strong>Event loop helps JS to run asynchronous code despite being single threaded. It continuously checks the call stack and when it becomes empty it sends pending tasks from microtask (promises)queues and macrotask queues (timers, I/O..)to stack for execution.<br>This mechanism ensures non-blocking behavior and enables JS to run long run process without blocking main thread.</p><p><strong>What If JavaScript Handled Everything Synchronously Only?<br></strong>If JS handles everything synchronously, any long running process (network requests, timers,.. ) would blocks the main thread until it completes. <br>As a result it freezes the UI, slows down the performance and causes poor UI experience.</p><p><strong>What Is JavaScript Execution Model ?<br></strong>The core components of JS execution:</p><p>JS uses a combination of process to execute code.</p><p><strong>Call Stack: <br></strong>Call stack helps JS engine to keep track of functions execution. <br>As JS is single-threaded, it executes one operation at a time.</p><p><strong>How it works?<br> </strong><br>When function is invoked, the JS engine pushes the function into call stack, it remains in stack until it completes it’s execution. If any nested function exists, it pushes that function into stack and executes the newly pushed function while the previous one waits for completion.</p><p>It ensures functions to execute in order and return properly after completion of execution.</p><pre>console.log(&quot;A&quot;) <br>function A(){<br>  console.log(&quot;B&quot;);<br>}<br><br>async function B(){<br>   console.log(&quot;C&quot;);<br>   await console.log(&quot;D&quot;);<br>   console.log(&quot;E&quot;);<br>   A();<br>}<br>B();<br>console.log(&quot;F&quot;)<br><br>// A – synchronous, runs immediately<br>// C, D – inside B(), both run synchronously<br>// await pauses B() after D<br>// (E + A()) are moved to the microtask queue<br>// F – synchronous, runs next<br>// Microtask queue runs: prints E, then B<br>// End</pre><p><strong>Web APIs:<br></strong>These are not part of JS, it is provided by Brower (DOM, timer, fetch..), Node.js they handle async task outside the call stack.</p><p><strong>Task Queues:<br></strong>Once Web APIs finish their task, there callbacks are sent to task queue.<br>There are two important queues:</p><ul><li>Microtask Queue: <br>Contains promises.then/catch/finally, MutationObserver</li><li>Macrotask Queue: <br>Contains timers, DOM events</li></ul><p><strong>Event Loop: <br></strong>It<strong> </strong>continuously checks if call stack is empty, if it is runs all the microtasks and the runs macrotasks again repeat.</p><p>This execution modal ensures non-blocking behavior and enables JS to run long process without blocking the main thread.</p><p><strong>What Is Call Stack (Most Important Base Layer) and Why Does It Run Only on LIFO?<br></strong>Call stack is a place where JS engine executes synchronous code line by line, in order, using push and pop operations to manage function calls.</p><p>Now why LIFO? Because when a function calls another function, most recently called function must complete execution before the previous one can continue.<br>This creates a LIFO nature automatically.</p><p><strong>Why Do We Need Web APIs and how do they interact with JS code?<br></strong>Web APIs are not part of the JavaScript, they are provided by the JS runtime environment like (Browser, Node.js). <br>These helps JS to achieve non blocking behavior by taking care of long running or async tasks without blocking the main thread.</p><p>Without Web APIs, JS would have to wait for each task to complete inside the call stack - results UI freezes, slow performance, bad user experience and no parallel work possible.</p><p><strong>Why Is setTimeout(0) Not Immediate?</strong><br>SetTimeout is never immediate.<br>When we call setTimeout, the callback is handed to web APIs, upon execution it is pushed in macrotask queue(after 0 ms) not microtask queue.</p><p>The event loop executes this only when,<br>- Call stack is empty <br>- When microtask queue is empty</p><p>Therefore, macrotask (setTimeout) never executes immediately.</p><p><strong>Why Does Microtask Run Before Macrotask?<br></strong>JS is designed to complete execution of small immediate tasks (microtasks) before the bigger async tasks(macrotasks) runs.</p><p>This ensures <br>- Predictable async behavior<br>- No UI flickering<br>- Promise chains runs reliably</p><pre>// Lets see an example<br>doSomeTask()<br>  .then(task1)<br>  .then(task2)<br>  .then(task3)<br>  .catch()<br><br>// A promise needs a fast and predictive execution sequence<br>If promises were delayed behind timers, network requests, rendering etc..<br>The order would get mixed - breaking the meaning of promises.<br><br>So JS ensures, microtask should immediatly finish task right after <br>current script</pre><p><strong>What Is Starvation and Microtask Starvation?<br></strong>Starvation is when a task is remained blocked from executing, while event loop is engaged with other tasks (like long running synchronous code, a flood of high priority task) for so long.</p><p>Microtask Starvation: It is a process of holding low priority task (macrotask queue) from execution due to flood of microtask.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a9104827cf8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript Basics- Type Coercion + bind, apply, call explained simply]]></title>
            <link>https://medium.com/@sairoopagaliveeti09/javascript-basics-type-coercion-bind-apply-call-explained-simply-f6ab3ed99b4a?source=rss-bfc49f969ca3------2</link>
            <guid isPermaLink="false">https://medium.com/p/f6ab3ed99b4a</guid>
            <category><![CDATA[js]]></category>
            <category><![CDATA[bind]]></category>
            <category><![CDATA[apply]]></category>
            <category><![CDATA[coercion]]></category>
            <dc:creator><![CDATA[SaiRoopa Galiveeti]]></dc:creator>
            <pubDate>Wed, 10 Dec 2025 10:24:59 GMT</pubDate>
            <atom:updated>2025-12-10T10:24:59.401Z</atom:updated>
            <content:encoded><![CDATA[<p>JS often sees confusing when mixing strings, numbers, functions — especially when this behaves unexpectedly. In this article we will break down two important JS concepts every JS developer need to know.<br>- Type coercion<br>- this, Call, Bind, Apply</p><h3><strong>Type Coercion:</strong></h3><p>JS is weakly-typed language (allows implicit type conversion with type mismatch)</p><p><strong>Coercion types:<br><em> </em>Implicit coercion:</strong><em> </em>JS converts types automatically behind the scenes</p><pre>console.log(1+2+&quot;3&quot;) // &quot;33&quot; (number-&gt; string) (string concatenation)<br>console.log(&quot;5&quot;-4) // 1 (string-&gt; number) (Arithmetic operations)<br>console.log(&quot;3&quot; == 3) //true (comparison with loose equality -&gt; string converts to number)<br>console.log(&quot;3&quot; === 3) // false (no coercion with strict equality, strict check)<br>console.log(null == undefined) // true <br>console.log(null === undefined) // false</pre><p>== operator always coercion where as === doesn’t.</p><p><strong>Explicit coercion (manual)</strong>: Convert values intentionally using built-in methods</p><pre>Number(&quot;42&quot;) // 42 (str -&gt; num)<br>+ &quot;42&quot; // 42 (unary +)<br>Boolean(0) // false<br>Boolean(&quot;Hi&quot;)    // true (non-empty string is truthy)</pre><p><strong>Difference between bind, apply and call in JavaScript:<br></strong><em><br></em><strong><em>This: </em></strong><em>refers</em><strong><em> </em></strong><em>to the object that invokes a function.</em></p><p>In global scope -&gt; In browser this refers to <strong><em>window</em></strong> object<br>In object method -&gt; refers to that object<br>In Event/Callback -&gt; depends on how it’s called.</p><p><em>Why do we need bind, apply, call?</em><br>Call, bind, apply lets us manually control what <strong><em>this </em></strong>refers to.</p><pre>const obj = {name : &quot;John&quot;}<br>function greet(){<br>   console.log(&quot;Hello&quot; + &quot; &quot; + this.name) <br>}<br><br>greet() // undefined<br>greet.call(obj) // Hello John -&gt; this refers to obj</pre><pre>// in async callbacks &quot;this&quot; changes unexpectedly -&gt; use bind() <br>const user = {<br>  name : &quot;John&quot;,<br>  display(){<br>   setTimeout(function(){<br>    console.log(&quot;Hello&quot; + &quot; &quot; + this.name)<br>   }.bind(user), 1000)<br>  }<br>}<br><br>user.display() // &quot;Hello John&quot;<br></pre><p>Now let’s get into bind, apply, call</p><p><strong>Bind:</strong> It is used to permanently fix <strong>this</strong> for a function and return a new function to be called later.</p><p>Used with callbacks, promises, async functions, event handlers</p><pre>const newFunc = func.bind(thisArgs, arg1, arg2)<br>//thisArgs -&gt; object to bind to the func,arg1,arg2-&gt; optional preset args</pre><p>bind() doesn’t run the function immediately, — it returns a new function.</p><p><strong>Call: </strong>It is used to invoke a function immediately while explicitly setting what “this” should it refer to and pass arguments individually(comma-separated)</p><pre>// Call syntax : func.call(thisArgs, arg1, arg2)<br><br>const obj1 = {<br>  name : &quot;John&quot;,<br>}<br><br>const obj2 = {<br>  name : &quot;Alex&quot;<br>}<br><br>function greet(city, country){<br>  console.log(`I am ${this.name} and I am from ${city}, ${country}`)<br>}<br><br>greet.call(obj1, &quot;Hyd&quot;, &quot;India&quot;);  // John<br>greet.call(obj2, &quot;Blr&quot;, &quot;India&quot; );  // Alex</pre><p>Used when same function is used across many objects, passing function parameters.</p><p><strong>Apply:</strong> apply is similar to call, but it send args as array.</p><pre>// syntax<br>func.apply(thisArgs, [arg1, arg2])</pre><p>Useful when number of args are dynamic.</p><p><strong>Where is it used in real world applications?</strong><br>- Multiple objects with single function<br>- Across async functions to bind the object<br>- Borrowing methods</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f6ab3ed99b4a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sealed Class in Java]]></title>
            <link>https://medium.com/@sairoopagaliveeti09/sealed-class-in-java-faa53081c2b8?source=rss-bfc49f969ca3------2</link>
            <guid isPermaLink="false">https://medium.com/p/faa53081c2b8</guid>
            <category><![CDATA[sealed-classes]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[SaiRoopa Galiveeti]]></dc:creator>
            <pubDate>Mon, 22 Sep 2025 02:11:18 GMT</pubDate>
            <atom:updated>2025-09-22T02:11:18.725Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Sealed class</strong> were implemented in Java 17, They allow only specific, permitted subclasses and interfaces to extend or implement it.</p><p>It helps with more controlled and explicit way to manage the inheritance hierarchy.</p><p><em>Key characteristics:</em></p><ol><li><strong>Sealed</strong> keyword: Declares a class or interface as sealed.</li><li><strong>Permits</strong> keyword: Explicitly permits subclasses and interfaces to extend or implement sealed class.</li><li>Subclasses of a sealed classes must be declared using one of these:<br> <strong>Final</strong>: No class is allowed to extend it. <br> <strong>Sealed</strong>: The subclass is sealed and can be extended by it’s own permitted subclasses.<br> <strong>Non -sealed</strong>: subclass is open and can be extended by any other classes.</li></ol><pre><br>// Only Bus, Car, and Truck are allowed to inherit from Vehicle.<br>public sealed class Vehicle permits Bus, Car, Truck {<br>    // attributes and method declarations<br>}<br><br>// Final class: no other class can extend Bus.<br>public final class Bus extends Vehicle {<br>    // Bus-specific implementation<br>}<br><br>// Sealed subclass: Car can only be extended by the explicitly permitted classes Volvo and Audi.<br>public sealed class Car extends Vehicle permits Volvo, Audi {<br>    // Car-specific implementation<br>}<br><br>// Non-sealed subclass: unlike Bus and Car, Truck can be extended by any other class.<br>public non-sealed class Truck extends Vehicle {<br>    // Truck-specific implementation<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=faa53081c2b8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>