<?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 Suresh Kumar on Medium]]></title>
        <description><![CDATA[Stories by Suresh Kumar on Medium]]></description>
        <link>https://medium.com/@sureshkumar_95502?source=rss-68f0c1676484------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Pq8k-1mJTUbX4cwT8S4nqw.gif</url>
            <title>Stories by Suresh Kumar on Medium</title>
            <link>https://medium.com/@sureshkumar_95502?source=rss-68f0c1676484------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 22:40:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sureshkumar_95502/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[VennsilixCampus — Modern School ERP]]></title>
            <link>https://medium.com/@sureshkumar_95502/vennsilixcampus-modern-school-erp-a0b011118422?source=rss-68f0c1676484------2</link>
            <guid isPermaLink="false">https://medium.com/p/a0b011118422</guid>
            <category><![CDATA[vennsilixcampus]]></category>
            <category><![CDATA[school-erp]]></category>
            <category><![CDATA[school-software]]></category>
            <category><![CDATA[vennsilix-technologies]]></category>
            <category><![CDATA[school-management-sw]]></category>
            <dc:creator><![CDATA[Suresh Kumar]]></dc:creator>
            <pubDate>Wed, 09 Sep 2026 08:06:36 GMT</pubDate>
            <atom:updated>2026-09-09T08:06:36.146Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YmuzuifStNVJWYG_AhO30g.png" /><figcaption>VennsilixCampus — School ERP</figcaption></figure><h3>VennsilixCampus — Built for School administrators, teachers and parents</h3><p>VennsilixCampus connects administrators, teachers, students and parents through role-based access and mobile applications.</p><p>Administrators can manage school operations, fees, examinations and reports. Teachers can handle attendance, timetable, homework and examinations, while parents and students can access relevant information digitally.</p><p>The goal is to replace scattered registers, spreadsheets and messages with <strong>one connected School Management Software platform</strong>.</p><h3>Strong features matter more than just a long feature list</h3><p>With VennsilixCampus, the focus has always been on <strong>strong, practical features — not superficial features</strong>.</p><p>Attendance, for example, is more than marking students present or absent. Schools need attendance trends, low-attendance identification and class-level insights.</p><p>Similarly, examination management covers the complete lifecycle — schedules, subjects, marks, reports, analysis and communication.</p><p>The same approach applies to fees, timetable, homework, admissions and other areas. <strong>That is where a good School ERP should differentiate itself.</strong></p><h3>Mobile-first school management</h3><p>Schools today need access beyond the desktop.</p><p>VennsilixCampus provides mobile access so parents can check information, teachers can perform daily tasks, and administrators can stay connected with school operations wherever they are.</p><h3>Communication made easier — WhatsApp alerts</h3><p>Schools communicate every day — fee reminders, homework, examinations, parent meetings and announcements. WhatsApp alerts(in regional languages) are used for efficient communication.</p><p>VennsilixCampus supports digital communication to reduce repetitive phone calls and manual work.</p><h3>Designed for different schools</h3><p>Every school has different structures and requirements. VennsilixCampus is designed as a <strong>multi-school platform</strong>, supporting everything from smaller schools to larger institutions with multiple administrators, teachers, classes and departments.</p><h3>More than software</h3><p>I don’t see VennsilixCampus simply as an attendance, fee or examination application.</p><p>The bigger vision is a <strong>digital operating platform for the entire school</strong> — connecting admissions, academics, attendance, fees, examinations and administration in one place.</p><p>Instead of asking, <em>“Which software should we use for this?”</em>, schools can ask:</p><p><strong>“Can we manage this through VennsilixCampus?”</strong></p><h3>Built by Vennsilix Technologies Private Limited</h3><p>VennsilixCampus™ is a product of <strong>Vennsilix Technologies Private Limited, Bangalore, India</strong>, with a long-term vision of building strong technology solutions for education and school management.</p><h3>Why VennsilixCampus has potential</h3><p>The School ERP market is competitive, so simply having another School Management Software isn’t enough.</p><p>What matters is solving real school problems.</p><p>VennsilixCampus aims to stand out through its <strong>strong features, broad school-management coverage, mobile accessibility and continuous development</strong>.</p><p><strong>VennsilixCampus™ — one platform for managing complete school operations.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a0b011118422" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[VennsilixCampus : Strong School Management Software Built to Run Complete School Operations]]></title>
            <link>https://medium.com/@sureshkumar_95502/vennsilixcampus-strong-school-management-software-built-to-run-complete-school-operations-f06dab44a819?source=rss-68f0c1676484------2</link>
            <guid isPermaLink="false">https://medium.com/p/f06dab44a819</guid>
            <category><![CDATA[school-erp-cloud]]></category>
            <category><![CDATA[vennsilix-technologies]]></category>
            <category><![CDATA[school-managementsoftware]]></category>
            <category><![CDATA[school-erp-management]]></category>
            <category><![CDATA[vennsilixcampus]]></category>
            <dc:creator><![CDATA[Suresh Kumar]]></dc:creator>
            <pubDate>Wed, 09 Sep 2026 07:45:29 GMT</pubDate>
            <atom:updated>2026-09-09T07:45:29.419Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YmuzuifStNVJWYG_AhO30g.png" /><figcaption>VennsilixCampus — Complete School Management Platform(developed by Vennsilix Technologies Private Limited)</figcaption></figure><p>When I started thinking about what a modern school really needs from technology, I realized something simple.</p><p><strong><em>A school doesn’t need ten different software products for ten different jobs.</em></strong></p><p>It needs <strong>one strong platform that can bring its day-to-day operations together.</strong></p><p>That is the idea behind <strong>VennsilixCampus™</strong> — a complete <strong>School Management Software</strong> and <strong>School ERP</strong> designed to help schools manage their operations from admission to academics, attendance to examinations, fees to communication, and much more.</p><p>VennsilixCampus™ is a product of <strong>Vennsilix Technologies Private Limited, Bangalore</strong>, built with a very practical objective: <strong>make school management simpler, more organized and more technology-driven.</strong></p><h3><strong>Why VennsilixCampus?</strong></h3><p>There are many School ERP products available today.</p><p>But while building VennsilixCampus<strong>™</strong>, the focus was not simply on adding a few popular modules and calling it a School ERP.</p><p>The focus was on building <strong>strong features across the complete school operation</strong>.</p><p>A school has hundreds of activities happening every day.</p><p>Students have to be admitted.</p><p>Classes have to be organized.</p><p>Teachers need timetables and attendance tools.</p><p>Homework has to reach students.</p><p>Examinations have to be conducted and results managed.</p><p>Fees have to be collected and tracked.</p><p>Parents need regular communication.</p><p>Management needs reports.</p><p>Staff, transport, hostel, inventory and other administrative activities also need attention.</p><p>VennsilixCampus<strong>™</strong> brings these areas together in one platform.</p><h4><strong>VennsilixCampus — One platform for end-to-end school operations</strong></h4><p>The strongest part of VennsilixCampus is its <strong>breadth of features</strong>.</p><p>It is designed to support the complete school management lifecycle rather than focusing on only one or two areas.</p><p>Some of the important areas include:</p><ul><li><strong>Student Admission Management</strong></li><li><strong>Student &amp; Parent Management</strong></li><li><strong>Attendance Management</strong></li><li><strong>Timetable Management</strong></li><li><strong>Homework Management</strong></li><li><strong>Examination Management</strong></li><li><strong>Online Examinations</strong></li><li><strong>Marks &amp; Results Management</strong></li><li><strong>Fee Management &amp; Collection</strong></li><li><strong>Fee Reminders</strong></li><li><strong>WhatsApp Communication</strong></li><li><strong>Internal Messaging</strong></li><li><strong>Leave Management</strong></li><li><strong>School Calendar</strong></li><li><strong>Holiday Management</strong></li><li><strong>Library Management</strong></li><li><strong>Inventory &amp; Invoice Management</strong></li><li><strong>Staff &amp; Salary Management</strong></li><li><strong>Vendor Payments</strong></li><li><strong>Transport Management</strong></li><li><strong>Hostel Management</strong></li><li><strong>Gate Pass Management</strong></li><li><strong>Special Education / CWSN Management</strong></li><li><strong>Reports &amp; Dashboards</strong></li><li><strong>Biometric Attendance Integration</strong></li><li><strong>Online Classes &amp; Video Meeting Integration</strong></li><li><strong>Mobile Apps for School Users</strong></li></ul><p>The intention is to keep expanding the platform as schools identify new requirements.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f06dab44a819" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI ML Interview Questions]]></title>
            <link>https://medium.com/@sureshkumar_95502/ai-ml-interview-questions-1d06a5ef5c79?source=rss-68f0c1676484------2</link>
            <guid isPermaLink="false">https://medium.com/p/1d06a5ef5c79</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[genai]]></category>
            <category><![CDATA[prompt-engineering]]></category>
            <category><![CDATA[ai-ml-interview-question]]></category>
            <category><![CDATA[machine-learning-ai]]></category>
            <dc:creator><![CDATA[Suresh Kumar]]></dc:creator>
            <pubDate>Tue, 10 Jun 2025 09:40:39 GMT</pubDate>
            <atom:updated>2025-06-10T09:45:04.452Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="AI ML Interview questions" src="https://cdn-images-1.medium.com/max/750/1*dfEBTIydYzlMVnghwHGFvg.jpeg" /><figcaption>AI ML Interview Questions</figcaption></figure><p>This post covers AI(Artificial Intelligence) &amp; ML(Machine Learning) interview related questions, useful for all Software Developers, Testers and even non-Techies</p><p>What is Prompt Engineering?</p><p>A. Training new models<br>B. Designing model architecture<br>C. Crafting effective inputs for AI<br>D. Cleaning training data<br><strong>Answer: </strong>C. Crafting effective inputs for AI<br><strong>Explanation:</strong><br>Prompt engineering is the practice of designing well-structured prompts to guide AI models (like ChatGPT) in producing accurate and useful responses.</p><p><strong>What is an AI model?<br></strong>A. A hardware device<br>B. A trained algorithm to make predictions<br>C. A coding language<br>D. None of them<br><strong>Answer:</strong> B. A trained algorithm to make predictions<br><strong>Explanation:</strong><br>An AI model is an algorithm trained on data to recognize patterns and make decisions or predictions, such as classifying images or generating text.</p><p><a href="https://www.udemy.com/course/ai-ml-core-concepts-practice-test/?referralCode=4C5B7E8A44C14BA3E97D">Click here for full set of AI/ML interview Questions</a></p><p><strong>Which data structure is used in Pandas to store tabular data?<br></strong>A. Array<br>B. List<br>C. DataFrame<br>D. Tuple<br><strong>Answer: </strong>C. DataFrame<br><strong>Explanation:</strong><br>A DataFrame is a 2D table with labeled axes (rows and columns), widely used in AI/ML data workflows.</p><p><strong>Which library is primarily used for machine learning in Python?<br></strong>A. Matplotlib<br>B. Flask<br>C. Scikit-learn<br>D. OpenCV<br><strong> Answer:</strong> C. Scikit-learn<br><strong>Explanation:</strong><br>Scikit-learn provides tools for model building, training, evaluation, and preprocessing in ML.</p><p><strong>What is the basic unit of a neural network called?<br></strong>A. Neuron<br>B. Node<br>C. Perceptron<br>D. All of the above<br><strong>Answer:</strong> D. All of the above<br><strong>Explanation:</strong><br>A neural network is made up of basic units known as neurons, also called nodes or perceptrons in different contexts. They mimic brain cells in processing inputs and generating outputs.</p><p><strong>What is the full form of LLM in the context of Artificial Intelligence?<br></strong>A. Long Language Model<br>B. Large Language Model<br>C. Logical Learning Model<br>D. Linguistic Learning Machine<br><strong>Answer: </strong>B. Large Language Model<br><strong>Explanation:</strong><br>A Large Language Model (LLM) is a type of AI model trained on massive text data to understand and generate human-like language.<br>Its purpose is to perform tasks like answering questions, translating languages, writing content, summarizing, and more using natural language.</p><p><strong>Which one is NOT a common use case of AI?<br></strong>A. Image recognition<br>B. Natural language processing<br>C. Web hosting<br>D. Chatbots<br><strong>Answer:</strong> C. Web hosting<br><strong>Explanation:</strong><br>Web hosting is an infrastructure service, not a typical AI application.</p><p><strong>What does Generative AI primarily do?<br></strong>A. Store data<br>B. Classify images<br>C. Generate new content<br>D. Delete information<br><strong>Answer:</strong> C. Generate new content<br><strong>Reasoning:</strong> GenAI creates new data (text, image, etc.) not just classifies or stores it</p><p><a href="https://www.udemy.com/course/ai-ml-core-concepts-practice-test/?referralCode=4C5B7E8A44C14BA3E97D">To try more questions on AI/ML, please click here</a></p><p><a href="https://www.udemy.com/course/ai-ml-core-concepts-practice-test/?referralCode=4C5B7E8A44C14BA3E97D">This AI &amp; ML cover sub topics such as AI Models, LLMs, Neural Networks, GenAI, Prompt Engineering, Knowledge Representation, etc…</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1d06a5ef5c79" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI Won’t Replace Programmers]]></title>
            <link>https://medium.com/@sureshkumar_95502/ai-wont-replace-programmers-c2580057c3c1?source=rss-68f0c1676484------2</link>
            <guid isPermaLink="false">https://medium.com/p/c2580057c3c1</guid>
            <category><![CDATA[ai-programming]]></category>
            <category><![CDATA[java-programming-course]]></category>
            <category><![CDATA[learn-programming]]></category>
            <category><![CDATA[ai-era-programming]]></category>
            <category><![CDATA[ai-useful-in-programming]]></category>
            <dc:creator><![CDATA[Suresh Kumar]]></dc:creator>
            <pubDate>Wed, 18 Dec 2024 17:59:34 GMT</pubDate>
            <atom:updated>2024-12-18T17:59:34.457Z</atom:updated>
            <content:encoded><![CDATA[<p>In the current AI-driven world, the landscape of technology is rapidly evolving. But does that mean you still need to learn programming? The short answer is YES, and this answer is true for atleast next few decades, and here’s why:</p><p><strong>1. AI Still Needs Human Control</strong><br>- AI is incredibly powerful, but it lacks the ability to think creatively, make complex decisions, or innovate without human input.<br>- Programming skills give you the control to shape AI tools, ensuring they are used in ways that align with your goals.</p><p><strong>2. With Programming skills, You’ll Stand Out in the Job Market</strong><br>- Automation and AI are reshaping industries, but programming remains one of the most in-demand skills across fields like tech, finance, healthcare, and more.<br>- Learning programming enables you to build your own AI solutions or work alongside AI systems effectively.</p><figure><img alt="ai will not replace programmer" src="https://cdn-images-1.medium.com/max/640/1*5aABjr05Fl-BfGf6pSRnTQ.jpeg" /><figcaption>AI in Software Sevelopment</figcaption></figure><p><a href="https://www.udemy.com/course/learn-complete-core-java-with-practical-examples/?referralCode=23FBECFFBB7A620AF30E">Learn Java Programming with 40 Hours Video, 100’s of downloadable code samples, assignments/exercises, total 120 hours of Learning</a></p><p><strong>3. It’s Easier Than You Think</strong><br>- Programming is more accessible than ever. Languages like Python(or Java) are beginner-friendly and widely used in AI development.<br>- Online platforms offer free resources to get you started with coding, and a wide community of developers is there to support you.</p><p><strong>4. Gain a Competitive Edge</strong><br>- Even in non-technical roles, understanding the basics of coding and AI helps you communicate effectively with technical teams and understand their processes.<br>- You’ll be better equipped to spot opportunities and challenges AI can bring to your work.</p><p><strong>5. Build Your Own Projects</strong><br>- Why rely solely on third-party AI solutions when you can build your own? Programming empowers you to create tailored applications, apps, or even personal AI models.<br>- Control your projects and be innovative without waiting for tech giants to offer ready-made solutions.</p><p><a href="https://www.udemy.com/course/learn-complete-core-java-with-practical-examples/?referralCode=23FBECFFBB7A620AF30E">Learn Java Programming with 40 Hours Video, 100’s of downloadable code samples, assignments/exercises, total 120 hours of Learning</a></p><p><strong>Key Takeaways:</strong><br>AI boosts productivity by automating coding tasks and suggesting optimizations.<br>It accelerates the coding process, making developers more efficient and less prone to errors.<br>By enhancing tools and workflows, AI is making programming easier and faster for both beginners and experts.</p><p>In this era, programming is not just for techies. It’s a valuable skill for everyone in the AI-driven world. So, why wait? Start coding today!</p><p>While AI will continue to automate many aspects of programming, programmers are not going anywhere anytime soon. The most likely scenario is that AI will enhance human capabilities in coding rather than replace human programmers entirely, at least for the next few decades. So, learning programming remains a valuable skill.</p><p><a href="https://www.udemy.com/course/learn-complete-core-java-with-practical-examples/?referralCode=23FBECFFBB7A620AF30E">Learn Java Programming with 40 Hours Video, 100’s of downloadable code samples, assignments/exercises, total 120 hours of Learning</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c2580057c3c1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unveiling the Power of Java’s Object Class]]></title>
            <link>https://medium.com/@sureshkumar_95502/unveiling-the-power-of-javas-object-class-a9126dc1f29d?source=rss-68f0c1676484------2</link>
            <guid isPermaLink="false">https://medium.com/p/a9126dc1f29d</guid>
            <category><![CDATA[java-getclass-reflection]]></category>
            <category><![CDATA[override-java-tostring]]></category>
            <category><![CDATA[methods-in-java-object]]></category>
            <category><![CDATA[override-equals-hashcode]]></category>
            <category><![CDATA[java-object-class]]></category>
            <dc:creator><![CDATA[Suresh Kumar]]></dc:creator>
            <pubDate>Wed, 18 Dec 2024 13:45:32 GMT</pubDate>
            <atom:updated>2024-12-18T13:45:32.807Z</atom:updated>
            <content:encoded><![CDATA[<h3>“Unveiling the Power of Java’s Object Class: What Every Developer Should Know”</h3><p>In the vast world of Java, the java.lang.Object class is at the very core of every object-oriented program. It is the parent class of every class in Java (except java.lang.Object itself). Despite its ubiquitous presence, many Java developers don’t fully understand the full range of features, methods, and nuances that Object class offers. This post gives you insight by providing indepth exploration of the Object class, focusing on its hidden gems, pitfalls, and best practices.</p><figure><img alt="Java base class Object" src="https://cdn-images-1.medium.com/max/640/1*TKnFYGI4sKespZZDoFpbBw.jpeg" /><figcaption>Java Object class</figcaption></figure><h4>What is the java.lang.Object Class?</h4><p>In Java, every class is implicitly a subclass of java.lang.Object. When you create a new class, the Object class serves as the default parent. This gives every Java object access to a set of essential methods that are built into Object. These methods some times are invoked implicityly, without we invoking and play a crucial role in object comparison, hashing, and many other fundamental operations.</p><p>The Object class is the foundation of object management in Java. This class is located in the java.lang package, which is automatically imported, so you don’t need to explicitly import it in your Java programs.</p><h4>Important Methods of java.lang.Object class</h4><p>The Object class has several methods, and understanding them is crucial for mastering Java. Here is a detailed look at each one, along with examples.</p><h4>1. equals(Object obj)</h4><p>The equals() method determines if two objects are considered equal. By default, equals() compares object references, meaning it checks if two references point to the same memory location. However, it is often overridden in custom classes to compare the actual content of objects.</p><pre>class Person {<br> private String name;<br> private int age;<br><br>Person(String name, int age) {<br>   this.name = name;<br>   this.age = age;<br> }<br><br>@Override<br> public boolean equals(Object obj) {<br>   if (this == obj) return true;<br><br>   if (obj == null || getClass() != obj.getClass()) return false;<br><br>   Person person = (Person) obj;<br>   return age == person.age &amp;&amp; name.equals(person.name);<br>   }<br>}<br><br>public class Main {<br>   public static void main(String[] args) {<br>     Person p1 = new Person(&quot;Alice&quot;, 30);<br>     Person p2 = new Person(&quot;Alice&quot;, 30);<br>     System.out.println(p1.equals(p2)); // true<br>   }<br>}</pre><p><strong>Common Pitfall: </strong><br>If equals() is overridden, hashCode() should also be overridden to maintain the contract between equals() and hashCode(), as detailed below.</p><h4>2. hashCode()</h4><p>The hashCode() method provides a hash code that is used in hash-based collections like HashMap and HashSet. It must be overridden when equals() is overridden to ensure that objects which are considered equal have the same hash code.</p><pre>@Override<br>public int hashCode() {<br> return Objects.hash(name, age); // Using the utility class Objects for convenience<br>}</pre><p><strong>Common Pitfall:</strong><br>If two objects are equal according to equals(), their hashCode() method must return the same value. This ensures that objects are correctly placed in hash-based collections.</p><h4>3. toString()</h4><p>The toString() method returns a string representation of the object. By default, it returns the class name followed by the “@” symbol and the object’s memory address (hash code). It is highly recommended to override toString() to provide meaningful information about the object.</p><pre>@Override<br>public String toString() {<br> return &quot;Person{name=&#39;&quot; + name + &quot;&#39;, age=&quot; + age + &quot;}&quot;;<br>}</pre><p><strong>Common Pitfall:</strong><br>Failing to override toString() results in generic output like Person@12345678, which is not very helpful for debugging.</p><h4>4. getClass()</h4><p>The getClass() method returns the Class object associated with the current instance. This is final method and cannot be overridden in your class. This method is often used for reflection or to retrieve metadata about the object’s type.</p><pre>Person p = new Person(&quot;Alice&quot;, 30);<br>System.out.println(p.getClass().getName()); // java.lang.Person</pre><h4>5. clone()</h4><p>The clone() method is used to create and return a copy of the current object. This method requires that the class implements Cloneable, otherwise it throws CloneNotSupportedException.</p><pre>class Person implements Cloneable {<br> private String name;<br> private int age;<br><br>public Person(String name, int age) {<br> this.name = name;<br> this.age = age;<br> }<br><br>@Override<br> protected Object clone() throws CloneNotSupportedException {<br> return super.clone(); // Creates a shallow copy<br> }<br>}</pre><p><strong>Common Pitfall:</strong><br>clone() is shallow by default, meaning it doesn’t clone the objects referenced by the current object. If deep cloning is needed, it must be implemented manually.</p><h4>6. finalize()</h4><p>The finalize() method is called by the garbage collector when an object is about to be destroyed. This is final method and cannot be overridden in your class. It is provided as a last chance for an object to release resources (e.g., closing file handles or network connections). Overriding finalize() improperly may adversely affect onoverall performance of your Program.</p><pre>@Override<br>protected void finalize() throws Throwable {<br> System.out.println(&quot;Object is being finalized&quot;);<br> super.finalize();<br>}</pre><p><strong>Common Pitfall:</strong><br>finalize() is not guaranteed to be called, and its execution may be delayed. It is usually better to use try-with-resources or Closeable/AutoCloseable for resource management.</p><h4>7. notify(), notifyAll(), wait(), wait(long timeout), wait(long timeout, int nanos)</h4><p>These methods are used for inter-thread communication in multi-threaded environments. These are final methods and cannot be overridden in your class. They are essential for creating synchronized blocks or managing complex thread interactions.</p><pre>public class Counter {<br> private int count = 0;<br>public synchronized void increment() throws InterruptedException {<br> while (count &gt;= 10) {<br> wait();<br> }<br> count++;<br> notify();<br> }<br>}</pre><p><strong>Common Pitfall:</strong><br>These methods must be called from within a synchronized block or method to work correctly. Misusing them can result in deadlocks or missed signals.</p><h4>8. notifyAll()</h4><p>This method wakes up all threads that are waiting on the object’s monitor (lock). It’s useful when multiple threads are waiting on the same condition.</p><pre>public synchronized void resetCounter() {<br> count = 0;<br> notifyAll(); // Notify all waiting threads<br>}</pre><h4>9. wait(long timeout)</h4><p>The wait(long timeout) method pauses the execution of the current thread until either a notification occurs (notify(), notifyAll()) or the timeout period elapses.</p><pre>public synchronized void checkCounter() throws InterruptedException {<br> while (count &lt; 5) {<br> wait(1000); // Wait for up to 1 second<br> }<br> System.out.println(&quot;Counter reached 5!&quot;);<br>}</pre><p><strong>Common Pitfall:</strong><br>Always ensure proper synchronization when using wait() and notify() methods to avoid race conditions.</p><h4>Object class Best Practices and Common Pitfalls</h4><p>1. equals() and hashCode() Contract:<br> — Always override both equals() and hashCode() together. Failing to do so can lead to subtle bugs, especially when objects are used in hash-based collections.<br> <br>2. Avoid Using finalize():<br> — The finalize() method is unreliable. Instead of relying on it for resource cleanup, use try-with-resources or implement AutoCloseable.</p><p>3. clone() Implementation:<br> — The default clone() method is shallow. For deep cloning, you’ll need to override it and manually clone the fields that are objects themselves.</p><p>4. Synchronization Pitfalls:<br> — When using wait(), notify(), or notifyAll(), always ensure that these methods are invoked within a synchronized block to avoid IllegalMonitorStateException.</p><p>5. Use of getClass():<br> — Be cautious when using getClass() for logic that depends on the object’s type. This can break polymorphism, and it’s generally better to use interfaces and method overriding for object behavior.</p><p><strong>Conclusion</strong></p><p>The java.lang.Object class is fundamental to understanding Java’s object-oriented programming model. By leveraging the methods provided by Object, you can manage object identity, equality, cloning, and synchronization efficiently. While it may seem like a basic class at first, understanding the nuances and best practices of Object can make you a much more effective Java developer.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a9126dc1f29d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unleash Java: Launch Any Program with a Simple Configuration]]></title>
            <link>https://medium.com/@sureshkumar_95502/unleash-java-launch-any-program-with-a-simple-configuration-925e4327470c?source=rss-68f0c1676484------2</link>
            <guid isPermaLink="false">https://medium.com/p/925e4327470c</guid>
            <category><![CDATA[java-runtime-exec]]></category>
            <category><![CDATA[real-power-of-java]]></category>
            <category><![CDATA[java-schedule-programs]]></category>
            <category><![CDATA[run-any-program-from-java]]></category>
            <category><![CDATA[run-notepad-java]]></category>
            <dc:creator><![CDATA[Suresh Kumar]]></dc:creator>
            <pubDate>Tue, 17 Dec 2024 17:52:41 GMT</pubDate>
            <atom:updated>2024-12-17T17:52:41.003Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog post, we’ll walk through how to launch a program like Notepad from a Java application. Then, we’ll make the process more flexible by allowing you to launch any application on a Windows machine, configurable via properties. Finally, we’ll extend this functionality to support multiple operating systems, so you can launch applications cross-platform (Windows, Linux, macOS) using the same program.</p><h4>Step 1: Launch Notepad from Java</h4><p>First, let’s write a simple Java program that launches Notepad on a Windows machine. We will use Java’s Runtime.exec() method. Runtime.exec() lets us execute system commands like opening Notepad.</p><p><strong>Basic Code to Launch Notepad:</strong></p><pre>public class ProgramLauncher {<br>  public static void main(String[] args) {<br>     try {<br>       // Command to launch Notepad<br>       String command = &quot;C:/Windows/System32/notepad.exe&quot;;<br>       Process process = Runtime.getRuntime().exec(command);<br>       process.waitFor(); // Wait for Notepad to finish<br>     } catch (Exception e) {<br>       System.err.println(&quot;Error: &quot; + e.getMessage());<br>     }<br>   }<br>}</pre><p>This will open Notepad on a Windows machine. It’s a simple and straightforward approach, but what if we want to make this more flexible and configurable?</p><h4>Step 2: Make It Configurable for Any Program on Windows</h4><p>To make this program more flexible, we can store the application path and name in a properties file, so it can be easily modified without changing the Java code.</p><p><strong>config.properties File:</strong></p><pre>program.path=C:/Windows/System32/<br>program.name=notepad.exe</pre><p>Updated Code to Read From above Properties file:</p><pre>import java.io.FileInputStream;<br>import java.io.IOException;<br>import java.util.Properties;<br><br>public class ProgramLauncher {<br>   // Load properties from config file<br>   private static Properties loadProperties() throws IOException {<br>     Properties properties = new Properties();<br>     try (FileInputStream input = new FileInputStream(&quot;config.properties&quot;)) {<br>     properties.load(input);<br>     }<br>     return properties;<br>     }<br><br>  public static void main(String[] args) {<br>     try {<br>       // Load the program path and name from properties<br>       Properties properties = loadProperties();<br>       String programPath = properties.getProperty(&quot;program.path&quot;);<br>       String programName = properties.getProperty(&quot;program.name&quot;);<br>       <br>       // Construct the full command<br>       String command = programPath + programName;<br>      // Launch the program<br>       Process process = Runtime.getRuntime().exec(command);<br>       process.waitFor(); // Wait for the process to finish<br>      } catch (Exception e) {<br>       System.err.println(&quot;Error: &quot; + e.getMessage());<br>       }<br>     }<br>    }</pre><p>With this approach, you can change the program.path and program.name in the config.properties file to launch any program on your Windows machine, without modifying the Java code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*uIUhkb-l3BCARelWyyo2Ag.jpeg" /><figcaption>How to use Runtime.getRuntime().exec()</figcaption></figure><h4>Step 3: Make It Cross-Platform (Windows, Linux, macOS)</h4><p>Now, lets make the program cross-platform so that it works not only on Windows but also on Linux and macOS. To do this, lets detect the operating system and adjust the command accordingly.</p><p><strong>Updated Code for Cross-Platform Support:</strong></p><pre>import java.io.FileInputStream;<br>import java.io.IOException;<br>import java.util.Properties;<br><br>public class ProgramLauncher {<br>  // Load properties from config file<br>   private static Properties loadProperties() throws IOException {<br>     Properties properties = new Properties();<br>     try (FileInputStream input = new FileInputStream(&quot;config.properties&quot;)) {<br>     properties.load(input);<br>     }<br>     return properties;<br>   }<br><br>// Launch the program based on OS<br> public static void launchProgram(Properties properties) {<br>   String osName = System.getProperty(&quot;os.name&quot;).toLowerCase();<br>   String programPath = properties.getProperty(&quot;program.path&quot;);<br>   String programName = properties.getProperty(&quot;program.name&quot;);<br>  try {<br>     String command = &quot;&quot;;<br>    if (osName.contains(&quot;win&quot;)) {<br>     // Windows command<br>     command = programPath + programName;<br>     } else if (osName.contains(&quot;nix&quot;) || osName.contains(&quot;nux&quot;) || osName.contains(&quot;mac&quot;)) {<br>     // Linux/macOS command<br>     if (osName.contains(&quot;nix&quot;) || osName.contains(&quot;nux&quot;)) {<br>     command = &quot;xdg-open &quot; + programName; // Linux command<br>     } else if (osName.contains(&quot;mac&quot;)) {<br>     command = &quot;open &quot; + programName; // macOS command<br>     }<br>     }<br>    // Execute the command<br>     if (!command.isEmpty()) {<br>     Process process = Runtime.getRuntime().exec(command);<br>     process.waitFor(); // Wait for the process to finish<br>     } else {<br>     System.err.println(&quot;Unsupported OS.&quot;);<br>     }<br>  } catch (Exception e) {<br>   System.err.println(&quot;Error: &quot; + e.getMessage());<br>   }<br>   }<br><br>  public static void main(String[] args) {<br>     try {<br>       // Load properties from the config file<br>       Properties properties = loadProperties();<br>      // Launch the program based on the configured properties<br>       launchProgram(properties);<br>    } catch (IOException e) {<br>       System.err.println(&quot;Error loading configuration: &quot; + e.getMessage());<br>     }<br>   }<br>}</pre><p>config.properties File for Cross-Platform Support:</p><pre># Windows Configuration<br>program.path=C:/Program Files/Microsoft Office/root/Office16/<br>program.name=EXCEL.EXE<br># Linux/macOS Configuration (will be handled automatically based on OS)<br># On Linux, you can set it to &#39;xdg-open&#39; or specific programs like &#39;libreoffice&#39;<br># On macOS, &#39;open&#39; command will be used</pre><p>How It Works:<br>1. Windows: If the program detects that it is running on a Windows machine, it uses the provided path and executable name (e.g., `EXCEL.EXE`).<br>2. Linux: If it’s running on a Linux machine, it uses `xdg-open` to open the program, which can work with many file types and applications.<br>3. macOS: For macOS, it uses the `open` command, which is a standard way to launch applications like `TextEdit`, `Microsoft Excel.app`, or any other installed app.</p><p><strong>Conclusion</strong></p><p>We have developed a flexible Java program that can:<br>Launch Notepad on Windows.</p><p>Launch any application by configuring the path and executable name via a properties file.</p><p>Support multiple platforms (Windows, Linux, macOS), allowing you to launch programs seamlessly across different operating systems.</p><p>By simply adjusting the config.properties file, you can now launch any program on your system, and the same program will work on Windows, Linux, and macOS without any additional changes. This makes the solution highly adaptable and easy to maintain.</p><p><strong>Where is this approach useful?</strong><br>It can be applied in a variety of real-world scenarios. For instance, it can be used in automation scripts to launch specific applications across different operating systems, making it useful in software deployment or system setup processes. It can also serve in enterprise applications where users need to open tools like Excel or text editors automatically based on predefined configurations. Additionally, it can be incorporated into custom workflow applications, where specific programs need to be triggered based on user actions or scheduled tasks.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=925e4327470c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to fix StackOverflowError in Java?]]></title>
            <link>https://medium.com/@sureshkumar_95502/how-to-fix-stackoverflowerror-in-java-62c7972788db?source=rss-68f0c1676484------2</link>
            <guid isPermaLink="false">https://medium.com/p/62c7972788db</guid>
            <category><![CDATA[java-method-calls]]></category>
            <category><![CDATA[java-infinite-recursion]]></category>
            <category><![CDATA[stackoverflowerror]]></category>
            <category><![CDATA[java-stackoverflowerror]]></category>
            <category><![CDATA[java-stackoverflow]]></category>
            <dc:creator><![CDATA[Suresh Kumar]]></dc:creator>
            <pubDate>Mon, 16 Dec 2024 04:04:59 GMT</pubDate>
            <atom:updated>2024-12-16T04:04:59.743Z</atom:updated>
            <content:encoded><![CDATA[<h4>What is StackOverflowError?</h4><p>A StackOverflowError in Java is a runtime error or exception that occurs when program’s call stack exceeds its allocated memory limit. Call stack is a special memory region used for managing method invocations and local variables. When too many nested calls or excessive memory usage occur in the stack, the JVM throws StackOverflowError.</p><figure><img alt="How to resolve StackOverflowerror in Java?" src="https://cdn-images-1.medium.com/max/640/1*PfJt0efP8ZHj0ZZ92JKzaw.jpeg" /><figcaption>Java StackOverflowError</figcaption></figure><h4>What is stack frame and what it contains?</h4><p>A Frame is allocated on Call stack, whenever a method is called. This Stack frame stores method parameters, local variables of the method. And whenever a method returns, Frame is deleted from Stack. When a method calls another method, without returning, previous Frame is not deleted, but a new Frame is created above previous Frame. There is a limit on overall size of Stack, and depends on multiple factors such as JVM implementation, the operating system, and the value of ‘-Xss’. Hence, it may get full when used excessively, and that is when StackOverflowError is thrown by JVM.</p><p><a href="https://www.udemy.com/course/learn-complete-core-java-with-practical-examples/?referralCode=23FBECFFBB7A620AF30E">Enroll for Core Java with 40 Hours of Video, Source code samples, reading material, practice questions. Total about 120 Learning hours.</a></p><h4>Below Situations causes StackOverflowError</h4><p>1. Unbounded Recursion<br>A common cause is a method that calls itself indefinitely without a termination condition.</p><p>Example:</p><pre>public class RecursionExample {<br> public static void main(String[] args) {<br>   infiniteRecursion();<br> }<br><br> public static void infiniteRecursion() {<br>   infiniteRecursion(); // No termination condition<br> }<br>}</pre><p>Fix: Ensure recursive functions have a proper base case to terminate.</p><pre>public static void finiteRecursion(int n) {<br> if (n == 0) return; // Base case<br> finiteRecursion(n - 1);<br>}</pre><p>2. Deeply Nested Method Calls<br>Excessive nesting of method calls can exhaust the stack.</p><p>Example:</p><pre>public class NestedCalls {<br> public static void main(String[] args) {<br> method1();<br> }<br>public static void method1() {<br> method2();<br> }<br>public static void method2() {<br> method1();<br> }<br>}</pre><p>Fix: Refactor code to avoid circular or deeply nested calls.</p><p><a href="https://www.udemy.com/course/learn-complete-core-java-with-practical-examples/?referralCode=23FBECFFBB7A620AF30E">Enroll for Core Java with 40 Hours of Video, Source code samples, reading material, practice questions. Total about 120 Learning hours.</a></p><p>3. Excessive Object Instantiation in Constructor Chaining<br>Recursive or circular calls in constructors can lead to this error.</p><p>Example:</p><pre>public class Check { <br> public Check() {<br> new Check(); //constructor instantiating itself, gets into infinite recursion<br> }<br> <br> public static void main(String args[]) {<br> new Check();<br> }<br>}</pre><p>Fix: Ensure constructors do not instantiate themselves.</p><p>4. Avoid using too many Local variables or large local variables, this may fillup Stack faster.</p><p><strong>How to configure Stack size of Java program?</strong><br>Sometimes, you maybe legitimately invoking required method calls in best possible way, and still it may result in StackOverflowError. In such cases you can configure the stack size using the `-Xss` JVM option:</p><p>java -Xss512k YourProgram<br>java -Xss1m YourProgram</p><p><a href="https://www.udemy.com/course/learn-complete-core-java-with-practical-examples/?referralCode=23FBECFFBB7A620AF30E">Enroll for Core Java with 40 Hours of Video, Source code samples, reading material, practice questions. Total about 120 Learning hours.</a></p><p><strong>How to find depth of stack</strong></p><pre>public class CallStackSize {<br>private static int depth = 0;<br>public static void recursiveMethod() {<br> depth++;<br> recursiveMethod(); // Continue calling until StackOverflowError<br> }<br>public static void main(String[] args) {<br> try {<br> recursiveMethod();<br> } catch (StackOverflowError e) {<br> System.out.println(&quot;Maximum stack depth: &quot; + depth);<br> }<br> }<br>}</pre><p>Above approach gives you an estimate of the maximum number of method calls the stack can handle. Also, size of each method call’s stack frame affects this number.</p><p><a href="https://www.udemy.com/course/java-full-stack-exam-practice-test-interview-questions/?referralCode=D84EECB3288F42E25923">Java Full Stack Interview Questions</a></p><p><strong>Best Practices to Prevent StackOverflowError</strong><br>1. Avoid Infinite Recursion: Always implement a base case in recursive methods.<br>2. Optimize Recursion Depth: Convert recursive algorithms to iterative ones where feasible.<br>3. Analyze Call Hierarchies: Identify and refactor deep or circular method calls.<br>4. Limit Stack Usage: Avoid large local variables; use the heap for substantial data structures.<br>5. Tune Stack Size: Adjust stack size with -Xss based on application needs.</p><p><a href="https://www.udemy.com/course/learn-complete-core-java-with-practical-examples/?referralCode=23FBECFFBB7A620AF30E">Enroll for Core Java with 40 Hours of Video, Source code samples, reading material, practice questions. Total about 120 Learning hours.</a></p><p><strong>Debugging StackOverflowError</strong><br>1. Examine Stack Trace: Identify the sequence of method calls leading to the error.</p><pre>try {<br> recursiveMethod();<br> } catch (StackOverflowError e) {<br> e.printStackTrace();<br> }</pre><p>2. Profiler Tools: Use tools like VisualVM or JProfiler to analyze call stacks.<br>3. Enable Logging: Log method entries and exits to identify problematic code paths.</p><p>By understanding the causes and solutions for StackOverflowError, you can design more robust Java applications and troubleshoot errors effectively.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=62c7972788db" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java, Call by Value or Call by Reference]]></title>
            <link>https://medium.com/@sureshkumar_95502/java-call-by-value-or-call-by-reference-df73a8d7fbe9?source=rss-68f0c1676484------2</link>
            <guid isPermaLink="false">https://medium.com/p/df73a8d7fbe9</guid>
            <category><![CDATA[java-call-by-value]]></category>
            <category><![CDATA[java-primitive-parameter]]></category>
            <category><![CDATA[java-object-parameter]]></category>
            <category><![CDATA[java-parameter]]></category>
            <category><![CDATA[java-call-by-reference]]></category>
            <dc:creator><![CDATA[Suresh Kumar]]></dc:creator>
            <pubDate>Sun, 15 Dec 2024 12:10:59 GMT</pubDate>
            <atom:updated>2024-12-15T12:10:59.366Z</atom:updated>
            <content:encoded><![CDATA[<h4>Java uses Call by Value or Call by Reference?</h4><p>This blog post gives more clarity on whether Java uses Call by Value or Call by Reference or some other approach, when passing parameters. This post also covers how Java handles different types of parameters, including primitives, objects, and arrays.</p><p>Does Java Use Call by Value or Call by Reference?</p><p>Java strictly uses, Call by Value. This means that when you pass arguments to a method, a copy of the variable’s value is passed. However, how this depends on whether the variable is a primitive type or a reference type/array.</p><figure><img alt="Java Parameters are passed as Call by Value or Call by reference" src="https://cdn-images-1.medium.com/max/720/1*WnIuVBUcym45pvYD1kyQ1Q.png" /><figcaption>Java — Call by Value or Call by Reference</figcaption></figure><h4>Call by Value in Different Scenarios</h4><p>Java Primitive Types: <br>When a primitive type (e.g., int, double, boolean) is passed to a method, a copy of its value is made. Any changes to the parameter within the called method does not affect variable’s original value in calling method.</p><pre>public class PrimitiveExample {<br> public static void modifyPrimitive(int num) {<br> num = 42; // Changes local copy<br> }<br>public static void main(String[] args) {<br> int x = 10;<br> modifyPrimitive(x);<br> System.out.println(x); // Output: 10<br> }<br>}</pre><p>Explanation:The method modifyPrimitive(), receives a copy of value in `x`. Modifying `num` does not affect the original value of `x`.</p><p><a href="https://www.udemy.com/course/learn-complete-core-java-with-practical-examples/?referralCode=23FBECFFBB7A620AF30E">Click Here to Learn Core Java with 40 Hours of Video, Downloadable Source code examples, total about 120 hours of Learning</a></p><p>Java Reference Types (Objects):<br>When an object reference is passed, the method gets a copy of the reference. The method can modify the object’s state but cannot change the reference to point to some other object.</p><p>Explanation:The method receives a copy of the reference to `myObj`. Changes to the object’s state (e.g., setting `value = 42`) are visible outside the method.</p><pre>class MyObject {<br> int value;<br>}<br>public class ReferenceExample {<br> public static void modifyObject(MyObject obj) {<br> obj.value = 42; // Modifies the object&#39;s state<br> }<br>public static void main(String[] args) {<br> MyObject myObj = new MyObject();<br> myObj.value = 10;<br> modifyObject(myObj);<br> System.out.println(myObj.value); // Output: 42<br> }<br>}</pre><p>Java Arrays:<br>Array in Java, is actually an object, so array parameters follow the same behavior as reference types. Changes to array elements inside a method are reflected outside, but reassigning the array reference affects only the local copy.</p><pre>public class ArrayExample {<br> public static void modifyArray(int[] arr) {<br> arr[0] = 42; // Modifies the array element<br> arr = new int[]{7, 8, 9}; // Changes local reference only<br> }<br>public static void main(String[] args) {<br> int[] myArray = {1, 2, 3};<br> modifyArray(myArray);<br> System.out.println(myArray[0]); // Output: 42<br> }<br>}</pre><p>Explanation: The method receives a copy of the array reference. Changes to the array’s elements are reflected outside the method, but reassigning the array reference affects only the local copy.</p><p><a href="https://www.udemy.com/course/learn-complete-core-java-with-practical-examples/?referralCode=23FBECFFBB7A620AF30E">Click Here to Learn Core Java with 40 Hours of Video, Downloadable Source code examples, total about 120 hours of Learning</a><br>Summarizing<br>Primitive parameters uses Copy of value, original value is unaffected <br>Object parameters uses Copy of reference, can modify object’s state <br>Array parameters uses Copy of reference, can modify array elements</p><p>Hence,<br>1. Java always uses call by value.<br>2. For primitives, the value itself is copied.<br>3. For objects and arrays, the reference is copied, allowing modification of their contents but not reassignment.</p><p><a href="https://www.udemy.com/course/java-full-stack-exam-practice-test-interview-questions/?referralCode=D84EECB3288F42E25923">Click Here for Java Full Stack interview Questions</a></p><p>Above gives some clarity on Java using Call by value or reference, which helps developers to avoid unintended side effects and write more predictable source code</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df73a8d7fbe9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JUnit5 Cheatsheet]]></title>
            <link>https://medium.com/@sureshkumar_95502/junit5-cheatsheet-dac3d6f260b8?source=rss-68f0c1676484------2</link>
            <guid isPermaLink="false">https://medium.com/p/dac3d6f260b8</guid>
            <category><![CDATA[junit-annotations]]></category>
            <category><![CDATA[learn-junit5-in-15-mins]]></category>
            <category><![CDATA[junit5-reference]]></category>
            <category><![CDATA[junit5-cheat-sheet]]></category>
            <category><![CDATA[junit5-annotation]]></category>
            <dc:creator><![CDATA[Suresh Kumar]]></dc:creator>
            <pubDate>Sat, 14 Dec 2024 18:05:03 GMT</pubDate>
            <atom:updated>2024-12-14T18:05:03.562Z</atom:updated>
            <content:encoded><![CDATA[<h3>Learn JUnit5 in 15 minutes</h3><h4>JUnit5 Annotations</h4><p>This JUnit Cheatsheet briefs JUnit annotations, dependencies &amp; assertions, which are useful for your quick reference.</p><p>JUnit is a popular Unit Testing Framework, for Testing Java based applications.</p><p>Below are commonly used JUnit5 Annotation</p><h4>@Test JUnit Annotation</h4><p>@Test specifies a method as a Test case.</p><pre>@Test<br>void testExample() {<br> assertEquals(4, 2 + 2);<br>}</pre><h4>@BeforeEach JUnit Annotation</h4><p>Method annotated with @BeforeEach gets executed before each test method.</p><pre>@BeforeEach<br>void init() {<br> System.out.println(&quot;Test starting…&quot;);<br>}</pre><figure><img alt="JUnit5 Annotations Cheatsheet" src="https://cdn-images-1.medium.com/max/410/1*YUlJL3yHtwQp32Fiz_uJxg.png" /><figcaption>JUnit5 Cheat Sheet</figcaption></figure><h4>@AfterEach JUnit Annotation</h4><p>Method annotated with @AfterEach gets executed after each test method.</p><pre>@AfterEach<br>void cleanup() {<br> System.out.println(&quot;Test finished.&quot;);<br>}</pre><p><a href="https://www.udemy.com/course/learn-complete-core-java-with-practical-examples/?referralCode=23FBECFFBB7A620AF30E">Click Here to Learn Core Java with 40 Hours of Video, Downloadable Source code examples, total about 120 hours of Learning</a></p><h4>@BeforeAll JUnit Annotation</h4><p>Method annotated with @BeforeAll gets executed once before all tests @BeforeAll can be used only on static method.</p><pre>@BeforeAll<br>static void setup() {<br> System.out.println(&quot;Initializing resources…&quot;);<br>}</pre><h4>@AfterAll JUnit Annotation</h4><p>Method annotated with @AfterAll get executed once after all tests. @AfterAll can be applied only on static method.</p><pre>@AfterAll<br>static void teardown() {<br> System.out.println(&quot;Cleaning up resources…&quot;);<br>}</pre><h4>@DisplayName JUnit Annotation</h4><p>Assigns a custom name to the test method.</p><pre>@DisplayName(&quot;Test addition operation&quot;)<br>@Test<br>void testAddition() {<br> assertEquals(5, 2 + 3);<br>}</pre><h4>@Disabled JUnit Annotation</h4><p>Disables a test method or class.</p><pre>@Disabled(&quot;Not implemented yet&quot;)<br>@Test<br>void testFeature() {<br> // Test code<br>}</pre><p><a href="https://www.udemy.com/course/learn-complete-core-java-with-practical-examples/?referralCode=23FBECFFBB7A620AF30E">Click Here to Learn Core Java with 40 Hours of Video, Downloadable Source code examples, total about 120 hours of Learning</a></p><h4>@ParameterizedTest JUnit Annotation</h4><p>Method annotated with @ParameterizedTest automatically gets invoked with the Parameters(Test data) from some source(such as hardcoded or CSV format or returned by a method).</p><p>@ParameterizedTest annotation should also specify the source of parameters using any annotation such as @ValueSource, @CsvSource, @MethodSource</p><pre>@ParameterizedTest<br>@ValueSource(ints = {1, 2, 3, 4})<br>void testWithValues(int number) {<br> assertTrue(number &gt; 0);<br>}</pre><h4>@ValueSource JUnit Annotation</h4><p>@ValueSource should be used along with @ParameterizedTest. Provides a source of hardcoded values(or Test data) for parameterized tests.</p><pre>@ParameterizedTest<br>@ValueSource(strings = {&quot;apple&quot;, &quot;banana&quot;, &quot;cherry&quot;})<br>void testStrings(String fruit) {<br> assertNotNull(fruit);<br>}</pre><h4>@CsvSource JUnit Annotation</h4><p>Supplies multiple sets of arguments in CSV format.</p><pre>@ParameterizedTest<br>@CsvSource({&quot;apple,1&quot;, &quot;banana,2&quot;})<br>void testCsv(String fruit, int number) {<br> assertNotNull(fruit);<br> assertTrue(number &gt; 0);<br>}</pre><h4>@MethodSource JUnit Annotation</h4><p>Supplies arguments from a factory method.</p><pre>@ParameterizedTest<br>@MethodSource(&quot;provideNumbers&quot;)<br>void testWithMethodSource(int number) {<br> assertTrue(number &gt; 0);<br>}<br>static Stream&lt;Integer&gt; provideNumbers() {<br> return Stream.of(1, 2, 3);<br>}</pre><h4>@RepeatedTest JUnit Annotation</h4><p>Executes the test a specified number of times.</p><pre>@RepeatedTest(3)<br>void testRepeated() {<br> assertTrue(true);<br>}</pre><h4>@Tag JUnit Annotation</h4><p>Categorizes tests for filtering, based on feature name or some other classification of Test case.</p><pre>@Tag(&quot;fast&quot;)<br>@Test<br>void fastTest() {<br> assertEquals(2, 1 + 1);<br>}</pre><h4>@Nested JUnit Annotation</h4><p>Creates nested test classes for better organization.</p><pre>@Nested<br>class MathTests {<br> @Test<br> void additionTest() {<br> assertEquals(5, 2 + 3);<br> }<br>}</pre><p><a href="https://www.udemy.com/course/learn-complete-core-java-with-practical-examples/?referralCode=23FBECFFBB7A620AF30E">Click Here to Learn Core Java with 40 Hours of Video, Downloadable Source code examples, total about 120 hours of Learning</a></p><h4>JUnit Conditional Annotations</h4><p><strong>@EnabledOnOs</strong>: Runs the test only on specified operating systems (e.g., @EnabledOnOs(OS.WINDOWS)).<br><strong>@DisabledOnOs</strong>: Disables the test on specified operating systems (e.g., @DisabledOnOs(OS.LINUX)).<br><strong>@EnabledOnJre</strong>: Runs the test only on specified Java runtime versions (e.g., @EnabledOnJre(JRE.JAVA_11)).<br><strong>@DisabledOnJre</strong>: Disables the test on specified Java runtime versions (e.g., @DisabledOnJre(JRE.JAVA_8)).</p><h4>@TestInstance JUnit Annotation</h4><p>Changes the test lifecycle to PER_CLASS or PER_METHOD.</p><pre>@TestInstance(TestInstance.Lifecycle.PER_CLASS)<br>class TestLifecycleDemo {<br> @BeforeAll<br> void beforeAll() {<br> System.out.println(&quot;Before all tests in the class&quot;);<br> }<br>}</pre><h4>Common JUnit5 Assertions</h4><h4>Basic JUnit5 Assertions</h4><p>Assertions in JUnit 5 are methods used to validate expected outcomes during tests. They verify conditions like equality, truth, exceptions, or timeouts, which decides a Test case is Pass or Fail.</p><pre>assertEquals(5, result); // Checks equality<br>assertNotEquals(3, result); // Checks inequality<br>assertTrue(condition); // Asserts condition is true<br>assertFalse(condition); // Asserts condition is false<br>assertNull(object); // Asserts object is null<br>assertNotNull(object); // Asserts object is not null<br>assertThrows(Exception.class, () -&gt; methodCall()); // Asserts exception is thrown</pre><p><a href="https://www.udemy.com/course/java-full-stack-exam-practice-test-interview-questions/?referralCode=D84EECB3288F42E25923">Click Here for Java Fullstack interview questions</a></p><h4>Advanced JUnit5 Assertions</h4><pre>assertAll(<br> &quot;Multiple assertions&quot;,<br> () -&gt; assertEquals(4, 2 + 2),<br> () -&gt; assertNotNull(&quot;Hello&quot;)<br>); // Groups assertions<br>assertIterableEquals(expectedList, actualList); // Compares collections</pre><h4>JUnit5 Setup &amp; Maven Dependency</h4><pre>&lt;dependency&gt;<br> &lt;groupId&gt;org.junit.jupiter&lt;/groupId&gt;<br> &lt;artifactId&gt;junit-jupiter&lt;/artifactId&gt;<br> &lt;version&gt;5.10.0&lt;/version&gt;<br> &lt;scope&gt;test&lt;/scope&gt;<br>&lt;/dependency&gt;</pre><h4>Maven Command to Run Tests</h4><p>mvn test</p><p><a href="https://www.udemy.com/course/learn-complete-core-java-with-practical-examples/?referralCode=23FBECFFBB7A620AF30E">Learn Core Java with 40 Hours of Video, Downloadable Source code examples, total about 120 hours of Learning</a></p><h4>JUnit 5 Use Cases</h4><p><strong>REST API Testing</strong>: Use with RestAssured to test REST endpoints.</p><p><strong>UI Testing</strong>: Combine with Selenium for browser tests.</p><p><strong>Microservice Testing</strong>: Test interactions and integrations.</p><p><strong>Performance Testing</strong>: Measure test performance with custom timers.</p><p><strong>BDD Testing</strong>: Can eb used with Cucumber Framework, for BDD Testing</p><p><strong>Conclusion</strong></p><p>Whether you’re testing unit logic or entire application flows, JUnit 5 simplifies the process and ensures reliability. Its modular structure, enhanced annotations, and compatibility with popular libraries (RestAssured, Selenium, Cucumber, etc.) make it a go-to choice for Java testing.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dac3d6f260b8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Different ways of using this keyword, in Java]]></title>
            <link>https://medium.com/@sureshkumar_95502/different-ways-of-using-this-keyword-in-java-f53f464854b0?source=rss-68f0c1676484------2</link>
            <guid isPermaLink="false">https://medium.com/p/f53f464854b0</guid>
            <category><![CDATA[this-in-method]]></category>
            <category><![CDATA[java-this-keyword]]></category>
            <category><![CDATA[method-chaining]]></category>
            <category><![CDATA[this-in-constructor]]></category>
            <category><![CDATA[this-in-java]]></category>
            <dc:creator><![CDATA[Suresh Kumar]]></dc:creator>
            <pubDate>Sat, 14 Dec 2024 09:47:49 GMT</pubDate>
            <atom:updated>2024-12-14T09:47:49.177Z</atom:updated>
            <content:encoded><![CDATA[<p>In this post, I have shared different ways of using <strong>this</strong> Java keyword. In Java, <strong>this</strong> keyword refers to current object. this can be used in below different ways</p><ol><li><strong>this(); </strong>— to invoke the matching constructor from another constructor of the same class</li><li><strong>this. </strong>— to avoid name collision between data member and parameters/local variable having same name.</li><li><strong>this </strong>— refers to current object of this class.</li></ol><p><a href="https://www.udemy.com/course/learn-complete-core-java-with-practical-examples/?referralCode=23FBECFFBB7A620AF30E">Click Here to Learn Core Java with 40 Hours of Video, Downloadable Source code examples, total about 120 hours of Learning</a></p><h3>this( )</h3><p>this( ); can be invoked only from constructor, that too this( ); should be first line in constructor. this( ) cannot be used in method body.</p><pre>class First{<br>  private First(){<br>    System.out.println(&quot;First()&quot;);<br>  }<br><br>  public First(int i){<br>    this(); //invokes First() constructor<br>  }<br>}</pre><h3>this.</h3><p>this. can be used to</p><ol><li>differentiate local variable and data member</li><li>differentiate method(or constructor) parameter and data member</li><li>invoke non static methods of same class. this. can be used either in Constructor or method</li></ol><pre>class First{<br>  private int i;<br>  private First(){<br>    System.out.println(&quot;First()&quot;);<br>  }<br>  <br>  public First(int i){<br>    this();<br>    this.i/*data member*/ = i/* method parameter */;<br>    // above statement differentiates Constructor parameter and data member<br>  }<br>  <br>  void met(){<br>    int i;<br>    this.i/*data member*/= i/*local variable*/;<br>    // above statement differentiates Local variable and data member<br>  }<br>}</pre><p><a href="https://www.udemy.com/course/learn-complete-core-java-with-practical-examples/?referralCode=23FBECFFBB7A620AF30E">Click Here to Learn Core Java with 40 Hours of Video, Downloadable Source code examples, total about 120 hours of Learning</a></p><h3>this</h3><p>this can be used in method body,</p><ol><li>in return statement</li><li>this can be passed as parameter when invoking a method</li><li>synchronized block, for object locking to synchronize multiple threads</li></ol><pre>class First{<br>  private int i;<br>  private First(){<br>      System.out.println(&quot;First()&quot;);<br>  }<br>  <br>  public First(int i){<br>    this();<br>    this.i = i;<br>  }<br>  <br>  public First met(){<br>    Second sobj = new Second();<br>    sobj.met9(this); //this used as parameter to a method<br>    return this; //this used in return statement<br>  }<br>}<br><br>class Second{<br>  public void met9(First obj){<br>    //use obj object to perform some business logic<br>  }<br>}</pre><p>for object locking, to synchronize threads in multi-threaded applications</p><pre>class Example{<br>  public void display(){<br>    synchronized(this){ //this keyword used for synnchronization<br>    for(int i=0;i&lt;10;i++){<br>      System.out.println(i);<br>    }<br>  }<br>}<br>}</pre><p><a href="https://www.udemy.com/course/learn-complete-core-java-with-practical-examples/?referralCode=23FBECFFBB7A620AF30E">Click Here to Learn Core Java with 40 Hours of Video, Downloadable Source code examples, total about 120 hours of Learning</a></p><p>One of the best real time example, of using this keyword, I can recollect is, Method chaining</p><p>In Method chaining, we can chain invocation of multiple methods, as shown below</p><p>obj.met1( ).met2( ).met3( );</p><p><a href="https://www.udemy.com/course/java-full-stack-exam-practice-test-interview-questions/?referralCode=D84EECB3288F42E25923">Click Here for Java Fullstack interview questions</a></p><pre>class Third{<br>  public Third met1(){<br>    System.out.println(&quot;met1()&quot;);<br>    return this;<br>  }<br><br>  public Third met2(){<br>    System.out.println(&quot;met2()&quot;);<br>    return this;<br>  }<br><br>  public Third met3(){<br>    System.out.println(&quot;met3()&quot;);<br>    return this;<br>  }<br>}<br><br>public class Main{<br>  public static void main(String args[]){<br>    Third obj = new Third(); <br>    obj.met1().met2().met3(); //Method Chaining<br>  } <br>}</pre><p>Hope, this blog post helped you to get more insight on this Java Keyword. If any queries, please share in the comments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f53f464854b0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>