Saturday, Aug 8, 2026 · Practical tutorials, weekly

What is Polymorphism in Java | Java Polymorphism | Polymorphism

S Saurabh K Jul 11, 2020 1 min read 0 comments

Java Polymorphism

Polymorphism is one of the most important concept in OOPS and also It is beneficial for any other programming languages.

Made from two words:

1. “Poly” means “many”
2. “morphs” means “forms”

Polymorphism – A single action in different ways…

Same methods in different class to perform different tasks – Polymorphism…

Program:

class Subject{
public void subjectName() {
System.out.println(“This is Subject Name”);
}
}
class Physics extends Subject {
public void subjectName() {
System.out.println(“Subject is Physics”);
}
}
class Mathematics extends Subject{
public void subjectName() {
System.out.println(“Subject is Mathematics “);
}
}
class MyMainClass {
public static void main(String[] args) {
Subject mySubject = new Subject();
Subject myPhysics = new Physics();
Subject myMathematics = new Mathematics();
mySubject.subjectName();
myPhysics.subjectName();
myMathematics.subjectName();
}
}

Output:

This is Subject Name

Subject is Physics

Subject is Mathematics

Connect with us:

Share:
Saurabh K

Saurabh K

Author at Technical Speaks

Writes practical guides and tutorials to help readers build, rank, and grow online.

Leave a Comment

Newsletter

Stay ahead of the curve

Join readers getting our freshest tutorials and guides on web, SEO, tech & more — delivered weekly.