TGViewer
Java Programming Java Programming @java_programming_notes · 33.2K subscribers
Post #1101 7.19K
Polymorphism in Java

📍 Polymorphism allows a single interface to be used for different types of actions.
📍 It is of two types:

Method Overloading (Compile-time Polymorphism)

Method Overriding (Runtime Polymorphism)


Method Overloading (Same method name, different parameters)

class MathOperations {
int add(int a, int b) {
return a + b;
}

double add(double a, double b) {
return a + b;
}
}

Method Overriding (Same method in parent and child class)

class Animal {
void makeSound() {
System.out.println("Animal makes a sound");
}
}

class Dog extends Animal {
void makeSound() {
System.out.println("Dog barks");
}
}

🔗 More Java Resources: https://whatsapp.com/channel/0029VamdH5mHAdNMHMSBwg1s
  • ❤ 16
More from @java_programming_notes
  1. Sep 23, 2026Important LLM Terms 🔹 Transformer Architecture 🔹 Attention Mechanism 🔹 Pre-training 🔹…
  2. Sep 19, 2026Java projects with tutorial 🚀 Supermarket Management: https://youtube.com/playlist?list=P…
  3. Sep 15, 2026Q5. Why should files be closed? 👉 To release resources and ensure pending data is properl…
  4. Sep 15, 2026import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; clas…
  5. Sep 15, 2026📁 Java File Handling (Important ⭐) File Handling allows Java programs to create, read, wr…
  6. Sep 14, 2026Best YouTube Playlists to learn Programming 👇 1/ Python: https://www.youtube.com/playlist…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →