473,573 Members | 2,476 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Polymorphism in Java

3 New Member
What is the difference between static and dynamic Polymorphism in java?
Jan 2 '16 #1
4 18624
5,501 Recognized Expert Moderator Expert
Vikas Rana, is this a homework question?
Such threads are usually closed when found.
Jan 2 '16 #2
Ishan Shah
47 New Member
Static polymorphism is a type of polymorphism, which collects data to call a method during compilation. Whereas dynamic polymorphism is a type of polymorphism that collects information for calling a method at the time of execution. So that's the main difference between static and dynamic polymorphism.
Feb 12 '21 #3
22 New Member
Polymorphism is a fundamental concept in object-oriented programming (OOP) and refers to the ability of an object to take on many forms. In Java, polymorphism is achieved through method overloading and method overriding.

Method overloading allows multiple methods to have the same name but with different parameters. When a method is called, Java determines which version of the process to execute based on the number and types of arguments passed to it.

Here is an example of method overloading in Java:
public class MyClass {

public void myMethod(int num) {

System.out.prin tln("This is an integer: " + num);


public void myMethod(String str) {

System.out.prin tln("This is a string: " + str);


public void myMethod(double dbl) {

System.out.prin tln("This is a double: " + dbl);



In this example, the `myMethod` method is overloaded three times with different parameter types. When called, the appropriate version of the method is executed based on the argument passed.

Method overriding occurs when a subclass provides a specific implementation of a method that is already defined in its superclass. This allows the subclass to inherit the methods of the superclass while still being able to customize their behavior.
Mar 9 '23 #4
14 New Member
Static polymorphism is a type of polymorphism, which collects data to call a method during compilation.
Whereas dynamic polymorphism is a type of polymorphism that collects information for calling a method at the time of execution.
So that's the main difference between static and dynamic polymorphism.
Mar 20 '23 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Jerry | last post by:
What are the advantages and disadvantages of using Object Oriented PHP vs Java?
by: Gurtaj | last post by:
Hello! I am working with PHP and MySQL in a proyect with some partners of our university, and we are thinking about building some classes and use inheritance and polymorphism. The problem is that we are not sure of PHP implementing polymorphism and we couldn't find info about it. I will really appreciate if someone could give us some...
by: Mayer Goldberg | last post by:
Can someone please explain the motivation behind the following restriction in the language: I define an interface and two classes implementing it: public interface InterA {} public class B implements InterA {} public class C implements InterA {}
by: rashkatsa | last post by:
Hi all ! I have written a little module called 'polymorph' that allows to call different methods of a class that have the same name but that have not the same number of arguments. *args are supported. You could find the module attached to this message. As in python, you could not define two method with same name (the second one override...
by: Steve Jorgensen | last post by:
The classing Visual Basic and VBA support for polymorphism, let's face it, is a bit on the weak side, and built-in support for inheritance is non-existent. This little essay is about some patterns I've ended up using successfully for certain kinds of inheritance and polymorphism, and some that have not worked out so well. Let's start with...
by: Mike | last post by:
Attached below is a file that implements polymorphism in C. It's loosly based on the way Miro Samek describes it (http://www.embedded.com/97/fe29712.htm). I found the article a little confusing so I made some changes and came up with wat's below. It appears to work, but I've written plenty of programs before that seemed to work, but didn't....
by: G.Ashok | last post by:
Hi, Does anybody know how Multiple polymorphism can be done in VB.NET or DOT doesn't support it? Is there any third party extensions available like for Java to do this? Regards, ....Ashok ------------------------------------------------------------------------ "It is beautiful for an engineer to shape and design the same way
by: chsalvia | last post by:
I've been programming in C++ for a little over 2 years, and I still find myself wondering when I should use polymorphism. Some people claim that polymorphism is such an integral part of C++, that anybody who doesn't use it might as well just program in plain C. I totally disagree with this, because I think C++ has a lot of great features...
by: =?utf-8?B?Qm9yaXMgRHXFoWVr?= | last post by:
Hello, (sorry to begin with Java in a Python list ;-) in Java, when I want to pass input to a function, I pass "InputStream", which is a base class of any input stream. In Python, I found that "file" objects exist. While specifying argument types in Python is not possible as in Java, it is possible to check whether an object is an...
by: r035198x | last post by:
Inheritance We have already covered one important concept of object-oriented programming, namely encapsulation, in the previous article. These articles are not articles on object oriented programming but on Java programming but I will cover all the important aspects of object oriented programming as Java has full support for object-oriented...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.