<?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 Vinodharanie Sivalingam on Medium]]></title>
        <description><![CDATA[Stories by Vinodharanie Sivalingam on Medium]]></description>
        <link>https://medium.com/@dharanie89?source=rss-ae409437c2f7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Vinodharanie Sivalingam on Medium</title>
            <link>https://medium.com/@dharanie89?source=rss-ae409437c2f7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 18:05:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dharanie89/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[Python Dictionary Operations]]></title>
            <link>https://medium.com/@dharanie89/python-dictionary-operations-5e198c6a84e2?source=rss-ae409437c2f7------2</link>
            <guid isPermaLink="false">https://medium.com/p/5e198c6a84e2</guid>
            <dc:creator><![CDATA[Vinodharanie Sivalingam]]></dc:creator>
            <pubDate>Wed, 22 Jan 2025 07:50:51 GMT</pubDate>
            <atom:updated>2025-01-22T09:01:53.043Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Create a Dictionary</strong></p><pre>dictionary = {<br>&quot;name&quot;:&quot;Vino&quot;,<br>&quot;age&quot;:&quot;40&quot;,<br>&quot;address&quot;:&quot;colombo&quot;<br>}</pre><h4>Access Values</h4><pre>dictionary[&quot;name&quot;]<br><br>#Use get() to Avoid Key Errors<br><br>dictionary.get(&quot;age&quot;, &quot;Key not found&quot;)</pre><h4>Add or Update a Key-Value Pair</h4><pre>dictionary[&quot;name&quot;] = &quot;Laj&quot;<br>dictionary[&quot;country&quot;] = &quot;Sri Lanka&quot;</pre><h4>Delete a Key-Value Pair</h4><pre>del dictionary[&quot;name&quot;]</pre><h4>Check If a Key Exists</h4><pre>if &quot;country&quot; in dictionary:<br>   print(&quot;country is available&quot;)</pre><h4>Iterate Through a Dictionary</h4><pre>for key in dictionary:<br>    print(key)<br><br>for value in dictionary.values():<br>    print(value)<br><br>for key,value in dictionary.items():<br>    print(key, value)</pre><h4>Get Keys and Values</h4><pre>print(dictionary.keys())<br>print(dictionary.values())<br>print(dictionary.items())</pre><h4>Merge Two Dictionaries</h4><pre>dic1 = {&quot;name&quot; : &quot;vino&quot;, &quot;age&quot; : &quot;40&quot;}<br>dic2 = {&quot;country&quot; : &quot;sl&quot;, &quot;city&quot; : &quot;colombo&quot;}<br>merged_dic = dic1 | dic2</pre><h4>Clear All Items</h4><pre>merged_dic.clear()</pre><h4>Create a Dictionary to Store Names and Marks of Three Students</h4><pre>def createDic(name_list:list, age_list : list) -&gt; {}: <br>     dictionary = {}<br>     for (index, name) in enumerate(name_list):<br>         dictionary[name] = age_list[index]<br>     return dictionary</pre><h4>Count the Number of Occurrences of Each Character in a String</h4><pre>def countOccurrences(s:str) -&gt; dict:<br>    dictionary = {}<br>    for c in s :<br>        if c in dictionary :<br>            dictionary[c] += 1<br>        else :<br>            dictionary[c] = 1<br>    return dictionary</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5e198c6a84e2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python List Operations]]></title>
            <link>https://medium.com/@dharanie89/python-list-operations-7abb95e7706b?source=rss-ae409437c2f7------2</link>
            <guid isPermaLink="false">https://medium.com/p/7abb95e7706b</guid>
            <dc:creator><![CDATA[Vinodharanie Sivalingam]]></dc:creator>
            <pubDate>Sun, 19 Jan 2025 10:22:34 GMT</pubDate>
            <atom:updated>2025-01-21T15:33:47.887Z</atom:updated>
            <content:encoded><![CDATA[<p>Learn List operation with below examples.</p><p><strong>Create a List</strong><br>Write a program to create a list of 5 integers the user enters.</p><pre>def createList() -&gt; []:<br>   x = [] <br>   for i in range(5):<br>        x.append(int(input(&quot;Enter a number&quot;)))<br>   return x</pre><p><strong>Access Elements</strong><br>Write a program to access and print a list&#39;s first, middle, and last elements.</p><pre>def accessElement():<br>    x = [12,3,4,56,7,8,5]<br>    print(x[0])<br>    print(x[len(x)//2])<br>    print(x[len(x) - 1])</pre><p><strong>Find the Length</strong></p><pre>def findLength(lst : []) -&gt; int :<br>    return len(lst)</pre><p><strong>Sum of Elements</strong></p><pre>def sumOfElement(lst : []) -&gt; int :<br>    count = 0<br>    for l in lst :<br>        count += l<br>    return count</pre><p><strong>Find the Largest Number</strong></p><pre>def findLargeNumber(lst:[]) -&gt; int:<br>    largeNumber = lst[0]<br>    for l in lst :<br>        if largeNumber &lt; l :<br>             largeNumber = l<br>    return largeNumber</pre><p><strong>Reverse a List</strong></p><pre>def reverseList(lst:[]) -&gt; []:<br>    reverseList = lst[:] # Deep copy<br>    for (index, l) in enumerate(lst) :<br>        reverseList[-1 * (index+1)] = l<br>    return reverseList<br><br>#OR<br><br>def reverseList(lst:[]) -&gt; []:<br>    return lst[::-1]</pre><p><strong>Filter Even Numbers</strong></p><pre>def filterEvenNumbers(lst: []) -&gt; []:<br>    evenNumberList = []<br>    for i in lst :<br>        if i%2 == 0 :<br>            evenNumberList.append(i)<br>    return evenNumberList</pre><p><strong>Count Occurrences</strong></p><pre>def countOccurrences(lst:[], num:int) -&gt; int:<br>    return lst.count(num)</pre><p><strong>Remove Duplicates</strong></p><pre>def removeDup(lst : []) -&gt; []:<br>   return list(set(lst))<br><br>#OR<br><br>def removeDup(lst : []) -&gt; []:<br>   removeDup = []<br>   for l in lst:<br>       if l not in removeDup:<br>           removeDup.append(l)<br>   return removeDup<br><br>#OR<br><br>def removeDup(lst : []) -&gt; []:<br>   return list(dict.fromkeys(lst))</pre><p><strong>List Slicing</strong><br>Write a program to extract the first half of a list and print it.</p><pre>def listSlicing(lst: list) -&gt; list:<br>    return lst[:len(lst) // 2]  # Use floor division `//` </pre><p><strong>Concatenate Two Lists</strong></p><pre>def concatenateList(lst1:list, lst2:list) -&gt; list:<br>    lst1.extend(lst2)<br>    return lst1 <br><br>#OR<br><br>def concatenateList(lst1:list, lst2:list) -&gt; list:<br>    return lst1 + lst2</pre><p><strong>Sort a List</strong></p><pre>def sortList(lst : list) -&gt; list :<br>    lst.sort()<br>    return lst<br><br>#OR<br><br>def sortList(lst : list) -&gt; list :<br>    return sorted(lst)</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7abb95e7706b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kubernetes Cluster Architecture]]></title>
            <link>https://medium.com/@dharanie89/kubernetes-architecture-24a390bfc8bb?source=rss-ae409437c2f7------2</link>
            <guid isPermaLink="false">https://medium.com/p/24a390bfc8bb</guid>
            <dc:creator><![CDATA[Vinodharanie Sivalingam]]></dc:creator>
            <pubDate>Sat, 18 Jan 2025 16:47:36 GMT</pubDate>
            <atom:updated>2025-01-18T16:48:11.358Z</atom:updated>
            <content:encoded><![CDATA[<p>The Kubernetes (K8s) architecture is designed to efficiently manage containerized applications across a cluster of machines. It follows a <strong>master-worker architecture</strong>, where the <strong>control plane</strong> (master) manages the cluster, and worker nodes execute the workloads.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r_1ICTesKA5EZAwVU4-4iQ.png" /><figcaption>K8s cluster components</figcaption></figure><h3>Control Panel</h3><p>If K8s is an airport, then the control panel is like the air traffic control tower, with people overlooking the cluster and making sure nodes and pods are created, modified, and deleted without any issues. The control panel is made up of several components.</p><ul><li><strong>API Server (kube-apiserver): </strong>exposes the Kubernetes API. Pods, deployment, and the horizontal pod autoscaler have API endpoints. Handles authentication, validation, and communication between components via RESTful calls. kubectl and kubedm are CLI tools to communicate with Kubernetes API via HTTP requests.</li></ul><pre>kubectl api-resources<br>kubectl get pods -n kube-system //</pre><ul><li><strong>etcd: </strong>is an open source, highly available key value store. In K8s it saves all data about the state of the cluster. Only the Kube API serve can communicate directly with etcd. etcd also run as a pod.</li><li><strong>Scheduler (kube-scheduler): </strong>which identify newly created pods that have not been assigned to a worker node and then chooses a node to run.</li><li><strong>Controller Manager (kube-controller-manager): </strong>is a loop that runs continually and checks the cluster&#39;s status to ensure proper operation.</li><li><strong>Cloud Controller Manager: </strong>which lets you connect to the cluster with a cloud provider API’s so you can use cloud resource</li></ul><h3>Worker nodes</h3><p>If K8s is an airport, then the worker nodes are like the busy terminals, where planes park and passengers board.</p><ul><li><strong>Kubelet:</strong> is an agent that runs on each worker node, and makes sure that containers in the pods are running and healthy. Kubelet communicates directly with the api-server gets the pod definitions and it is looking for newly assigned pods.</li><li><strong>Container runtime:</strong> is responsible for running containers (e.g., Docker, containerd, CRI-O). Manages container lifecycle, including pulling images, creating containers, and handling their execution.</li><li><strong>Kube-Proxy:</strong> it makes sure that pods and services can communicate with the other nodes.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uyOkFSnvsQ1nQMp-Ai15wA.png" /><figcaption>K8s system flow sequence diagram</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=24a390bfc8bb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basic problems to learn Python]]></title>
            <link>https://medium.com/@dharanie89/basic-problems-to-learn-python-001edb99cc73?source=rss-ae409437c2f7------2</link>
            <guid isPermaLink="false">https://medium.com/p/001edb99cc73</guid>
            <dc:creator><![CDATA[Vinodharanie Sivalingam]]></dc:creator>
            <pubDate>Thu, 16 Jan 2025 11:17:46 GMT</pubDate>
            <atom:updated>2025-01-16T11:25:12.399Z</atom:updated>
            <content:encoded><![CDATA[<p>Since I have over 10 years of experience in Java and have recently started learning Python, I decided to write this blog. Here, you’ll find a few basic problems to solve using Python. If you’re in the same boat, let’s learn together!</p><h4><strong>Print Hey including your name</strong></h4><pre>name = input(&quot;What is your name?&quot;)<br><br>print(&quot;Hey&quot;, name) </pre><h4>Add Two Numbers</h4><pre>first_number = int(input(&quot;Enter a number: &quot;))<br>second_number = int(input(&quot;Enter another number: &quot;))<br>print(&quot;Sum of those two numbers is :&quot;, first_number + second_number)</pre><h4>Check Even or Odd</h4><pre>number = int(input(&quot;Enter a number to check odd or even : &quot;))<br>if number % 2 == 0 :<br>    print(&quot;EVEN!!&quot;)<br>else :<br>    print(&quot;ODD!!&quot;)</pre><h4>Find the Largest Number</h4><pre>num1 = int(input(&quot;First num : &quot;))<br>num2 = int(input(&quot;Second num : &quot;))<br>num3 = int(input(&quot;Third num : &quot;))<br><br>if (num1 &gt; num2 and num1 &gt; num3) :<br>    print(num1)<br>elif (num2 &gt; num1 and num2 &gt; num3) :<br>    print(num2)<br>else :<br>    print(num3)<br><br>#OR use max function<br><br>print(max(num1, num2, num3))</pre><h4>Count Vowels in a String</h4><pre>input_word = input(&quot;Enter a word: &quot;).lower()<br>vowels = &quot;aeiou&quot;<br><br>count = 0<br>for i in input_word:<br>    if i in vowels:<br>        count += 1<br>print(count)</pre><h4>Reverse a String</h4><pre>input_word = input(&quot;Enter a word: &quot;)<br>reverse_word = &quot;&quot;<br><br>for s in input_word:<br>    reverse_word = s + reverse_word<br><br>print(reverse_word)<br><br>#OR You can reverse the string using slicing: string[::-1]<br><br>print(input_word[::-1])</pre><h4>Check if a Number is Prime</h4><pre>number = int(input(&quot;Enter a number: &quot;))<br>if number &lt;= 1:<br>    print(&quot;NOT PRIME&quot;)<br>else :<br>    is_not_prime_number = False<br>    for i in range(2, int(number/2) + 1):<br>        if number%i == 0:<br>            is_not_prime_number = True<br>            break<br>    if is_not_prime_number:<br>        print(&quot;NOT PRIME&quot;)<br>    else:<br>        print(&quot;PRIME&quot;)<br>        </pre><h4>Sum of Digits</h4><pre>number = input(&quot;Enter a number: &quot;)<br>count = 0<br>for n in number:<br>    count += int(n)<br>print(count)</pre><h4>Factorial of a Number</h4><pre>number = int(input(&quot;Enter a number: &quot;))<br>factorial = 1<br>for n in range(1, number+1):<br>    factorial *= n<br>print(factorial)<br><br>#OR Recursive<br><br>def factorical(number:int) -&gt; int :<br>    if (number == 1 or number == 0) :<br>        return 1<br>    else : <br>        return number * factorical(number -1)</pre><h4>FizzBuzz</h4><pre>def fizzbuzz():<br>    for i in range(1, 101):<br>        if (i % 15 == 0) :<br>            print(&quot;FizzBuzz&quot;)<br>        elif (i % 5 == 0) :<br>            print(&quot;Buzz&quot;)<br>        elif (i % 3 == 0) :<br>            print(&quot;Fizz&quot;)<br>        else :<br>            print(i)</pre><h4>Count Occurrences of a Character in a String</h4><pre>def countOccurrences(string:str, char:str) -&gt; int :<br>    count = 0;<br>    for s in string:<br>        if (s == char):<br>            count += 1<br>    return count<br><br>#OR Use Build-in function<br>string.count(char)</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=001edb99cc73" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Docker and Docker Compose?]]></title>
            <link>https://medium.com/@dharanie89/all-i-know-about-docker-eccfced08507?source=rss-ae409437c2f7------2</link>
            <guid isPermaLink="false">https://medium.com/p/eccfced08507</guid>
            <dc:creator><![CDATA[Vinodharanie Sivalingam]]></dc:creator>
            <pubDate>Tue, 07 Jan 2025 15:46:06 GMT</pubDate>
            <atom:updated>2025-01-15T09:38:24.513Z</atom:updated>
            <content:encoded><![CDATA[<p>As I start learning Docker, I will share what I learn daily in this blog.</p><p>You’ve built a new project, and it’s running perfectly on your local machine. To make it work, you need a specific environment like Ubuntu, Java 17, and MySQL.</p><p>Now, your friend needs to set up the same project on her Windows machine 🙃. How do we make that happen 🧐 ? She’ll have to install the right OS, dependencies, and database, and make sure everything’s in sync. It’s gonna take forever and might drive her crazy! 😅</p><h4><strong>Docker’s Role in Solving This:</strong></h4><p>Docker can fix this problem by putting the entire environment into a container. With Docker, you can bundle your app, its dependencies, and settings into a Docker image. This image can be shared and run on any machine with Docker, so your friend can set up the environment quickly and easily 😎.</p><h4>How to set up the project to run in Docker 🧐?</h4><p>Setting up a project to run in Docker involves creating a <strong>Dockerfile</strong>, <strong>building an image</strong>, and then running a container based on that image.</p><ul><li><strong>Install Docker:</strong> <a href="https://docs.docker.com/desktop/">Docker installation doc</a></li><li><strong>Create a Dockerfile:</strong> In the root directory of your project, create a file named Dockerfile (without any file extension). This file will define how your project should be built and run in Docker. <a href="https://docs.docker.com/get-started/docker-concepts/building-images/writing-a-dockerfile/">Dockerfile commands and their explanations</a>. Here’s an example of a simple Dockerfile for a Java project:</li></ul><pre># Base image<br>FROM ubuntu:20.04<br><br># Install necessary dependencies for MySQL and your application<br>RUN apt-get update &amp;&amp; \<br>    apt-get install -y mysql-server openjdk-17<br><br>COPY . /app<br>WORKDIR /app<br><br># Expose the necessary ports<br>EXPOSE 8080 3306<br><br># Run your Java application<br>CMD service mysql start &amp;&amp; \<br>    java -jar /app/your-application.jar</pre><ul><li><strong>Build the Docker Image:</strong> Open your terminal in the root directory of your project (where the Dockerfile is located). Run the following command to build the Docker image:</li></ul><blockquote>Docker Image: A container image is a file with executable code that can be run as a container.<br>Container Registry: a database that stores images; these images can be public or private for those people or service account with permission.</blockquote><pre>#my-app is the name you want to assign to the image<br>docker build -t my-app . </pre><ul><li><strong>Run the Docker container:</strong> Once the image is built, you can run a container from that image with the following command:</li></ul><pre>#my-app is the name of docker image<br>docker run -p 8080:8080 my-app</pre><ul><li><strong>Verify the Application: </strong>Happy Ending!!!!</li></ul><h4>But…</h4><p>If your friend needs to run another project that also requires a MySQL database 😔, and if MySQL is bound to your app, she’ll have to create a new database for the other project. Can we reuse the MYSQL 🧐? <strong>YES, you can</strong> 👌. <strong>Docker Compose is here to solve these problems!</strong></p><h4>Docker compose</h4><p>You can define multiple containers in a docker-compose.yml file. One container is for your application, and the other is for MySQL.</p><p>Here’s why:</p><ul><li><strong>Separation of Concerns</strong>: Separating the database and application into different containers makes it easier to manage and maintain each service independently.</li><li><strong>Scalability</strong>: It allows you to scale the application and database separately if needed.</li><li><strong>Reusability</strong>: You can reuse MySQL containers for different applications without rebuilding your app image.</li></ul><h4>How to work with Docker Compose?</h4><ul><li><strong>Create a Dockerfile: </strong>In the root directory of your project, create a file named docker-compose.yml. <a href="https://docs.docker.com/reference/cli/docker/compose/">Docker compose file commands and their explanations</a>. Here’s an example of a simple docker-compose.yml:</li></ul><pre>version: &#39;3.9&#39;<br><br>services:<br>  app:<br>    build: .<br>    ports:<br>      - &quot;8080:8080&quot;<br>    depends_on:<br>      - mysql-db<br>    environment:<br>      DB_HOST: mysql-db<br>      DB_USER: root<br>      DB_PASSWORD: rootpassword<br><br>  mysql-db:<br>    image: mysql:8.0<br>    environment:<br>      MYSQL_ROOT_PASSWORD: rootpassword<br>      MYSQL_DATABASE: myapp<br>    ports:<br>      - &quot;3306:3306&quot;<br>    volumes:<br>      - mysql_data:/var/lib/mysql<br><br>volumes:<br>  mysql_data:</pre><ul><li><strong>Start the Services: </strong>Open your terminal in the root directory of your project (where the docker-compose.yml is located). Run the following command to up the services:</li></ul><pre>docker compose up</pre><ul><li><strong>View Running Containers: </strong>Run the following command to list the running services:</li></ul><pre>docker ps</pre><ul><li><strong>Stop the Services: </strong>Run the following command to down the services:</li></ul><pre>docker compose down</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eccfced08507" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Interesting Java Questions That Got Me Thinking]]></title>
            <link>https://medium.com/@dharanie89/interesting-java-questions-that-got-me-thinking-d86ed157bc9e?source=rss-ae409437c2f7------2</link>
            <guid isPermaLink="false">https://medium.com/p/d86ed157bc9e</guid>
            <dc:creator><![CDATA[Vinodharanie Sivalingam]]></dc:creator>
            <pubDate>Mon, 06 Jan 2025 09:59:32 GMT</pubDate>
            <atom:updated>2025-01-08T05:50:28.962Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently, I started searching for jobs, and here are some interesting questions that tested my Java skills.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NAgcR6xxzqQWikG-hbq2Sw.png" /></figure><ol><li>What’s the output of the following code snippet?</li></ol><pre>boolean x= true;<br>boolean y= false;<br><br>if (x = y) {<br>    System.out.println(&quot;x and y are equal.&quot;);<br>} else {<br>    System.out.println(&quot;x and y are not equal.&quot;);<br>}</pre><p>Normally, inside an if statement, there should be a condition that returns a boolean value (true or false). In this case, it’s a variable assignment, so we would typically expect a compilation error. However, <strong>the output is</strong> x and y are not equal. Why? <strong>x and </strong><strong>y are both boolean variables.</strong></p><p>Explanation:</p><ul><li>x is assigned to the value of y, which is false.</li><li>The result of the assignment (X = Y) is the value of x after the assignment, which is false.</li><li>Since the if statement checks for false, the else block is executed, and x and y are not equal. is printed.</li></ul><p>2. What’s the output of the following code snippet?</p><pre>class A {<br>    void go() {<br>    }<br>}<br><br>class B extends A {<br>    String go() {<br>        return null;<br>    }<br>}</pre><p>I thought it would override first, then overloading would kick in, and everything would work fine. But nope, that didn’t happen!</p><p>The output is: Compilation Error (attempting to use incompatible return type)</p><p>Explanation:</p><ul><li>In class A, the go() method is declared as void, meaning it does not return any value.</li><li>In class B, the go() method return type is String, which is not compatible with the return type of the go() method in class A (which is void).</li><li>Overriding will fail, and we’ll get a compilation error instead!</li></ul><h4>Why Can’t We Overload Based on Return Type?</h4><p>The reason is that the <strong>compiler cannot resolve the correct method to call based solely on the return type</strong>.</p><p>3. What’s the output of the following code snippet?</p><pre>Date d1 = new Date(99,11,31);<br>Date d2 = new Date(99,11,31);<br>test(d1, d2);<br>System.out.println(&quot;D1 &quot; + d1 + &quot; D2 &quot; + d2);<br><br>public static void test(Date d1, Date d2) {<br>  d1.setYear(100);<br>  d2 = d1;<br>}</pre><p>The output is: D1 Sun Dec 31 00:00:00 IST 2000 D2 Fri Dec 31 00:00:00 IST 1999</p><p>Explanation:</p><ul><li>new Date(99, 11, 31): This creates a Date object for the year 1999, December 31. Therefore, both d1 and d2 are Date objects representing December 31, 1999.</li><li>In the test method, d1’s year is changed to 2000, so now d1 represents December 31, 2000.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/401/1*O40OeW6n2SMfmWL9bUjSfQ.jpeg" /><figcaption>eg : Object references before d2=d1 line execution</figcaption></figure><ul><li>The line d2 = d1; assigns the reference of d1 to d2 (In Java, <strong>objects are passed by reference</strong>, meaning when you pass an object to a method, the method works with the same object in memory). However, this only <strong>changes </strong><strong>d2 locally</strong> within the method. The reference to d2 in the calling method (outside the test() method) remains unchanged. This means that after test() is executed, d2 still refers to the original Date object created in the main method, not the object that d1 refers to inside test().</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/401/1*9OTJIvA9kAZoXxais6WLcA.jpeg" /><figcaption>eg : Object references after d2=d1 line execution</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d86ed157bc9e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>