<?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 Coding Tamilan on Medium]]></title>
        <description><![CDATA[Stories by Coding Tamilan on Medium]]></description>
        <link>https://medium.com/@codingpullingo?source=rss-d09eca694083------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*NvD0KnuzL2mOe574wbmMmA.png</url>
            <title>Stories by Coding Tamilan on Medium</title>
            <link>https://medium.com/@codingpullingo?source=rss-d09eca694083------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 14:59:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@codingpullingo/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[☕ Java-ல Method Overloading vs Method Overriding: குழப்பமே இல்லாம எளிமையா புரிஞ்சுக்கலாம்!]]></title>
            <link>https://medium.com/@codingpullingo/java-%E0%AE%B2-method-overloading-vs-method-overriding-%E0%AE%95%E0%AF%81%E0%AE%B4%E0%AE%AA%E0%AF%8D%E0%AE%AA%E0%AE%AE%E0%AF%87-%E0%AE%87%E0%AE%B2%E0%AF%8D%E0%AE%B2%E0%AE%BE%E0%AE%AE-%E0%AE%8E%E0%AE%B3%E0%AE%BF%E0%AE%AE%E0%AF%88%E0%AE%AF%E0%AE%BE-%E0%AE%AA%E0%AF%81%E0%AE%B0%E0%AE%BF%E0%AE%9E%E0%AF%8D%E0%AE%9A%E0%AF%81%E0%AE%95%E0%AF%8D%E0%AE%95%E0%AE%B2%E0%AE%BE%E0%AE%AE%E0%AF%8D-06f3ccad892e?source=rss-d09eca694083------2</link>
            <guid isPermaLink="false">https://medium.com/p/06f3ccad892e</guid>
            <category><![CDATA[method-overriding]]></category>
            <category><![CDATA[method-overloading]]></category>
            <category><![CDATA[java8-tutorial]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Coding Tamilan]]></dc:creator>
            <pubDate>Fri, 02 Oct 2026 16:37:21 GMT</pubDate>
            <atom:updated>2026-10-02T16:37:21.991Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZttJmrPFrmNOJyqjnUaIjw.png" /></figure><p>வணக்கம் நண்பர்களே! 👋</p><p>Java கத்துக்க ஆரம்பிக்கும் போதோ, இல்ல Java Developer Interview-க்கு prepare பண்ணும் போதோ கண்டிப்பா நம்ம எல்லாரையும் குழப்புற ஒரு classic கேள்வி: <strong>“Method Overloading-க்கும் Method Overriding-க்கும் என்ன வித்தியாசம்?”</strong></p><p>ரெண்டுமே பாக்குறதுக்கு ஒரே மாதிரி “Method Over…”-ன்னு ஆரம்பிக்கிறதுனால, நிறைய பேரு interview-ல ரெண்டையும் மாத்தி மாத்தி சொல்லிடுவாங்க. ஆனா உண்மையிலேயே இது ரொம்ப ரொம்ப சிம்பிளான ஒரு concept!</p><p>இந்த article-ல, எந்தவித குழப்பமும் இல்லாம, நம்முடைய <strong>நிஜ வாழ்க்கை உதாரணங்கள் (Real-world examples)</strong> மற்றும் <strong>எளிய Java Code</strong> வச்சு தெளிவா புரிஞ்சுக்கலாம்! வாங்க! 🚀</p><h3>🎭 முதல்ல Polymorphism-னா என்ன?</h3><p>Overloading மற்றும் Overriding ரெண்டுமே Object-Oriented Programming (OOPs)-ன் முக்கிய தூணான <strong>Polymorphism</strong>-ன் இரு வகைகள்.</p><ul><li><strong>Poly</strong> = பல (Many)</li><li><strong>Morph</strong> = வடிவங்கள் (Forms)</li></ul><p>ஒரே பெயரைக் கொண்ட ஒரு செயல், சூழ்நிலைக்கு ஏத்த மாதிரி பல வடிவங்கள்ல இயங்குறது தான் Polymorphism. இதுல:</p><ol><li><strong>Compile-time Polymorphism</strong> (Static Binding) 👉 <strong>Method Overloading</strong></li><li><strong>Runtime Polymorphism</strong> (Dynamic Binding) 👉 <strong>Method Overriding</strong></li></ol><p>இப்போ ரெண்டையும் தனித்தனியா ஆழமா பாப்போம்!</p><h3>1️⃣ Method Overloading (Compile-Time Polymorphism)</h3><h3>💡 நிஜ வாழ்க்கை உதாரணம் (Real-World Analogy):</h3><p>நம்ம ஸ்மார்ட்போன்ல இருக்கிற <strong>“Search”</strong> பட்டனை யோசிச்சு பாருங்க:</p><ul><li>வெறும் Text குடுத்து தேடலாம்.</li><li>ஒரு Image-ஐ அப்லோட் பண்ணி தேடலாம் (Google Lens).</li><li>வாய்ஸ் குடுத்து தேடலாம் (Voice Search).</li></ul><p>இங்க செய்ற வேலை ஒன்னுதான் — <strong>“Search”</strong>. ஆனா நாம குடுக்குற Input (Parameters) வேற வேற! இதுதான் <strong>Overloading</strong>.</p><h3>📌 Java-ல Overloading-னா என்ன?</h3><p><strong>ஒரே Class-க்குள்</strong>, ஒரே பெயர் கொண்ட பல Method-கள் இருந்து, அவற்றின் <strong>Parameters (எண்ணிக்கை, Data Type, அல்லது Order)</strong> மட்டும் வேற மாதிரி இருந்தா அதுதான் <strong>Method Overloading</strong>.</p><h3>💻 Code Example:</h3><p>ஒரு எளிய Calculator கிளாஸ் எடுத்துப்போம்:</p><pre>class Calculator {<br>// 1. இரண்டு எண்களைக் கூட்டுதல்<br>    int add(int a, int b) {<br>        return a + b;<br>    }<br>    // 2. மூன்று எண்களைக் கூட்டுதல் (Parameter எண்ணிக்கை அதிகம்)<br>    int add(int a, int b, int c) {<br>        return a + b + c;<br>    }<br>    // 3. தசம எண்களைக் (double) கூட்டுதல் (Parameter வகை வேறு)<br>    double add(double a, double b) {<br>        return a + b;<br>    }<br>}<br>public class Main {<br>    public static void main(String[] args) {<br>        Calculator calc = new Calculator();<br>        System.out.println(calc.add(10, 20));       // Output: 30<br>        System.out.println(calc.add(10, 20, 30));   // Output: 60<br>        System.out.println(calc.add(5.5, 4.5));     // Output: 10.0<br>    }<br>}</pre><h3>🧠 இது ஏன் “Compile-Time” Polymorphism?</h3><p>நீங்க code-ஐ compile பண்ணும் போதே, Java Compiler-க்கு தெளிவா தெரிஞ்சிடும்: &quot;calc.add(10, 20)&quot; கால் பண்ணா முதல் method-ஐயும், &quot;calc.add(10, 20, 30)&quot; கால் பண்ணா இரண்டாவது method-ஐயும் எக்ஸிகியூட் பண்ணனும்னு. முடிவை Compile நேரத்திலேயே எடுக்குறதால இதுக்கு <strong>Static Binding</strong> அல்லது <strong>Compile-Time Polymorphism</strong> என்று பெயர்.</p><blockquote><em>[!WARNING] </em><strong><em>முக்கியமான Interview ட்ரிக்:</em></strong><em> வெறும் </em><em>Return Type-ஐ மட்டும் மாத்திட்டு, Parameters-ஐ மாத்தாம விட்டா அது Overloading கிடையாது! Java Compiler உடனே </em><strong><em>Compile Error</em></strong><em> அடிச்சிடும்!</em></blockquote><h3>2️⃣ Method Overriding (Runtime Polymorphism)</h3><h3>💡 நிஜ வாழ்க்கை உதாரணம் (Real-World Analogy):</h3><p>ஒரு குடும்பத்துல அப்பாவுக்கும் பையனுக்கும் நடக்குற விஷயத்தை எடுத்துப்போம்:</p><ul><li>அப்பா பையனுக்கு ஒரு கார் வாங்கி தர்றாரு (Parent Class). அந்த கார்ல ஒரு ஹார்ன் சவுண்ட் இருக்கு (makeSound() -&gt; &quot;பீப் பீப்&quot;).</li><li>பையன் அந்த காரை ஓட்டும் போது, அந்த பழைய ஹார்னை கழட்டிட்டு, ஒரு மாசான ஸ்போர்ட்ஸ் ஹார்ன் மாட்டிக்குறான் (makeSound() -&gt; &quot;ப்ரூம் ப்ரூம்!&quot;).</li></ul><p>இங்க செயல் ஒன்னுதான் (makeSound), ஆனா பையன் (Child Class) அப்பா குடுத்த method-ஐ தனக்கு ஏத்த மாதிரி மாத்தி அமைச்சுக்குறான். இதுதான் <strong>Overriding</strong>!</p><h3>📌 Java-ல Overriding-னா என்ன?</h3><p>Parent Class-ல் ஏற்கனவே உள்ள ஒரு Method-ஐ, Child Class தனக்கேற்றவாறு <strong>அதே பெயர், அதே Parameters, மற்றும் அதே Return Type</strong> உடன் மாற்றி எழுதுவது <strong>Method Overriding</strong>.</p><p>இங்கு கண்டிப்பா <strong>Inheritance (</strong><strong>extends)</strong> இருக்க வேண்டும்!</p><h3>💻 Code Example:</h3><pre>// Parent Class<br>class Animal {<br>    void makeSound() {<br>        System.out.println(&quot;விலங்குகள் பொதுவான சத்தம் போடுகின்றன...&quot;);<br>    }<br>}<br>// Child Class 1<br>class Dog extends Animal {<br>    @Override<br>    void makeSound() {<br>        System.out.println(&quot;நாய் குரைக்கிறது: லொள் லொள்! 🐶&quot;);<br>    }<br>}<br>// Child Class 2<br>class Cat extends Animal {<br>    @Override<br>    void makeSound() {<br>        System.out.println(&quot;பூனை கத்துகிறது: மியாவ் மியாவ்! 🐱&quot;);<br>    }<br>}<br>public class Main {<br>    public static void main(String[] args) {<br>        // Parent Reference, Child Object (Upcasting)<br>        Animal myAnimal1 = new Dog();<br>        Animal myAnimal2 = new Cat();<br>        myAnimal1.makeSound(); // Output: நாய் குரைக்கிறது: லொள் லொள்! 🐶<br>        myAnimal2.makeSound(); // Output: பூனை கத்துகிறது: மியாவ் மியாவ்! 🐱<br>    }<br>}</pre><h3>🧠 இது ஏன் “Runtime” Polymorphism?</h3><p>இங்க பாருங்க: Animal myAnimal1 = new Dog();</p><ul><li>Reference Type: Animal (Parent)</li><li>Actual Object: Dog (Child)</li></ul><p>Compile பண்ணும் போது Compiler-க்கு myAnimal1 ஒரு Animal ஆப்ஜெக்ட் மட்டுமே தெரியும். ஆனா ப்ரோக்ராம் ரன் ஆகும் போது (JVM runtime), அது உண்மையான ஆப்ஜெக்ட் Dog-ஆ இருக்கிறதால, Dog-ல் உள்ள makeSound()-ஐ இயக்கும். இதனால தான் இதுக்கு <strong>Dynamic Binding</strong> அல்லது <strong>Runtime Polymorphism</strong> என்று பெயர்.</p><h3>⚖️ Method Overloading vs Overriding: நேரடி ஒப்பீடு (Cheat Sheet)</h3><p>Interview-க்கு போறதுக்கு முன்னாடி இந்த ஒரு டேபிளை மட்டும் மனசுல வச்சிக்கோங்க, போதும்:</p><p>அம்சம் (Feature)Method OverloadingMethod Overriding<strong>தத்துவம்</strong>ஒரே Class-க்குள் கூடுதல் வசதிParent-ன் செயலை Child மாற்றி அமைப்பது<strong>Polymorphism வகைCompile-time</strong> (Static Binding)<strong>Runtime</strong> (Dynamic Binding)<strong>இடம் (Class)ஒரே Class-க்குள்</strong> நடக்கும்<strong>Superclass மற்றும் Subclass</strong> இடையே நடக்கும் (Inheritance அவசியம்)<strong>Method Name</strong>ஒன்றாக இருக்க வேண்டும்ஒன்றாக இருக்க வேண்டும்<strong>Parametersகண்டிப்பாக வேறுபட வேண்டும்</strong> (Count / Type)<strong>அப்படியே ஒன்றாக இருக்க வேண்டும்Return Type</strong>மாறலாம், தவறில்லைஒன்றாக இருக்க வேண்டும் (அல்லது Covariant Type)<strong>private / </strong><strong>final</strong>Overload செய்யலாம்<strong>Override செய்ய முடியாது</strong><strong>static Methods</strong>Overload செய்யலாம்<strong>Override செய்ய முடியாது</strong> (Method Hiding எனப்படும்)<strong>Annotation</strong>தேவையில்லை@Override பயன்படுத்துவது Best Practice</p><h3>🔥 அடிக்கடி கேட்கப்படும் 3 முக்கியமான Interview கேள்விகள்</h3><h3>Q1: static method-களை Override பண்ண முடியுமா?</h3><blockquote><strong><em>பதில்: முடியாது!</em></strong><em> Parent class-ல் உள்ள ஒரு static method-ஐ child class-ல் அதே பெயரில் எழுதினால், அது Override ஆகாது. அதற்குப் பெயர் </em><strong><em>Method Hiding</em></strong><em>. Static method-கள் ஆப்ஜெக்ட்டைச் சார்ந்தது அல்ல, Class-ஐச் சார்ந்தது என்பதால் Runtime Polymorphism இங்கு வேலை செய்யாது.</em></blockquote><h3>Q2: Return type-ஐ மட்டும் மாற்றி Overloading பண்ண முடியுமா?</h3><blockquote><strong><em>பதில்: முடியாது!</em></strong><em> Parameters மாறாமல் வெறும் Return type-ஐ மட்டும் மாற்றினால் Java Compiler குழம்பிவிடும் (</em><em>Ambiguity error).</em></blockquote><h3>Q3: @Override annotation போடலைன்னா கோட் ரன் ஆகாதா?</h3><blockquote><strong><em>பதில்: ரன் ஆகும்.</em></strong><em> </em><em>@Override கட்டாயம் இல்லை. ஆனால் அதை போடுவது மிகச் சிறந்த பழக்கம். ஏதேனும் spelling mistake அல்லது parameter mismatch இருந்தால் Compiler உடனே நமக்கு எச்சரிக்கும்.</em></blockquote><h3>🏁 முடிவுரை (Conclusion)</h3><p>ரொம்ப சுருக்கமா சொல்லணும்னா:</p><ul><li><strong>Overloading</strong> என்பது ஒரு Class-க்குள் readability மற்றும் flexibility-ஐ அதிகப்படுத்துகிறது (ஒரே பேர், பல வேலை).</li><li><strong>Overriding</strong> என்பது Inheritance வழியே Child Class-க்கு பிரத்யேக சுதந்திரத்தை வழங்குகிறது (அப்பா வழியில் தனி வழி).</li></ul><p>இந்த எளிய விளக்கம் உங்களுக்குப் பிடித்திருந்தால், Medium-ல் மறக்காமல் <strong>Clap 👏 பண்ணுங்க</strong>! உங்களுடைய சக Developer நண்பர்களுடனும் பகிர்ந்து கொள்ளுங்கள்.</p><p>உங்களுக்கு இதில் ஏதேனும் சந்தேகம் இருந்தால் கீழே Comments-ல் கேளுங்கள், இணைந்து கற்போம்! Happy Coding! 💻✨</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=06f3ccad892e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Java 8 Stream API Interview-ல கேட்கப்படும் Top 10 Questions (தமிழ் விளக்கம்)]]></title>
            <link>https://medium.com/@codingpullingo/java-8-stream-api-interview-%E0%AE%B2-%E0%AE%95%E0%AF%87%E0%AE%9F%E0%AF%8D%E0%AE%95%E0%AE%AA%E0%AF%8D%E0%AE%AA%E0%AE%9F%E0%AF%81%E0%AE%AE%E0%AF%8D-top-10-questions-%E0%AE%A4%E0%AE%AE%E0%AE%BF%E0%AE%B4%E0%AF%8D-%E0%AE%B5%E0%AE%BF%E0%AE%B3%E0%AE%95%E0%AF%8D%E0%AE%95%E0%AE%AE%E0%AF%8D-a65ea6851082?source=rss-d09eca694083------2</link>
            <guid isPermaLink="false">https://medium.com/p/a65ea6851082</guid>
            <category><![CDATA[java-stream-api]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[java8]]></category>
            <dc:creator><![CDATA[Coding Tamilan]]></dc:creator>
            <pubDate>Fri, 02 Oct 2026 15:41:56 GMT</pubDate>
            <atom:updated>2026-10-02T15:41:56.628Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9QnCT0DvDgPiAScj05Uhrg.png" /></figure><p>வணக்கம் நண்பர்களே! 👋</p><p>நீங்க ஒரு Java Developer-ஆ இருந்து, சமீபத்துல Interview attend பண்ணியிருந்தா இல்ல இனிமே attend பண்ண போறீங்கன்னா, கண்டிப்பா <strong>Java 8 Stream API</strong>-ல இருந்து கேள்விகள் இல்லாம அந்த interview முடியாது!</p><p>Stream API வந்த பிறகு Java code எழுதுற விதமே ரொம்ப clean-ஆ, readable-ஆ மாறிடுச்சு. ஆனா interview-ல தியரியா கேட்காம, &quot;எங்கிட்ட ஒரு Employee list இருக்கு, இதுல இருந்து இதை எடுத்து கொடுங்க&quot;-ன்னு practical coding problems தான் அதிகமா கேப்பாங்க.</p><p>இந்த article-ல, interview-ல அடிக்கடி கேட்கப்படுற <strong>Top 10 Stream API Questions</strong>-ஐ ஒரு ரியல்-டைம் Employee data வச்சு, ரொம்ப ஈஸியா பேச்சு வழக்குத் தமிழ்ல பாக்கப்போறோம்! வாங்க ஆரம்பிக்கலாம்! 🔥</p><h3>📌 நம்ம பயன்படுத்த போற Employee Model &amp; Data</h3><p>முதல்ல நம்மகிட்ட இருக்கிற Employee கிளாஸ் மற்றும் data என்னன்னு பாத்துடுவோம்:</p><pre>class Employee {<br>    private int id;<br>    private String name;<br>    private String department;<br>    private String city;<br>    private int salary;<br>// Constructor, Getters, Setters &amp; toString()<br>}</pre><p><strong>Sample Data List:</strong></p><pre>List&lt;Employee&gt; employeeList = new ArrayList&lt;&gt;();<br>employeeList.add(new Employee(1, &quot;John&quot;, &quot;IT&quot;, &quot;New York&quot;, 50000));<br>employeeList.add(new Employee(2, &quot;Jane&quot;, &quot;HR&quot;, &quot;Chicago&quot;, 60000));<br>employeeList.add(new Employee(3, &quot;Bob&quot;, &quot;IT&quot;, &quot;San Francisco&quot;, 70000));<br>employeeList.add(new Employee(4, &quot;Alice&quot;, &quot;HR&quot;, &quot;New York&quot;, 80000));<br>employeeList.add(new Employee(5, &quot;Charlie&quot;, &quot;IT&quot;, &quot;Chicago&quot;, 90000));<br>employeeList.add(new Employee(6, &quot;David&quot;, &quot;HR&quot;, &quot;San Francisco&quot;, 100000));<br>employeeList.add(new Employee(7, &quot;Eve&quot;, &quot;Sales&quot;, &quot;New York&quot;, 110000));<br>employeeList.add(new Employee(8, &quot;Frank&quot;, &quot;Sales&quot;, &quot;Chicago&quot;, 120000));<br>employeeList.add(new Employee(9, &quot;Grace&quot;, &quot;IT&quot;, &quot;San Francisco&quot;, 130000));<br>employeeList.add(new Employee(10, &quot;Heidi&quot;, &quot;HR&quot;, &quot;New York&quot;, 140000));</pre><h3>1️⃣ “IT” Department-ல 70,000-க்கு மேல சம்பளம் வாங்குறவங்கள மட்டும் Filter பண்ணுங்க</h3><h3>🎯 கேள்வி:</h3><p>IT துறையில் பணிபுரிந்து, சம்பளம் 70,000-க்கு மேல் இருக்கும் ஊழியர்களை மட்டும் தனியாக ஒரு List-ஆக எடுக்க வேண்டும்.</p><h3>💻 Code:</h3><pre>List&lt;Employee&gt; itHighEarners = employeeList.stream()<br>        .filter(e -&gt; &quot;IT&quot;.equals(e.getDepartment()) &amp;&amp; e.getSalary() &gt; 70000)<br>        .collect(Collectors.toList());<br>itHighEarners.forEach(System.out::println);</pre><h3>💡 எப்படி வேலை செய்யுது?</h3><ul><li>.filter() method-குள்ள ஒரு Predicate (boolean condition) பாஸ் பண்றோம்.</li><li>ரெண்டு condition-யும் &amp;&amp; போட்டு செக் பண்றோம்: department &quot;IT&quot;-ஆ இருக்கணும் மற்றும் salary &gt; 70000-ஆ இருக்கணும்.</li><li>Filter பண்ணி முடிச்சதும், .collect(Collectors.toList()) மூலமா அதை மறுபடியும் ஒரு புது List-ஆ மாத்திடுறோம்.</li></ul><h3>🖨️ Output:</h3><pre>Employee{id=5, name=&#39;Charlie&#39;, department=&#39;IT&#39;, city=&#39;Chicago&#39;, salary=90000}<br>Employee{id=9, name=&#39;Grace&#39;, department=&#39;IT&#39;, city=&#39;San Francisco&#39;, salary=130000}</pre><h3>2️⃣ கம்பெனியிலேயே அதிக சம்பளம் (Highest Salary) வாங்குற Employee யார்?</h3><h3>🎯 கேள்வி:</h3><p>முழு list-லையும் அதிக சம்பளம் வாங்கும் ஊழியரை கண்டுபிடிக்க வேண்டும்.</p><h3>💻 Code:</h3><pre>Optional&lt;Employee&gt; highestPaid = employeeList.stream()<br>        .max(Comparator.comparingInt(Employee::getSalary));<br>highestPaid.ifPresent(System.out::println);</pre><h3>💡 எப்படி வேலை செய்யுது?</h3><ul><li>.max() method-க்கு ஒரு Comparator தேவை.</li><li>Comparator.comparingInt(Employee::getSalary) salary-ஐ பேஸ் பண்ணி compare பண்ணும்.</li><li>ஒருவேளை List காலியா இருந்தா NullPointerException வராம இருக்க Stream API நமக்கு Optional&lt;Employee&gt; ரிட்டர்ன் பண்ணுது.</li><li>அதனால .ifPresent() போட்டு safe-ஆ print பண்றோம்.</li></ul><h3>🖨️ Output:</h3><pre>Employee{id=10, name=&#39;Heidi&#39;, department=&#39;HR&#39;, city=&#39;New York&#39;, salary=140000}</pre><h3>3️⃣ 2-வது அதிக சம்பளம் (2nd Highest Salary) வாங்குற Employee யார்?</h3><h3>🎯 கேள்வி:</h3><p>Interview-ல 90% கண்டிப்பா கேட்கிற ஒரு classic கேள்வி இது! 2nd highest salary வாங்குற employee-ஐ எப்படி எடுக்கிறது?</p><h3>💻 Code:</h3><pre>Optional&lt;Employee&gt; secondHighest = employeeList.stream()<br>        .sorted(Comparator.comparingInt(Employee::getSalary).reversed())<br>        .skip(1)<br>        .findFirst();<br>secondHighest.ifPresent(System.out::println);</pre><h3>💡 எப்படி வேலை செய்யுது?</h3><ul><li>முதல்ல .sorted(...) வச்சு salary-ஐ descending order-ல (அதிகத்துல இருந்து குறைவா) sort பண்றோம் (.reversed()).</li><li>.skip(1) போடும்போது முதல் இடத்துல இருக்கிற (1st highest) ஆளை skip பண்ணிடும்.</li><li>அதுக்கப்புறம் வர்ற முதல் ஆள் தான் 2nd highest! அதை .findFirst() மூலமா எடுத்துக்கிறோம்.</li></ul><h3>🖨️ Output:</h3><pre>Employee{id=9, name=&#39;Grace&#39;, department=&#39;IT&#39;, city=&#39;San Francisco&#39;, salary=130000}</pre><h3>4️⃣ ஒவ்வொரு Department-லேயும் எத்தனை பேர் வேலை செய்றாங்க? (Count by Department)</h3><h3>🎯 கேள்வி:</h3><p>Department வாரியாக ஊழியர்களின் எண்ணிக்கையை கணக்கிட வேண்டும் (SQL-ல GROUP BY department, COUNT(*) பண்ற மாதிரி).</p><h3>💻 Code:</h3><pre>Map&lt;String, Long&gt; countByDept = employeeList.stream()<br>        .collect(Collectors.groupingBy(<br>                Employee::getDepartment, <br>                Collectors.counting()<br>        ));<br>countByDept.forEach((dept, count) -&gt; System.out.println(dept + &quot;: &quot; + count));</pre><h3>💡 எப்படி வேலை செய்யுது?</h3><ul><li>Collectors.groupingBy() SQL-ல இருக்கிற GROUP BY மாதிரி வேலை செய்யும்.</li><li>முதல் parameter: எதை வச்சு group பண்ணனும்? (Employee::getDepartment).</li><li>இரண்டாவது downstream collector: group பண்ணதுக்கு அப்புறம் என்ன பண்ணனும்? இங்க நாம எண்ணிக்கை தேவைப்படுறதால Collectors.counting() கொடுக்கிறோம்.</li><li>Result ஒரு Map&lt;String, Long&gt; ஆக கிடைக்கும்.</li></ul><h3>🖨️ Output:</h3><pre>Sales: 2<br>HR: 4<br>IT: 4</pre><h3>5️⃣ ஒவ்வொரு Department-ன் Average Salary எவ்வளவு?</h3><h3>🎯 கேள்வி:</h3><p>ஒவ்வொரு துறைக்கும் சராசரி சம்பளத்தை (Average Salary) கண்டுபிடிக்க வேண்டும்.</p><h3>💻 Code:</h3><pre>Map&lt;String, Double&gt; avgSalaryByDept = employeeList.stream()<br>        .collect(Collectors.groupingBy(<br>                Employee::getDepartment, <br>                Collectors.averagingInt(Employee::getSalary)<br>        ));<br>avgSalaryByDept.forEach((dept, avg) -&gt; System.out.printf(&quot;%s: %.2f%n&quot;, dept, avg));</pre><h3>💡 எப்படி வேலை செய்யுது?</h3><ul><li>முந்தைய கேள்வி மாதிரியே தான், ஆனா இங்க downstream collector-ஆ Collectors.averagingInt(Employee::getSalary)-ஐ பயன்படுத்துறோம்.</li><li>இது தானாகவே ஒவ்வொரு department-ன் சம்பளங்களை கூட்டி சராசரியை (Double value) கணக்கிட்டு Map-ல் கொடுக்கும்.</li></ul><h3>🖨️ Output:</h3><pre>Sales: 115000.00<br>HR: 95000.00<br>IT: 85000.00</pre><h3>6️⃣ ஒவ்வொரு Department-லேயும் அதிக சம்பளம் வாங்குறவர் யார்? (Max by Department)</h3><h3>🎯 கேள்வி:</h3><p>ஒவ்வொரு துறையிலும் உள்ள உச்சபட்ச சம்பளம் வாங்கும் ஊழியரை கண்டுபிடிக்க வேண்டும்.</p><h3>💻 Code:</h3><pre>Map&lt;String, Employee&gt; topEarnerByDept = employeeList.stream()<br>        .collect(Collectors.groupingBy(<br>                Employee::getDepartment,<br>                Collectors.collectingAndThen(<br>                        Collectors.maxBy(Comparator.comparingInt(Employee::getSalary)),<br>                        Optional::get<br>                )<br>        ));<br>topEarnerByDept.forEach((dept, emp) -&gt; <br>        System.out.println(dept + &quot; -&gt; &quot; + emp.getName() + &quot; ($&quot; + emp.getSalary() + &quot;)&quot;));</pre><h3>💡 எப்படி வேலை செய்யுது?</h3><ul><li>இது ஒரு advanced grouping question!</li><li>Collectors.maxBy(...) பயன்படுத்தினா நமக்கு Optional&lt;Employee&gt; கிடைக்கும்.</li><li>அந்த Optional-ல இருந்து நேரடியா Employee ஆப்ஜெக்ட்டை எடுக்க Collectors.collectingAndThen(..., Optional::get) பயன்படுத்துறோம்.</li><li>இதன் மூலம் Result Map&lt;String, Optional&lt;Employee&gt;&gt;-ஆ இல்லாம, கிளீனா Map&lt;String, Employee&gt;-ஆ கிடைக்கும்.</li></ul><h3>🖨️ Output:</h3><pre>Sales -&gt; Frank ($120000)<br>HR -&gt; Heidi ($140000)<br>IT -&gt; Grace ($130000)</pre><h3>7️⃣ எல்லா Employee பெயர்களையும் Comma போட்டு, Uppercase-ல ஒரே String-ஆ மாத்துங்க</h3><h3>🎯 கேள்வி:</h3><p>அனைத்து ஊழியர்களின் பெயர்களையும் பெரிய எழுத்துக்களில் (Uppercase) மாற்றி, கமா (,) இட்டு ஒரே வரியாக இணைக்க வேண்டும்.</p><h3>💻 Code:</h3><pre>String names = employeeList.stream()<br>        .map(e -&gt; e.getName().toUpperCase())<br>        .collect(Collectors.joining(&quot;, &quot;));<br>System.out.println(names);</pre><h3>💡 எப்படி வேலை செய்யுது?</h3><ul><li>.map() மூலம் ஒவ்வொரு Employee ஆப்ஜெக்ட்ல இருந்தும் வெறும் பெயரை மட்டும் எடுத்து அதை .toUpperCase() பண்றோம்.</li><li>கடைசியா Collectors.joining(&quot;, &quot;) எல்லா பெயர்களுக்கும் நடுவுல கமா சேர்த்து ஒரு அழகான String-ஆ கொடுக்குது. பழைய மாதிரி for-loop போட்டு கடைசி கமாவ ரிமூவ் பண்ண வேண்டிய அவசியமே இல்ல!</li></ul><h3>🖨️ Output:</h3><pre>JOHN, JANE, BOB, ALICE, CHARLIE, DAVID, EVE, FRANK, GRACE, HEIDI</pre><h3>8️⃣ Partitioning: 80,000-க்கு மேல் மற்றும் குறைவான சம்பளம் வாங்குபவர்களை பிரிக்கவும்</h3><h3>🎯 கேள்வி:</h3><p>Salary &gt; 80,000 உள்ளவர்களை ஒரு பட்டியலாகவும், 80,000 அல்லது அதற்கும் குறைவாக உள்ளவர்களை மற்றொரு பட்டியலாகவும் பிரிக்க வேண்டும்.</p><h3>💻 Code:</h3><pre>Map&lt;Boolean, List&lt;Employee&gt;&gt; partitioned = employeeList.stream()<br>        .collect(Collectors.partitioningBy(e -&gt; e.getSalary() &gt; 80000));<br>System.out.println(&quot;Earning &gt; 80k: &quot; + partitioned.get(true).size() + &quot; employees&quot;);<br>System.out.println(&quot;Earning &lt;= 80k: &quot; + partitioned.get(false).size() + &quot; employees&quot;);</pre><h3>💡 எப்படி வேலை செய்யுது?</h3><ul><li>groupingBy மற்றும் partitioningBy-க்கு என்ன வித்தியாசம்னு interview-ல அடிக்கடி கேப்பாங்க:</li><li>groupingBy: எத்தனை categories வேணும்னாலும் பிரிக்கலாம் (n keys).</li><li>partitioningBy: கண்டிப்பா ரெண்டே ரெண்டு category தான் (true அல்லது false).</li><li>இங்க சம்பளம் 80k-க்கு மேல இருந்தா true list-லயும், இல்லன்னா false list-லயும் விழும்.</li></ul><h3>🖨️ Output:</h3><pre>Earning &gt; 80k: 6 employees<br>Earning &lt;= 80k: 4 employees</pre><h3>9️⃣ Multiple Fields வைத்து Sort செய்வது எப்படி? (Department ASC, பிறகு Salary DESC)</h3><h3>🎯 கேள்வி:</h3><p>முதலில் Department பெயரின் அடிப்படையில் ஏறுவரிசையிலும் (Alphabetical order), ஒரே department-க்குள் இருப்பவர்களை அவர்களின் Salary அடிப்படையில் இறங்குவரிசையிலும் (Descending order) sort செய்ய வேண்டும்.</p><h3>💻 Code:</h3><pre>List&lt;Employee&gt; sortedEmployees = employeeList.stream()<br>        .sorted(Comparator.comparing(Employee::getDepartment)<br>                .thenComparing(Comparator.comparingInt(Employee::getSalary).reversed()))<br>        .collect(Collectors.toList());<br>sortedEmployees.forEach(e -&gt; <br>        System.out.println(e.getDepartment() + &quot; | &quot; + e.getName() + &quot; | $&quot; + e.getSalary()));</pre><h3>💡 எப்படி வேலை செய்யுது?</h3><ul><li>Comparator.comparing(...) முதல் level sorting-ஐ செய்யும் (Department ascending).</li><li>.thenComparing(...) அடுத்த level sorting-ஐ செய்யும் (Salary descending).</li><li>எத்தனை லெவல் வேணும்னாலும் நாம .thenComparing() சங்கிலித் தொடர் போல சேர்த்துட்டே போகலாம்!</li></ul><h3>🖨️ Output:</h3><pre>HR | Heidi | $140000<br>HR | David | $100000<br>HR | Alice | $80000<br>HR | Jane | $60000<br>IT | Grace | $130000<br>IT | Charlie | $90000<br>IT | Bob | $70000<br>IT | John | $50000<br>Sales | Frank | $120000<br>Sales | Eve | $110000</pre><h3>🔟 Summary Statistics: மொத்த சம்பளத்தின் Min, Max, Average, Sum, Count-ஐ ஒரே நொடியில் எடுப்பது எப்படி?</h3><h3>🎯 கேள்வி:</h3><p>தனியாக loop எழுதாமல், சம்பளத்தின் குறைந்தபட்சம், அதிகபட்சம், சராசரி, கூடுதல் மற்றும் எண்ணிக்கையை ஒரே நேரத்தில் எடுக்க வேண்டும்.</p><h3>💻 Code:</h3><pre>IntSummaryStatistics stats = employeeList.stream()<br>        .mapToInt(Employee::getSalary)<br>        .summaryStatistics();<br>System.out.println(&quot;Count:   &quot; + stats.getCount());<br>System.out.println(&quot;Min:     $&quot; + stats.getMin());<br>System.out.println(&quot;Max:     $&quot; + stats.getMax());<br>System.out.println(&quot;Average: $&quot; + stats.getAverage());<br>System.out.println(&quot;Sum:     $&quot; + stats.getSum());</pre><h3>💡 எப்படி வேலை செய்யுது?</h3><ul><li>.mapToInt(Employee::getSalary) stream-ஐ ஒரு IntStream-ஆ மாத்துது (Primitive stream).</li><li>IntStream-ல் உள்ள .summaryStatistics() method நமக்கு ஒரு IntSummaryStatistics ஆப்ஜெக்ட்டை தருது.</li><li>இதில் ஒரே பாஸ்ஸில் (single pass) count, min, max, sum, average எல்லாமே calculate ஆகிடும்!</li></ul><h3>🖨️ Output:</h3><pre>Count:   10<br>Min:     $50000<br>Max:     $140000<br>Average: $95000.0<br>Sum:     $950000</pre><h3>🎯 Quick Interview Tips:</h3><ol><li><strong>Intermediate vs Terminal Operations:</strong> filter(), map(), sorted() போன்றவை Intermediate operations (Lazy-ஆ வேலை செய்யும்). collect(), forEach(), count(), findFirst() போன்றவை Terminal operations (இது கால் பண்ணும் போது தான் Stream இயங்கும்).</li><li><strong>groupingBy vs partitioningBy:</strong> ரெண்டே குரூப்னா (boolean condition) partitioningBy, பல பிரிவுகள்னா groupingBy.</li><li><strong>Primitive Streams:</strong> performance அதிகப்படுத்த mapToInt(), mapToLong(), mapToDouble() பயன்படுத்துங்கள் (Boxing / Unboxing overhead தவிர்க்கப்படும்).</li></ol><h3>🏁 முடிவுரை (Conclusion)</h3><p>Stream API-ல இந்த 10 கேள்விகளை நீங்க தெளிவா புரிஞ்சிக்கிட்டு practice பண்ணிட்டீங்கனாலே, எந்த ஒரு Java Developer Interview-லையும் Stream API-ல வரக்கூடிய கேள்விகளை தன்னம்பிக்கையோட face பண்ணலாம்!</p><p>இந்த article உங்களுக்கு பயனுள்ளதா இருந்தா, கண்டிப்பா <strong>Clap 👏 பண்ணுங்க</strong>, உங்க நண்பர்களோட <strong>Share பண்ணுங்க</strong>! உங்களுக்கு Stream API-ல வேற ஏதாச்சும் சந்தேகங்கள் இருந்தா கீழே comment பண்ணுங்க, அடுத்த பதிவுல பாக்கலாம்!</p><p>Happy Coding! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a65ea6851082" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>