Our training has officially started, and the first topic we explored was Method Overloading 🔹 Method Overloading Method Overloading is the process of creating multiple methods with the same name inside the same class. ✔ In method overloading, name clashes may happen, but Java resolves them at compile time. ✔ The Java compiler resolves overloading by checking in this order: • Method name • Number of parameters • Data type of parameters • Order of data types 📌 Real-time example: substring() method • Accepts one argument • Also accepts two arguments 🔹 Polymorphism Polymorphism means “one is to many” — a method existing in multiple forms. 📌 Real-time example: Carbon exists in multiple forms that is Carbon dioxide, Coal, Graphite, Diamond and many more ➡ Same element, different forms. 🔹 Virtual Polymorphism Virtual polymorphism is not real polymorphism, but an illusion to the user. 📌 Example: Mobile power button • User thinks one button performs both ON and OFF. In reality, there are two separate methods: • One for power ON and One for power OFF ➡ Hence, it is called virtual (not true) polymorphism 🔹 Method Overloading as Compile-Time Polymorphism ✔ Method calling and method binding happen at compile time ✔ Hence, method overloading is called: • Compile-Time Polymorphism • Early Binding 🔹 Overloading Type Promotion If an exact match is not found, Java: • Looks for the closest possible match • Checks the number of type conversions ⚠ If multiple methods have the same number of conversions, → Ambiguous method call error occurs. 📌 Key Takeaway: Even though we say “one method performs multiple tasks”, 👉 In reality, one method always performs only one task. 💡 Understanding these basics clearly makes advanced Java concepts much easier! Huge Thanks to MALLIKARJUN V VERNEKAR for the guidance. #Java #OOPsConcepts #MethodOverloading #Polymorphism #CompileTimePolymorphism #JavaLearning #ProgrammingBasics 🚀
Java Method Overloading Explained
More Relevant Posts
-
🚀 Learning Update: Core Java – Encapsulation & Constructors 1️⃣ Understood Encapsulation practically, not just theoretically. 2️⃣ Learned how to protect data using the private access modifier. 3️⃣ Implemented controlled access using setters and getters. 4️⃣ Realized the importance of validating data inside setters (handling negative values, invalid inputs, etc.). 5️⃣ Implemented a real-world example using a Customer class with ID, Name, and Phone fields. 6️⃣ Learned about the shadowing problem when parameter names match instance variables. 7️⃣ Understood that local variables have higher priority inside methods. 8️⃣ Solved shadowing using the this keyword (currently executing object). 9️⃣ Gained clarity on constructors and how they are called during object creation. 🔟 Learned that constructors must have the same name as the class and do not have a return type. 1️⃣1️⃣ Understood the difference between default constructor, zero-parameterized constructor, and parameterized constructor. 1️⃣2️⃣ Learned that if we don’t create a constructor, Java automatically provides a default constructor. 1️⃣3️⃣ Explored constructor overloading and how Java differentiates constructors based on parameters. 1️⃣4️⃣ Understood the difference between constructors and methods (return type, calling time, naming rules). 1️⃣5️⃣ Gained better clarity on object creation flow, memory allocation, and execution order. Feeling more confident about explaining Encapsulation and Constructors clearly in interviews now! 💻🔥 #Java #CoreJava #OOPS #Encapsulation #Constructor #LearningJourney #PlacementPreparation TAP Academy
To view or add a comment, sign in
-
-
Day 6 | Full Stack Development with Java Today’s learning made me realize how important data conversion is while working with Java programs. I explored Type Casting — a concept that controls how data moves between different data types. What is Type Casting? Type casting is the process of converting one data type into another. In Java, this becomes important because Java is a strongly typed language. Two Types of Type Casting I Learned Today: Implicit Casting (Widening) – Automatic Happens when converting a smaller data type to a larger one. No data loss occurs. Example flow: byte → short → int → long → float → double The compiler handles it automatically. Explicit Casting (Narrowing) – Manual Used when converting a larger data type into a smaller one. Requires programmer intervention. Syntax example: byte b = (byte) a; May cause loss of precision, so it must be used carefully. Realization of the Day Understanding type casting helped me see how Java manages memory and prevents unexpected behavior during calculations. Even a small conversion can change program output — which shows why fundamentals matter so much in backend development. Learning step by step and connecting theory with real code is making this journey more interesting every day. #Day6 #Java #TypeCasting #FullStackDevelopment #LearningInPublic #ProgrammingJourney #SoftwareDevelopment
To view or add a comment, sign in
-
-
Stop comparing Python to Java 8. It’s 2026. Yes — Java is more verbose than Python. That’s objectively true. But most comparisons are still stuck in a pre-Java-17 mental model. Modern Java removed a huge amount of historical boilerplate: records, var, pattern matching, concise collections, simplified entry points. In real backend code today, the gap often looks like: Python → ~6 lines Modern Java → ~8–10 lines Not 3×. Not 10×. Just slightly more explicit. And that explicitness buys: • compile-time guarantees • safer large-scale refactoring • precise domain contracts • long-term maintainability Python is excellent for scripting and rapid iteration. But modern Java isn’t “overly verbose” — it’s deliberately structured for systems that must scale and live for years.
To view or add a comment, sign in
-
-
: 🔁 Deep Dive into Inheritance & Method Overriding in Java Today I explored some powerful concepts of Inheritance in Java, especially focusing on Method Overriding and related rules. Here are the key takeaways from my learning: ✅ 1. Return Type Rule While overriding a method, the return type must be: The same type, or A Covariant Return Type (a subclass of the original return type). ✅ 2. Access Specifier Rule The access level cannot be more restrictive than the parent method. You can increase visibility (e.g., protected → public) But you cannot decrease it (e.g., public → private ❌) ✅ 3. Covariant Return Type Java allows a subclass method to return a more specific type than the parent method. This improves flexibility and supports runtime polymorphism. ✅ 4. Parameters To override: Method name must be the same Parameters must be exactly the same If parameters change → it becomes Method Overloading, not Overriding. ✅ 5. Method Overloading in Inheritance Overloading is supported in inheritance. A subclass can have: Same method name Different parameters This is resolved at compile-time. 🚫 Why Static Methods Are Not Overridden? Static methods are not overridden because they belong to the class, not the object. Instead, they follow the concept of Method Hiding. When a static method is redefined in a child class: It hides the parent’s method It does NOT support runtime polymorphism ✅ Static Variables in Inheritance Static variables are inherited, but they are shared among all objects since they belong to the class. 🔒 Final Keyword in Inheritance final variable → Cannot be modified final method → Cannot be overridden final class → Cannot be inherited Java developers intentionally declare some classes as final (for example, security or immutability reasons) to: Prevent unwanted modification Ensure data integrity Maintain system stability #Java #Inheritance #MethodOverriding #OOP #LearningJourney #BackendDevelopment #TapAcademy
To view or add a comment, sign in
-
-
💡Looking at how different teams perform with Python and Java, one insight stands out: language choice matters less than aligning the technology with the product’s architecture, constraints, and growth trajectory. Java brings structure, predictability, and long-term stability – qualities that matter hugely in enterprise systems, financial platforms, and high-load environments. When consistency under pressure is non-negotiable, Java delivers that reliability every time. Python, on the other hand, accelerates everything around development itself. • The speed of iteration. • The pace of experimentation. • The ability to turn complex ideas into working features with minimal friction. I’ve seen Python unlock rapid progress in data-heavy projects, AI-driven platforms, and fast-evolving products where adaptability is just as important as performance. And I know how Java can anchor critical systems that need to run flawlessly for years. What's interesting is that companies rarely choose “Python or Java.” They choose the language that moves that specific piece of the product forward. ✨ 𝗣𝘆𝘁𝗵𝗼𝗻 𝗳𝗼𝗿 𝗶𝗻𝗻𝗼𝘃𝗮𝘁𝗶𝗼𝗻 𝗮𝗻𝗱 𝘀𝗽𝗲𝗲𝗱. 𝗝𝗮𝘃𝗮 𝗳𝗼𝗿 𝘀𝘁𝗿𝘂𝗰𝘁𝘂𝗿𝗲 𝗮𝗻𝗱 𝗹𝗼𝗻𝗴-𝘁𝗲𝗿𝗺 𝗿𝗲𝘀𝗶𝗹𝗶𝗲𝗻𝗰𝗲. Different strengths are both essential, depending on the mission. If you want a more detailed breakdown of how they compare in performance, syntax, scalability, and ecosystem maturity, we recently published a full guide: https://lnkd.in/drGmi827 ?utm_source=LinkedIn&utm_medium=post&utm_campaign=LiPostsOct25&utm_id=LiPostsOct25 Curious to hear your thoughts 🤔 Which language has served you better in real projects, and why? Have you seen Python or Java outperform expectations in unexpected ways? 𝗜’𝗱 𝗹𝗼𝘃𝗲 𝘁𝗼 𝗿𝗲𝗮𝗱 𝘆𝗼𝘂𝗿 𝗲𝘅𝗽𝗲𝗿𝗶𝗲𝗻𝗰𝗲𝘀 𝗶𝗻 𝘁𝗵𝗲 𝗰𝗼𝗺𝗺𝗲𝗻𝘁𝘀 💬👇
To view or add a comment, sign in
-
-
🚀 Day 16/30 – Java DSA Challenge 🔎 Problem 69: 150. Evaluate Reverse Polish Notation (LeetCode – Medium) Today’s problem focused on evaluating expressions written in Reverse Polish Notation (RPN) — also known as Postfix Expression. This problem strengthens: ✅ Stack fundamentals ✅ Expression evaluation ✅ Operator handling ✅ Order of operations without parentheses 🧠 Problem Summary We are given an array of strings representing a mathematical expression in Reverse Polish Notation. We must evaluate the expression and return the result. Key Points: Valid operators: +, -, *, / Division truncates toward zero No division by zero Expression is always valid 💡 Why Stack is Perfect Here? In RPN: Operands come first Operator comes after its operands Example: ["2","1","+","3","*"] Which translates to: ((2 + 1) * 3) = 9 Core Logic: 1️⃣ If token is a number → Push to stack 2️⃣ If token is an operator → Pop top two numbers Apply operation Push result back to stack At the end, the stack contains the final result. ⏱ Complexity Analysis Time Complexity: O(N) Space Complexity: O(N) Each token is processed exactly once. 📌 Concepts Reinforced ✔ Stack-based expression evaluation ✔ Understanding postfix notation ✔ Order of operand handling (important for subtraction & division) ✔ Clean and structured operator handling 📈 Learning Reflection This problem shows how powerful stacks are when dealing with expressions. Unlike infix expressions (which require precedence rules and parentheses), postfix expressions simplify evaluation — making stack the ideal data structure. Mastering these fundamentals builds strong foundations for: Expression parsing Compiler design basics Advanced algorithm problems ✅ Day 16 Progress Update 🔥 69 Problems Solved in 30 Days DSA Challenge Consistency. Logic. Growth. 🚀 #Day16 #30DaysOfDSA #Java #LeetCode #Stack #Algorithms #ProblemSolving #CodingJourney #InterviewPreparation
To view or add a comment, sign in
-
-
One of today’s most interesting learning was understanding the platform-independent nature of Java. Why language like java/python are platform independent and C/C++ are platform dependent? A common misconception is that high-level languages themselves are platform independent. In reality, platform independence comes from how the code is processed internally. First let's see what happens when a C/C++ code is run? The high level language code is translated using compiler into a machine level Object code (.obj file). [Key note: Machine level code are machine dependent because underlying operating system has it's own way of processing(specific to OS + CPU architecture)]. Object code is further linked with library files (.lib) using linker and than executable file (.exe) is generated and executed. Now, let's come to Java. Java follows a different path, the source code is compiled to Byte code(.class) using java compiler. Byte Code is neither in HLL nor in MLL i.e secure and platform independent. Now byte code is given to JVM. Since every operating system has its own JVM, the same bytecode can run anywhere. JVM takes the byte code and translates it into MLL using interpreter and executed statement by statement. That's the magic behind Write Once, Run Anywhere (WORA) This design choice is what makes Java incredibly portable and one of the reasons it remains so widely used. Greatful for the insightful session and guidence by Syed Zabi Ulla sir. Always fascinating to see how much happens behind the scenes when we run even a simple program. #Java #Programming #ComputerScience #Coding #JVM #PlatformIndependence #ObjectOrientedProgramming
To view or add a comment, sign in
-
-
👋 Hii Connections 📌𝗚𝗮𝗿𝗯𝗮𝗴𝗲 𝗖𝗼𝗹𝗹𝗲𝗰𝘁𝗼𝗿 (𝗚𝗖) 𝗶𝗻 𝗝𝗮𝘃𝗮 ❓ 𝗪𝗵𝗮𝘁 𝗶𝘀 𝗚𝗮𝗿𝗯𝗮𝗴𝗲 𝗖𝗼𝗹𝗹𝗲𝗰𝘁𝗼𝗿 (𝗚𝗖)? Garbage Collector (GC) is a part of JVM that automatically removes unused objects from Heap memory. ❓ 𝗪𝗵𝘆 𝗚𝗖 𝗶𝘀 𝗡𝗲𝗲𝗱𝗲𝗱? In C/C++ → Memory is manually freed using free() or delete() In Java → Memory allocation = new Memory deallocation = Automatic (by GC) Prevents: -> Memory leaks -> Dangling pointers -> Manual memory errors ❓ 𝗪𝗵𝗮𝘁 𝗶𝘀 𝗛𝗲𝗮𝗽 𝗔𝗿𝗲𝗮? Heap is the runtime memory where objects and instance variables are stored. Heap is divided into: 1️⃣ Young Generation 2️⃣ Old Generation ❓ 𝗪𝗵𝗮𝘁 𝗶𝘀 𝗬𝗼𝘂𝗻𝗴 𝗚𝗲𝗻𝗲𝗿𝗮𝘁𝗶𝗼𝗻? Young Generation is the part of the Heap memory where newly created objects are stored. -> Most objects are short-lived, so GC runs frequently here. -> Young Generation has: 1. Eden Space 2. Survivor S0 3. Survivor S1 ❓ 𝗪𝗵𝗮𝘁 𝗶𝘀 𝗘𝗱𝗲𝗻 𝗦𝗽𝗮𝗰𝗲? All new objects are created here. Example: Student s = new Student(); // Stored in Eden ❓ 𝗪𝗵𝗮𝘁 𝗶𝘀 𝗦𝘂𝗿𝘃𝗶𝘃𝗼𝗿 (𝗦𝟬 & 𝗦𝟭)? Stores objects that survive Minor GC One acts as 𝗙𝗿𝗼𝗺 𝗦𝗽𝗮𝗰𝗲, other as 𝗧𝗼 𝗦𝗽𝗮𝗰𝗲 After each Minor GC → they swap Object age increases If age reaches limit (~15) → moved to Old Generation ❓𝗪𝗵𝗮𝘁 𝗶𝘀 𝗢𝗹𝗱 𝗚𝗲𝗻𝗲𝗿𝗮𝘁𝗶𝗼𝗻? Old Generation is the part of the Heap memory where long-lived objects are stored. -> Cleaned by Major / Full GC. -> If memory not available → java.util.OutOfMemoryError 📌𝗚𝗖 𝗳𝗼𝗹𝗹𝗼𝘄𝘀 𝗠𝗦𝗖 𝗔𝗹𝗴𝗼𝗿𝗶𝘁𝗵𝗺! 1️⃣ Mark – Marks reachable objects 2️⃣ Sweep – Removes unreachable objects 3️⃣ Compact – Rearranges memory (removes gaps) Java learners 👉 Save it. Like it. Comment “JVM”. 🚀 🚀 Next post will be about Garbage Collection in Java - how JVM automatically manages memory! Follow and like to stay updated with the series 💙 #Java #GarbageCollection #100DaysOfCode
To view or add a comment, sign in
-
-
For most of my career, I’ve worked extensively with Java. Recently, I decided to properly learn Python — not by watching tutorials, but by building real programs. Over the past few weeks, I worked through topics like: Strings, Lists, Dictionaries Functions, Scope, *args / **kwargs File I/O & Regex Modules & External Libraries OOP, Inheritance, Polymorphism Unit Testing Multithreading MySQL integration And I implemented 8 progressively complex projects — including: • Reading and processing PDFs • Extracting data using regex from config files • Storing structured questions in MySQL • Implementing polymorphism for multiple question types • Parsing RSS feeds using multithreading Coming from a Java background, this was eye-opening. Some reflections: ✔ Python dramatically reduces boilerplate ✔ Development speed is significantly faster ✔ OOP feels more flexible and less rigid ✔ Error handling is simpler and cleaner But at the same time: ✔ Java’s type safety provides strong guarantees ✔ Enterprise architecture patterns feel more mature ✔ Concurrency control is more explicit and powerful The biggest difference isn’t syntax. It’s philosophy. Java says: “Define everything clearly before running.” Python says: “Write it simply. Make it work.” I’ve written a detailed Medium article sharing my hands-on comparison, lessons learned, and when I would choose one over the other. If you’re a Java developer considering Python (or vice versa), this might be useful. https://lnkd.in/gJ5TWCiF Would love to hear from others who’ve worked with both — what differences stood out to you? #Python #Java #SoftwareEngineering #LearningJourney #BackendDevelopment #Programming #TechGrowth
To view or add a comment, sign in
-
Understanding reduce() in Java Streams — with a real example reduce() is one of those Stream APIs that looks simple, but once you truly understand it, your thinking level changes. Let’s go beyond sum(). 🧪 Example: Total notebooks owned by all students class Student { private int notebooks; public int getNotebooks() { return notebooks; } } Now imagine this data: List<Student> students = Arrays.asList( new Student(3), new Student(5), new Student(2) ); ❓ Problem Find the total number of notebooks owned by all students. ❌ Naive thinking Using loops, counters, mutable variables… ✅ Stream + reduce() way int totalNotebooks = students.stream() .map(Student::getNotebooks) .reduce(0, Integer::sum); 🧠 What’s happening internally? identity → 0 (starting point) accumulator → Integer::sum Step by step: 0 + 3 = 3 3 + 5 = 8 8 + 2 = 10 Final result: 10 🔍 Why reduce() is powerful Because it: Converts many values → one value Avoids mutable state Works beautifully with parallel streams Forces you to think in transformations ⚠️ Important rule (interview favorite) The identity value must not change the result. That’s why: .reduce(0, Integer::sum) ✅ .reduce(1, Integer::sum) ❌ 🧠 Key takeaway reduce() is not about adding numbers. It’s about how data collapses into meaning. If you understand reduce(), you’re not just writing Java — you’re thinking functionally. #Java #Streams #Reduce #FunctionalProgramming #BackendDevelopment #LearningInPublic
To view or add a comment, sign in
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development