runtime polymorphism

runtime polymorphism

View Answers

November 21, 2009 at 11:21 AM

Hi Friend,

The run-time polymorphism is basically the Method Overriding.Here super class reference is referring to subclass object and compiler does not know which method to call.

For ex:
class Flower {
void which() {
System.out.println("A Beautiful flower.");
}
}
class Rose extends Flower {
void which() {
System.out.println("Rose");
}
}
class Lotus extends Flower {
void which() {
System.out.println("Lotus.");
}
}
class RuntimePolymorphism {

public static void main(String[] args) {
Flower ref1 = new Flower();
Rose ref2 = new Rose();
Lotus ref3 = new Lotus();
ref1.which();
ref2.which();
ref3.which();
}
}

For more information,please visit the following links:

http://www.roseindia.net/java/master-java/method_overriding.shtml
http://www.roseindia.net/java/javascript-array/modified-java-method-overriding.shtml

Thanks









Related Tutorials/Questions & Answers:
runtime polymorphism - Development process
runtime polymorphism  how run time polymorphism is achieved  Hi Friend, The run-time polymorphism is basically the Method Overriding.Here super class reference is referring to subclass object and compiler does
polymorphism
polymorphism  can we achieve without overriding polymorphism
Advertisements
dynamic polymorphism
dynamic polymorphism  give an example for dynamic polymorphism?   Dynamic polymorphism is where a class overrides a superclass method... seen at runtime, so they are considered dynamic. Here is an example
dynamic polymorphism
dynamic polymorphism  Develop with suitable hierarchy, classes for Point, Shape, Rectangle, Square, Circle, Ellipse, Triangle, Polygon, etc. Design a simple test application to demonstrate dynamic polymorphism
Polymorphism in actionscript
Polymorphism in actionscript  Hi....... Please implement How polymorphism works on actionscript? Thanks  Ans: class Worker extends Employee { override public function receivePayment():Number { return 0
Polymorphism
Polymorphism - Java Beginners
Polymorphism  what is dynamic polymorphism? with example  Hi friend, Dynamic polymorphism is run time polymorphism. Thanks  The term static polymorphism is associated with overloaded methods because
Polymorphism in Hibenate - Hibernate
Polymorphism in Hibenate  Hi, How polymorphism inheritance and association achieved in hibernate. Thank u in advance
Does hibernate support polymorphism?
Does hibernate support polymorphism?  Hi, Does hibernate support polymorphism? thanks
Polymorphism - Java Beginners
Q: Isn't it possible to detect the method's associatation, in case of method... is run (run-time polymorphism) ? Isn't java compiler having such an ability... Polymorphism means the ability to take more than one form. Polymorphism
ModuleNotFoundError: No module named 'polymorphism'
ModuleNotFoundError: No module named 'polymorphism'  Hi, My Python... 'polymorphism' How to remove the ModuleNotFoundError: No module named 'polymorphism' error? Thanks   Hi, In your python
Run time polymorphism
Run time polymorphism  What is run time polymorphism or dynamic method dispatch
Java run time polymorphism
Java run time polymorphism  What is run-time polymorphism or dynamic method dispatch
Polymorphism - Java Beginners
Polymorphism  type of polymorphism  In Java polymorphism... Or we can also say that a polymorphism is possible in both state Static and Dynamic. Coz polymorphism means in many forms. So do not get confused of it just
Polymorphism in Java 7
This tutorial describe concept of Polymorphism. It is one of OOPs concept
Dynamic polymorphism - Java Beginners
Dynamic polymorphism  Develop with suitable hierarchy, classes for point, shape, rectangele, square, circle,ellipse, triangle, polygon, etc. Design a simple test application to demonstrate dynamic polymorphism.. Thanks
Dynamic Polymorphism - Java Beginners
Dynamic Polymorphism  Develop with suitable hierarchy, classes for Point, Shape, Rectangle, Square, Circle, Ellipse, Triangle, Polygon, etc. Design a simple test application to demonstrate dynamic polymorphism.? Thanks
polymorphism - Java Beginners
polymorphism  what is polymorphism? what is the advantage of function overloading? explain the concept of operator overloading?  Hi Friend, Please visit the following links: http://www.roseindia.net/help/java/m
Polymorphism : Method Overriding
In this tutorial you will learn another concept of polymorphism that is method overriding
PHP Polymorphism Function
PHP Polymorphism Function: The PHP Polymorphism Method is one of the feature of OOP language. Generally we get polymorphism in two ways: Compile time Run time Compile time polymorphism PHP is like function overloading, operator
Polymorphism : Method Overloading
In this tutorial you will learn one of polymorphism concept that is method overloading with example in Java 7
What is Polymorphism in Java?
Polymorphism in Java means a subclass, though having its own unique behavior... IS-A relationship is polymorphic. In Polymorphism, common interface is used while writing code. Single polymorphism is achieved by method overriding while multiple
( Inheritance,need help in Polymorphism, Overriding) - Java Beginners
( Inheritance,need help in Polymorphism, Overriding)  can any one please help me create this application,thank you Advanced Concepts with Classes( Inheritance, Polymorphism, Overriding) Employees in a company are divided
Java question to implement polymorphism - Java Beginners
Java question to implement polymorphism  I have a question that i need to answer:- Using the principle of polymorphism provide implementation for the calculateFees() method for each Online Fax Subscription type
Polymorphism
; OOPs revolve around the four concepts: 1. Encapsulation 2. Polymorphism..., programmatically. Here we will discuss Polymorphism briefly: -- Polymorphism... behavior to method calls of the same name. -- Polymorphism does not allow
( Inheritance, Polymorphism, Overriding)i need help - Java Beginners
( Inheritance, Polymorphism, Overriding)i need help  Advanced Concepts with Classes( Inheritance, Polymorphism, Overriding) i need help to create this application,than you Employees in a company are divided into the classes
runtime exception hibernate
runtime exception hibernate  runtime exception hibernate
Inheretance and polymorphism - Java Beginners
Inheretance and polymorphism - Java Beginners
Inheretance and polymorphism - Java Beginners
Runtime error
Runtime error  I have written 3n+1 code in java and it gives correct o/p but when i submit my code online for my contest it says runtime error.. how to know where is problem
Runtime Class
Runtime Class  How can we halt d execution withd help of exit(arg) method?? ...pls tag a code
thread runtime process
thread runtime process  Java thread runtime process
runtime error
runtime error  still i am getting runtime error as:the specified dsn contains an architecture mismatch between the driver and application   Hi, This error is related to some OS related problem.ADS_TO_REPLACE_1 "dsn
Runtime
ModuleNotFoundError: No module named 'runtime'
ModuleNotFoundError: No module named 'runtime'  Hi, My Python... 'runtime' How to remove the ModuleNotFoundError: No module named 'runtime... to install padas library. You can install runtime python with following command
ModuleNotFoundError: No module named 'runtime'
ModuleNotFoundError: No module named 'runtime'  Hi, My Python... 'runtime' How to remove the ModuleNotFoundError: No module named 'runtime... to install padas library. You can install runtime python with following command
Version of swt>runtime dependency
List of Version of swt>runtime dependency
Version of com.jslsolucoes>runtime dependency
List of Version of com.jslsolucoes>runtime dependency
java runtime error - JDBC
java runtime error  when i m running my program using type1 driver it is showing a runtime error of SQLException of unable to create the connection object.please give the solution
JSP handle runtime exceptions
JSP handle runtime exceptions  How does JSP handle runtime exceptions?   Using errorPage attribute of page directive and also we need to specify isErrorPage=true if the current page is intended to URL redirecting
Java Runtime
Java Runtime       In this section, you will learn about Java Runtime Environment (JRE), it also known as Java Runtime. This is a part of Java Development Kit (JDK). It is a set
how to add fields at runtime in j2me
how to add fields at runtime in j2me  How can I add fields at runtime in my form? How can I switch screens and can add fields at runtime? Thanks Dhruv
Runtime shared library
Runtime shared library  Hi....... Please just tell me about What are runtime shared libraries in flex? Thanks  Ans: Run time shared library is One way to reduce the size of your applications' SWF files
Version of cobertura>cobertura-runtime dependency
List of Version of cobertura>cobertura-runtime dependency
Version of eclipse>eclipse-runtime dependency
List of Version of eclipse>eclipse-runtime dependency
Version of jetty>jasper-runtime dependency
List of Version of jetty>jasper-runtime dependency
Version of metaclass>metaclass-runtime dependency
List of Version of metaclass>metaclass-runtime dependency
Version of tomcat>jasper-runtime dependency
List of Version of tomcat>jasper-runtime dependency
Version of xtc>rats-runtime dependency
List of Version of xtc>rats-runtime dependency

Ads