It achieves it by implementing the object-oriented paradigm.
Inheritance.
Runtime prolymorphism means overriding compiletile polymorphism means overloading
Polymorphism, is an object-oriented programming concept, which relates to the ability to create a variable, function or an object that has more than one form. This allows the object to invoke the correct instance of the variable, function or other object based upon the object type. The most common use of polymorphism in OOP occurs when a parent class reference is used to refer to a child class object. Here are some links to examples: C++: http://www.cplusplus.com/forum/beginner/10884/ c#: http://msdn.microsoft.com/en-us/library/ms173152.aspx Python: http://en.wikipedia.org/wiki/Polymorphism_in_object-oriented_programming Java: http://www.tutorialspoint.com/java/java_polymorphism.htm
The main difference is that: neither of them are related to one another. They have nothing similar between them and are totally different. The only point here is that they are both used in Java which can be stated as a similarity. Inheritance is the feature wherein functionality from one class is available for another class. Polymorphism refers to the feature wherein the same entity exists as multiple items. Ex: method overriding, method overloading etc.
method overloading is the primary way polymorphism is implemented in JavaOverloading methodsoverloaded methods: appear in the same class or a subclasshave the same name but,have different parameter lists, and,can have different return types
Overloading, Overriding, Polymorphism, Information Hiding, Inheritance all these are CONCEPTS of C++ and Java. An Object Oriented Language and not of C language. Thats why Bjarne Stroustrup came up with C++ ...
The dictionary definition of polymorphism refers to a principle in biology in which an organism or species can have many different forms or stages. This principle can also be applied to object-oriented programming and languages like the Java language. Subclasses of a class can define their own unique behaviors and yet share some of the same functionality of the parent class.Overriding and Overloading are two techiques to achive polymorphism in Java.Method overloading: When a method in a class having the same method name with different arguments is said to be method overloading. Method overriding : When a method in a class having the same method name with same arguments is said to be method overriding.
The C language does not support classes, per se, like the C++ language does. The closest the C language comes to a class is in the typdef struct... typdef struct _myClass { ... ... }; myClass; But you won't have any methods, inheritance, polymorphism, operator overloading, access specifiers, etc. like you do in C++.
Compile Time Polymorphism in Java is when you have the several methods with same name and different parameters and compiler has to decide how to select which method has to run based on the arguments hence the name Compile time polymorphism or method overloading.
Some of the key OOPS principles are: Encapsulation - The ability to make changes in your code without breaking the code of all others who use your code is a key benefit of encapsulation. You should always hide implementation details. To elaborate, you must always have your variables as private and then have a set of public methods that others can use to access your variables. Since the methods are public anyone can access them, but since they are in your class you can ensure that the code works the way that is best for you. So in a situation that you want to alter your code, all you have to do is modify your methods. No one gets hurt because i am just using your method names in my code and the code inside your method doesnt bother me much. If you want maintainability, flexibility, and extensibility (and I guess, you do), your design must include encapsulation. You do that by: • Keep instance variables protected (with an access modifier, mostly private). • Make public accessor methods, and force calling code to use those methods rather than directly accessing the instance variable. • For the methods, use the JavaBeans naming convention of set and get. Inheritance - Inheritance is the feature by which functionality in one class is used in another class. It creates a parent child relationship between classes. Polymorphism - Polymorphism refers to the feature wherein the same entity exists as multiple items. Ex: method overriding, method overloading etc.
The polymorphism concept is similar for all objected oriented languages the defination is same and function too. The polymorphism is defined below. "one name multiple form" The explaination is that the polymorphism is combination of two words "poly" means many and "morphism " means form .the function overloading could be example for it. void sum(int,int) void sum(float,float) void sum(double,int) void sum(int,float) in above example the function name is same but only signature is different. and therefore this can be easily implemented in java. posted by: Girija Shankar jaiswal contact no.+919453755840
JAVA is an Object Based Programming Language. it doesn't provide multiple inheritance and operator overloading. while Object Oriented Lanuages provides both.