Tuesday, 18 March 2025

Contact Info

  • ADDRESS: 851, LG, Sector 3F, Sector 3, Vaishali, Ghaziabad, Uttar Pradesh 201010

  • PHONE: +91 7986794481

  • E-MAIL: contact@technicalspeaks.com

  • Home  
  • What is Polymorphism in Java | Java Polymorphism | Polymorphism
- core java

What is Polymorphism in Java | Java Polymorphism | Polymorphism

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: Output: This […]

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:

Leave a comment

Your email address will not be published. Required fields are marked *

About Us

Providing expert blogs on web, SEO, tech, YouTube, and more, helping readers stay updated and grow in the digital world.

Email Us: contact@technicalspeaks.com

Contact: +91 7986794481

Sign Up for Our Newsletter

Subscribe to our newsletter to get our newest articles instantly!