Polymorphism is another important concept in object oriented programming. The word polymorphism comes from two words - poly meaning many, and morph meaning forms. In programming it refers to the ability of a method to behave differently depending on how it is used. One common form of polymorphism in Java is method overloading. Things that became clear : • method overloading happens when multiple methods share the same name • the methods must differ in their parameter list • Java decides which method to execute based on the arguments passed • this is known as compile-time polymorphism • it allows the same operation to work with different types or number of inputs A simple example shows how this works : class Calculator { void add(int a, int b) { System.out.println(a + b); } void add(int a, int b, int c) { System.out.println(a + b + c); } } Both methods have the same name but different parameters, so Java treats them as separate methods. This approach helps make programs more flexible while keeping method names consistent. #java #oop #programming #learning #dsajourney
Lakhyadeep Sen’s Post
More Relevant Posts
-
📚 Today’s Learning: String Concatenation & "concat()" Method in Java In today’s class, I explored an important concept in Java called String Concatenation and the "concat()" method. 🔹 String Concatenation String concatenation is the process of combining two or more strings into a single string. In Java, this is commonly done using the "+" operator. It helps developers create meaningful text outputs by joining variables and messages together. 🔹 "concat()" Method Java also provides the "concat()" method, which is a built-in method of the String class. This method is used to append one string to another string, producing a new combined string. 🔹 Important Concept – String Immutability One key concept behind these operations is that Strings in Java are immutable. This means the original string cannot be changed; instead, a new string object is created when concatenation happens. 💡 Key Takeaway: - "+" is an operator used for concatenation - "concat()" is a method of the String class used to join strings Learning these fundamental concepts strengthens my Java programming foundation and helps me understand how strings work internally. #Java #Programming #LearningJourney #StudentDeveloper #Coding TapAcademy
To view or add a comment, sign in
-
-
🚀 Understanding Polymorphism in Java Polymorphism is one of the core concepts of Object-Oriented Programming (OOP). The word Polymorphism means “many forms.” In Java, it allows the same method or object to behave differently depending on the context or object calling it. 🔹 Types of Polymorphism 1️⃣ Compile-Time Polymorphism (Method Overloading) Occurs when multiple methods have the same name but different parameters. The decision of which method to call is made at compile time. 2️⃣ Run-Time Polymorphism (Method Overriding) Occurs when a child class provides a different implementation of a method defined in the parent class. The method call is resolved at runtime. 💡 Why Polymorphism is Important ✔ Improves code reusability ✔ Makes programs flexible and scalable ✔ Helps represent real-world scenarios in programming Understanding concepts like Polymorphism strengthens the foundation of writing clean, maintainable, and efficient code. 📚 Always learning and improving as a developer. #TAPAcademy #SharathR #LearningJourney #Java #OOP #Polymorphism #Programming #SoftwareDevelopment #LearningJourney
To view or add a comment, sign in
-
-
Day 40 - Abstraction in Java Today I explored Abstraction, one of the core concepts of Object-Oriented Programming in Java. 🔹 What is Abstraction? Abstraction is the process of hiding implementation details and showing only the essential features to the user. In simple terms: 👉 The user knows what a program does, but not how it does it internally. 📌 Key Points Abstraction is achieved using abstract classes and abstract methods. An abstract class cannot be instantiated (no objects can be created). It can contain both abstract methods and concrete methods. If a class contains at least one abstract method, the class must be declared abstract. 📌 Abstract Method A method that only has a declaration (signature) but no body. Child classes must provide the implementation. Example concept from my learning: ✈️ Plane Example Abstract class: Plane Methods: takeOff(), fly(), land() Child classes: CargoPlane PassengerPlane FighterPlane Each child class implements these methods differently, demonstrating abstraction and code reuse. 📌 Why Abstraction is Important ✔ Reduces code complexity ✔ Improves code maintainability ✔ Promotes modular design ✔ Enhances security by hiding details 💡 Real-world example: When sending an email, we simply type the message and click Send. The complex processes happening in the background are hidden from us. #Java #OOP #Abstraction #ProgrammingJourney #JavaLearning #SoftwareDevelopment #Coding
To view or add a comment, sign in
-
-
📘 Learning Java – Polymorphism Today I learned one of the most powerful concepts in Object-Oriented Programming: Polymorphism. The word Polymorphism comes from Greek: Poly = Many Morph = Forms In Java, polymorphism means one method call can perform different behaviors depending on the object it works with. To understand this better, I used a real-world airport example ✈️ Imagine an Airport controller giving permission to different planes: CargoPlane PassengerPlane FighterPlane The airport system simply calls: permit(Plane p) But each plane behaves differently: CargoPlane → carries goods PassengerPlane → carries passengers FighterPlane → performs defense operations Even though the method call is the same, the behavior changes based on the object. That is the power of polymorphism. Key Concepts I Practiced Today ✔ Loose Coupling Parent reference → Child object Plane ref = new CargoPlane(); ✔ Upcasting Assigning child object to parent reference. ✔ Downcasting Converting parent reference back to child type to access specialized methods. Why Polymorphism is Important 🔹 Code Reduction – Write one method and reuse it for multiple objects. 🔹 Code Flexibility – New child classes can work without modifying existing code. In simple words: 💡 Polymorphism = One method call, many behaviors. Every day I’m getting deeper into Java OOP concepts, and it's amazing how closely programming models real-world systems. #Java #OOP #Polymorphism #JavaDeveloper #Programming #CodingJourney #SoftwareEngineering
To view or add a comment, sign in
-
-
Day 39 of My Java Learning Journey – Polymorphism Today I learned one of the most powerful concepts in Polymorphism in Java. 📌 What is Polymorphism? Polymorphism comes from two Greek words: Poly → Many Morphs → Forms 👉 So, polymorphism means “many forms.” In Object-Oriented Programming, it allows one reference to behave differently depending on the object it refers to. ✈️ Example from my practice I created a parent class Plane with a method fly(). Then I created three child classes: CargoPlane PassengerPlane FighterPlane Each class overrides the fly() method with different behavior. Example behavior: CargoPlane → flying at low height PassengerPlane → flying at medium height FighterPlane → flying at great height Using a parent reference (Plane ref), I assigned different child objects: Plane ref; ref = cp; ref.fly(); ref = pp; ref.fly(); ref = fp; ref.fly(); This demonstrates Runtime Polymorphism (Method Overriding). ⚠️ Important Concept I Learned Using a parent reference, we can only call: ✔ Inherited methods ✔ Overridden methods But we cannot directly access child-specific methods like: carryCargo() carryPassenger() carryWeapons() To access them, we must use Downcasting. Example: ((CargoPlane) ref).carryCargo(); 🎯 Advantages of Polymorphism ✔ Code Reusability ✔ Flexibility ✔ Reduced Complexity #Java #JavaProgramming #OOP #Polymorphism #MethodOverriding #ProgrammingJourney
To view or add a comment, sign in
-
-
🚀 Starting my journey in Java programming! Today I implemented a simple concept with a Program— Factorial of a number. Factorial is widely used in mathematics and programming problems. Through this program, I practiced loops, condition handling, and method creation in Java. 💡 What I learned: • Writing reusable methods • Handling edge cases (like negative numbers) • Taking user input using Scanner • Strengthening my logic-building skills Here’s my implementation: import java.util.*; class FactorialProgram { private static int factorial(int a) { int fact = 1; if (a >= 0) { for (int i = a; i >= 1; i--) { fact = fact * i; } } else { System.out.println("Factorial of negative numbers cannot be determined"); return 0; } return fact; } public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.print("Enter the number: "); int a = sc.nextInt(); System.out.println("\nFactorial of the Number: " + factorial(a)); sc.close(); } } Would love feedback or suggestions to improve this further 🙌, as i am learning please help!! #Java #Programming #CodingJourney #LearningInPublic #BeginnerDeveloper #TechSkills
To view or add a comment, sign in
-
🚀 Understanding Polymorphism in Java Polymorphism is one of the core concepts of Object-Oriented Programming (OOP). The word Polymorphism means “many forms.” In Java, it allows the same method or object to behave differently depending on the context or object calling it. 🔹 Types of Polymorphism 1️⃣ Compile-Time Polymorphism (Method Overloading) Occurs when multiple methods have the same name but different parameters. The decision of which method to call is made at compile time. 2️⃣ Run-Time Polymorphism (Method Overriding) Occurs when a child class provides a different implementation of a method defined in the parent class. The method call is resolved at runtime. 💡 Why Polymorphism is Important ✔ Improves code reusability ✔ Makes programs flexible and scalable ✔ Helps represent real-world scenarios in programming Understanding concepts like Polymorphism strengthens the foundation of writing clean, maintainable, and efficient code. 📚 Always learning and improving as a developer. #Java #Polymorphism #OOP #Programming #SoftwareDevelopment #LearningJourney 💻🚀
To view or add a comment, sign in
-
-
Most students just read Java… But very few actually understand how it works internally. So I tried something different. Instead of long boring notes, I converted my Java String concepts into visual handwritten style notes — so anyone can understand things like: • Heap vs SCP • Why String is immutable • String vs StringBuilder vs StringBuffer • Important String interview questions These are the kinds of concepts that actually matter in interviews and real development. If you are learning Java right now, try to solve the MCQ / questions in the last slide and comment your answer 👇 Let’s see how many people get it right. And yes — these handwritten-style notes are designed with the help of AI so that they are more readable and easier to understand. If this helped you, don’t forget to like ❤️ and save 📌 this post. #java #programming #developers #coding #javadeveloper #learning #computerscience
To view or add a comment, sign in
-
🚀 Learning OOP Concept: Polymorphism in Java Today, I explored one of the core concepts of Object-Oriented Programming — Polymorphism. 🔹 What is Polymorphism? Polymorphism means “one object, many forms.” It allows methods to perform different tasks based on the object that is calling them. 🔹 Types of Polymorphism: 1. Compile-time (Method Overloading) Same method name, different parameters. 2. Runtime (Method Overriding) Same method name, same parameters, but different implementation in child classes. 🔹 Why is it important? ✔ Improves code flexibility ✔ Enhances reusability ✔ Supports dynamic behavior in applications 🔹 Simple Example: A method "draw()" can behave differently for shapes like Circle, Square, and Triangle. 💡 This concept plays a major role in writing scalable and maintainable applications. Excited to keep learning and building more with Java! ☕ #Java #OOP #Polymorphism #Programming #LearningJourney #SoftwareDevelopment
To view or add a comment, sign in
-
-
#Day32 – Polymorphism in Java 🔄 Today I focused on one of the most powerful OOP concepts — Polymorphism, which enables a single method to behave in multiple ways. 🔹 Key Learnings ✔ Polymorphism means one method → multiple behaviors ✔ Achieved using method overriding + inheritance ✔ Same method call gives different outputs based on object ✔ Enables dynamic method dispatch (runtime decision) 🔹 Core Concepts ✔ Tight Coupling → Child object with child reference ✔ Loose Coupling → Child object with parent reference (important for polymorphism) ✔ Parent reference can point to different child objects 🔹 Advanced Understanding ✔ Parent reference cannot access child-specific methods directly ✔ Requires downcasting to access specialized methods ✔ Helps in writing flexible and reusable code Write code using parent references and change behavior using different objects — this is the essence of real-world polymorphism. TAP Academy Harshit T #Java #OOPS #Polymorphism #CodingJourney #Consistency
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