Why abstract class needs a constructor? 🤔 Even though you can’t create an object of an abstract class, its constructor still runs — because it helps initialize common properties when a subclass object is created! 🔥 💡 Example: The abstract class sets up base variables or logs setup info before the child class adds its own behavior. #Java #OOPs #Constructor #AbstractClass #JavaConcepts #CodingReels #Skillio #JavaForBeginners
More Relevant Posts
-
#helloskillio Why abstract class needs a constructor? 🤔 Even though you can’t create an object of an abstract class, its constructor still runs — because it helps initialize common properties when a subclass object is created! 🔥 💡 Example: The abstract class sets up base variables or logs setup info before the child class adds its own behavior. #Java #OOPs #Constructor #AbstractClass #JavaConcepts #CodingReels #Skillio #JavaForBeginners https://lnkd.in/gWv63jaz
To view or add a comment, sign in
-
🚀 𝐃𝐚𝐲 9 𝐨𝐟 𝐦𝐲 #100𝐃𝐚𝐲𝐬𝐎𝐟𝐃𝐒𝐀 𝐉𝐨𝐮𝐫𝐧𝐞𝐲 𝐏𝐫𝐨𝐛𝐥𝐞𝐦𝐬 𝐒𝐨𝐥𝐯𝐞𝐝 𝐓𝐨𝐝𝐚𝐲 : 🔥 1️⃣ Leetcode (Medium) – Product of Array Except Self 💡 Key Idea: Instead of using division, use Prefix and Suffix Products. Prefix → product of all elements before the current index Suffix → product of all elements after the current index Multiply both to get the result for each element. 🧾 Time Complexity: O(n) ⚙️ Space Complexity: O(1) #DSA #Java #100DaysOfCode #ProblemSolving #LearningInPublic #SortingAlgorithms #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 59 of #100DaysOfCode 🚀 🔹 Problem: Check if Digits Are Equal in String After Operations I – LeetCode ✨ Approach: Used an iterative reduction strategy 🔁 — repeatedly combined adjacent digits (mod 10) until only two numbers remained. Finally checked if both digits are equal! Simple yet logical 🧠 ⚡ Complexity Analysis: Time Complexity: O(n²) – iterative pairwise reduction until only two digits remain Space Complexity: O(n) – storing intermediate list of digits 📊 Performance: ✅ Runtime: 10 ms (Beats 35.69%) ✅ Memory: 45.51 MB (Beats 12.86%) 🔑 Key Insight: Sometimes, brute-force reduction problems aren’t about optimization — they’re about translating logic into clean code that mirrors the operation flow perfectly. ✨ #LeetCode #100DaysOfCode #Java #DSA #ProblemSolving #CodingChallenge #LogicBuilding #ProgrammingJourney #DailyCoding
To view or add a comment, sign in
-
-
@Value + Lifecycle Annotations The @Value annotation injects constants, property values, or expressions. It simplifies configuration by externalizing values cleanly. With @PostConstruct, you can initialize resources after dependencies load. @PreDestroy helps you release resources before shutdown. Together they ensure smooth object setup and cleanup. #SpringFramework #Java #SoftwareEngineering #BackendDevelopment
To view or add a comment, sign in
-
🚀 Day 43 of #100DaysOfLeetCode Today's problem: LeetCode #160 – Intersection of Two Linked Lists 💡 Concept: Find the node where two singly linked lists intersect. Used the Two Pointer Approach — a smart and efficient way to solve this without using extra memory. 🧠 Logic: Move both pointers through the lists. When one pointer reaches the end, switch it to the other list’s head. They’ll either meet at the intersection node or end up as null together. ✅ Complexity: Time – O(n + m) Space – O(1) 💬 Takeaway: Sometimes, the best solutions come from balancing the path — literally! Understanding how pointers sync up teaches a lot about memory references and linked list behavior. #LeetCode #CodingChallenge #Java #DataStructures #TwoPointerTechnique #ProblemSolving #LinkedLists
To view or add a comment, sign in
-
-
#100DaysOfCode – Day 81 Linked List Cycle Problem Given the head of a linked list, determine whether the list contains a cycle meaning a node’s next pointer refers back to a previous node. My Approach Used Floyd’s Cycle Detection Algorithm (Tortoise & Hare Method): Initialized two pointers slow and fast. Moved slow one step and fast two steps in each iteration. If they ever meet → cycle detected. If fast or fast.next becomes null → no cycle exists. Complexity Time: O(n) Space: O(1) Even in problems involving dynamic structures like linked lists, a simple pointer-based approach can lead to an elegant and optimal solution. #100DaysOfCode #LeetCode #Java #ProblemSolving #DataStructures #LinkedList #TortoiseAndHare #takeUforward #CodeNewbie #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 390 of #500DaysOfCode 🔹 LeetCode Problem 278: First Bad Version Today’s problem was about efficiently finding the first defective version in a product release sequence using minimal API calls. Once a version turns bad, all versions after it are bad — a perfect use case for binary search optimization! ⚙️ 🧠 Concepts Used: Binary Search 🔍 Optimization of API calls Problem-solving with boundary conditions ⚡ Time Complexity: O(log n) ⚡ Space Complexity: O(1) Each step halves the search range, making it super-efficient! 🚀 #LeetCode #Java #CodingChallenge #BinarySearch #ProblemSolving #100DaysOfCode #500DaysOfCode #CodeNewbie #LearnToCode #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 Day 43 of #100DaysOfLeetCode Today's problem: LeetCode #160 – Intersection of Two Linked Lists 💡 Concept: Find the node where two singly linked lists intersect. Used the Two Pointer Approach — a smart and efficient way to solve this without using extra memory. 🧠 Logic: Move both pointers through the lists. When one pointer reaches the end, switch it to the other list’s head. They’ll either meet at the intersection node or end up as null together. ✅ Complexity: Time – O(n + m) Space – O(1) 💬 Takeaway: Sometimes, the best solutions come from balancing the path — literally! Understanding how pointers sync up teaches a lot about memory references and linked list behavior. #LeetCode #CodingChallenge #Java #DataStructures #TwoPointerTechnique #ProblemSolving #LinkedLists
To view or add a comment, sign in
-
-
🚀 Day 43 of #100DaysOfLeetCode Today's problem: LeetCode #160 – Intersection of Two Linked Lists 💡 Concept: Find the node where two singly linked lists intersect. Used the Two Pointer Approach — a smart and efficient way to solve this without using extra memory. 🧠 Logic: Move both pointers through the lists. When one pointer reaches the end, switch it to the other list’s head. They’ll either meet at the intersection node or end up as null together. ✅ Complexity: Time – O(n + m) Space – O(1) 💬 Takeaway: Sometimes, the best solutions come from balancing the path — literally! Understanding how pointers sync up teaches a lot about memory references and linked list behavior. #LeetCode #CodingChallenge #Java #DataStructures #TwoPointerTechnique #ProblemSolving #LinkedLists
To view or add a comment, sign in
-
More from this author
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
Constructor in abstract class is used to initialize the instance variable of abstract class