🚰Method Overloading (Compile-Time Polymorphism || Static Polymorphism + Early Binding ) Same method name, but different inputs → Java chooses the correct one ✅ ✅ It is called Compile-Time Polymorphism because the compiler decides which method to call based on arguments. ✅ Overloading Rules, You CAN overload by changing: ✅ Number of parameters ✅ Data types of parameters ✅ Order of parameters ✅data type order swap IS overloading ❌ You CANNOT overload by changing ONLY: ❌ Return type (NOT enough) ✅ Because Java doesn’t look at return type while calling a method. 🚫 You CANNOT overload a method by only changing return type Because method calling depends on: ✅ method name + parameters Return type is NOT used to decide the call. 🔖Frontlines EduTech (FLM) #Java #CoreJava #OOPS #Polymorphism #MethodOverloading #CompileTimePolymorphism #ConstructorOverloading #JVM #JavaDeveloper #FullStackDeveloper #LearningInPublic
Java Method Overloading: Compile-Time Polymorphism Explained
More Relevant Posts
-
Merge Sort in Java may look complex, but most mistakes happen because: • we don’t clearly understand how the array is divided • we mix up the merge logic • we forget that sorting actually happens during the merge step The core idea is straightforward: divide the array into smaller parts, sort them recursively, and then merge them back in sorted order. What really happens: – The array is repeatedly divided until each part has one element – A single element is already sorted by definition – Then, pairs of sorted subarrays are merged to form bigger sorted arrays So: – First, size-1 arrays are merged into size-2 sorted arrays – Then size-2 into size-4 – Then size-4 into size-8 – And so on, until the whole array is sorted The key insight: 👉 All the real sorting happens during merging, not during splitting. Once you understand that: • recursion just breaks the problem into smaller pieces • merge logic ensures order • time complexity stays O(n log n) in all cases Merge Sort isn’t about simplicity — it’s about guaranteed performance and clean divide-and-conquer thinking. That’s what makes it a foundation algorithm for: ✔ large datasets ✔ external sorting ✔ stable sorting requirements #Java #MergeSort #DSA #Algorithms #DivideAndConquer #ProblemSolving #BackendEngineering
To view or add a comment, sign in
-
day 93/100 #leetcodegrind “Find Minimum in a Sorted Rotated Array” problem — a classic example of Binary Search in action. 💡 Key idea: In a rotated sorted array, the minimum element is the pivot. By comparing mid and high elements, we can efficiently narrow the search space to find the minimum in O(log n) time. 🧠 What I practiced: Binary search on rotated arrays Identifying the pivot element efficiently Handling edge cases like non-rotated arrays Writing clean and optimized Java code It’s a simple problem, but it reinforces the power of binary search in non-traditional ways. Rotation? No problem! 🔄🚀 #DSA #ProblemSolving #Java #BinarySearch #Arrays #LeetCode #CodingPractice #DailyLearning
To view or add a comment, sign in
-
-
Some of the most influential designs in Java have zero methods. A Marker Interface looks empty on the surface, but its power lies in what it communicates to the runtime, not to the developer. A marker interface is a type-level signal, a way of encoding metadata directly into the inheritance hierarchy so that the JVM, libraries, and frameworks can make decisions based on presence, not behavior. It enables capabilities such as: 🔹 Type-based selection — the compiler and runtime can enforce or restrict actions based on the marker's presence. 🔹 Optimized execution pathways — e.g., Serializable lets JVM and frameworks apply dedicated serialization protocols. 🔹 Design-time guarantees — class hierarchies can embed semantic meaning without additional APIs. 🔹 Framework-level hooks — libraries like Spring use markers to activate internal logic without heavy scanning. Its strength comes from where it operates: Before method dispatch Before reflection Before annotation processing At the type system level Marker interfaces offer: ✔ compile-time safety ✔ structural meaning ✔ predictable inheritance ✔ faster checks than runtime-scanned metadata Even today, they remain valuable in scenarios where type identity conveys meaning more reliably than annotations — permission tagging, domain flags, lifecycle markers, and low-level system signals. Sometimes the most powerful abstractions in Java say nothing — yet shape how everything behaves. Hashtags: #Java #AdvancedJava #JVM #JavaInternals #BackendEngineering #JavaDeveloper #SoftwareEngineering #HighPerformanceJava #ProgrammingConcepts #DeepWork #CleanCode #CodingBestPractices #TechLearning #JavaCommunity #TypeSystem
To view or add a comment, sign in
-
Some of the most influential designs in Java have zero methods. A Marker Interface appears empty, but its real purpose is type-level communication — conveying semantic meaning directly through the inheritance hierarchy. It allows the compiler, JVM, and frameworks to make decisions based purely on presence of a type, not behavior. Marker interfaces enable: 🔹 Type-based selection — Compile-time and runtime can enforce or restrict operations based on the marker. 🔹 Optimized execution paths — e.g., Serializable triggers specialized serialization logic in the JVM. 🔹 Structural guarantees — semantic meaning is baked into the class design, not attached externally. 🔹 Framework-level hooks — frameworks like Spring use markers to activate behavior without reflection-heavy scanning. What makes marker interfaces powerful is where they operate: earlier than annotations earlier than reflection earlier than runtime scanning directly within the type system Because of this, they provide: ✔ compile-time safety ✔ predictable inheritance ✔ faster checks ✔ clean separation of intent ✔ tighter integration with object hierarchies Even in the era of annotations, marker interfaces remain relevant in systems where type identity is more trustworthy than metadata — domain flags, lifecycle markers, permission tagging, serialization/clone control, and low-level system signals. Sometimes the most impactful abstractions in Java are the ones that say nothing — yet redefine how the entire system interacts with them. #️⃣ High-Reach Java Hashtags #Java #AdvancedJava #JVM #JavaInternals #BackendEngineering #JavaDeveloper #SoftwareEngineering #HighPerformanceJava #ProgrammingConcepts #CleanCode #DeepWork #CodingBestPractices #SystemDesignThinking #JavaCommunity #TypeSystem #TechLearning
To view or add a comment, sign in
-
🚀Day 20 of #120DaysOfCode 📌 Problem: Reverse Integer(7) 📌 Language: Java Algorithm: 1. Initialize rev = 0 2. While x != 0 . Extract digit . Check overflow . Update rev 3. Return rev ⏱️ Time and Space Complexity Time Complexity: O(logn) Space complexity: O(1) 🔥One problem closer to mastery #120DaysOfCode #Day20 #Java #Array #Leetcode #ProblemSolving #Consistency #LearningEveryday #LearningPublic #DSA
To view or add a comment, sign in
-
-
🚀Day 14 of #120DaysOfCode 📌 Problem: Matrix Reshape(566) 📌 Language: Java 🔍Approach 1. Check if Reshape is possible 2. Traverse the original matrix in row order 3. Mapping logic ⏱️ Time and Space Complexity Time Complexity: O(m x n) Space complexity: O(r x c) 🔥One problem closer to mastery #120DaysOfCode #Day14 #Java #Array #Leetcode #ProblemSolving #Consistency #LearningEveryday #LearningPublic #DSA
To view or add a comment, sign in
-
-
Day25 - LeetCode Journey Solved LeetCode 344: Reverse String in Java ✅ This was a simple problem on the surface, but it perfectly highlights how powerful clean logic can be. The goal was to reverse a string in-place using O(1) extra space, which means no extra arrays and no shortcuts. Just pure two-pointer logic. Using the left and right pointers and swapping characters step by step felt very satisfying. It’s one of those patterns that looks small but appears everywhere in interviews and real-world problems. Mastering this makes many string and array problems much easier later on. What I liked about this problem is how it teaches efficiency. Instead of creating new memory, we directly modify the existing array. That mindset of optimizing space is extremely important in DSA. Key takeaways: • Strong practice of the two-pointer technique • In-place operations with constant extra space • Clean and readable swapping logic • Reinforced fundamentals of string manipulation ✅ Accepted successfully ✅ 0 ms runtime with optimal performance Sometimes the simplest problems build the strongest foundations. Consistency with basics is what makes complex problems feel easier later 💪 #LeetCode #DSA #Java #Strings #ProblemSolving #Algorithms #CodingJourney #InterviewPreparation #TwoPointers #Consistency #DailyPractice
To view or add a comment, sign in
-
-
Solved today’s LeetCode Daily Question using Java. Algorithm Traverse the array once to detect a strictly increasing sequence. Identify the peak element where the trend changes. Continue traversal while the sequence is strictly decreasing. Validate that there is exactly one peak and the traversal ends at the last index. Why this works A single-pass greedy scan ensures O(n) time complexity and constant space while rejecting invalid multiple-trend patterns early. Result • Runtime: 1 ms (beats 72.27%) • Memory: 44.62 MB (beats 64.71%) • 871/871 test cases passed #leetcode #algorithm #dsa #java #problemSolving #softwareengineering
To view or add a comment, sign in
-
-
Today I worked on a fun little pattern-checking problem in Java: detecting a “trionic” array — one that goes: strictly increasing ➝ strictly decreasing ➝ strictly increasing What I like about this solution is that it’s clean, fast, and doesn’t overcomplicate things with extra arrays or nested loops. It simply walks the array once, identifying the turning points: p = peak of the first increasing run q = bottom after the decreasing run flag = end of the final increasing run And then validates that: ✅ all three phases exist ✅ each phase has at least one step ✅ the last phase reaches the end of the array Time complexity: O(n) Space complexity: O(1) Leetcode problem link:https://lnkd.in/g8nkhR85 #Java #DSA #Algorithms #CodingInterview #ProblemSolving #SoftwareEngineering
To view or add a comment, sign in
-
-
StackOverflowError vs. OutOfMemoryError: A JVM Memory Primer Understanding the difference between these two Java runtime errors is crucial for effective debugging and performance tuning. Both signal exhaustion, but in distinct memory areas of the JVM. Q1: What is the fundamental distinction between them? A: The core difference lies in the memory pool they deplete. A StackOverflowError is related to stack memory, which is per-thread and stores method calls, local primitives, and object references. It's typically caused by deep or infinite recursion, where a method calls itself repeatedly until the thread's fixed stack size is exhausted. An OutOfMemoryError concerns the heap memory, the shared runtime data area where all Java objects and class instances are allocated. This error occurs when the heap is full and the Garbage Collector cannot reclaim enough space for a new object. Q2: How do their symptoms and debugging approaches differ? A: A StackOverflowError is often easier to diagnose. The exception stack trace is repetitive, clearly showing the cyclic pattern of method calls. Fixing it usually involves correcting the recursive algorithm's base case or converting it to an iterative solution. In contrast, an OutOfMemoryError is more complex. The root cause could be a genuine memory leak (objects unintentionally held in references), an undersized heap for the application's needs, or inefficient object creation. Debugging requires tools like heap dumps, profilers (VisualVM, YourKit), and analyzing GC logs to identify what's filling the heap and why those objects aren't being collected. Key Insight: Think of it as depth vs. breadth. StackOverflow is about the depth of your execution chain in a single thread. OutOfMemory is about the breadth of object allocation across the entire application. Have you tackled a tricky OOM lately? What's your go-to strategy for heap analysis? #Java #JVM #PerformanceTuning #Debugging #SoftwareDevelopment #Programming
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