What do you meant by Runtime Polymorphism?
Answer Posted / swe
In runtime polymorphism ... the code is called at run time according to need or given conditions.
suppose there r two methods namely Add() one in super class and other is in sub class.both have the same name and same parameters.
so we have to choose that which method from them shld called at run time i.e. of super class or of sub class.by polymorphism we do that.
ex:-
class A
{
int add(){//code of the method}
//some other code
}
class B extends A
{
int add(){//code of the method}
//some other code
}
class AB
{
public static void main(String s[])
{
A ob1;
ob1 new A();
int i ob1.add();//will call the method of super class.
ob1 new B();// sub class's reference can be assigned to super class address but not vice versa.to do that we have to type cast the reference of the sub class in reference of the super class.
int j ob1.add();//will call the method of sub class
}
| Is This Answer Correct ? | 1 Yes | 1 No |
Post New Answer View All Answers
What is SOLID Principle in Programming Language?
Given an array of size n+1 which contains all the numbers from 1 to n.Find the number which is repeated in O(n) time.How do you proceed with the same with floating numbers from 0 to 1 instead of 1 to n?
4. What is the need of START 0? Instead if can we use any other numeric? If we use what will happen?
How does the type system works when there is interoperability between a COM and .Net, i mean what exactly happens there
HOW TO FIND NUMBER OF TWOS IN N!(N FACTORIAL)??
what is the extension of SPDS Dynamic cluster tables?
why we use mantis? what u mean mantis in IT trends? addvantages of mantis?
when we use mantis? how learn mantis?
My Qualification is MCA.My interview is on 5th may.They may ask q as------AS u r MCA...Why u r not tring anywhere else? What can be the ans?
Write a program to find factorial of a number using functions
what is session state?
Find out the list of roles which gives access to GUI activities? thanks in advance
Find out the roles which gives access to all tables in SAP? Thanks in advance.
if 3 duplicate records, by keeping one original and one duplicate record, and how to delete remaining 2 duplicates in sql server 2008
What is autocall macro and how to create autocall macro? what is the use of it?