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
How to know we are in home page of a web application using QTP
What is the meaning of client-server application. The purpose of Client-Server Application. with description.
What is the entry point function of a DLL?
please any one pass file aid,xpeditor and endeavor tools
hii I inntrested abt scjp certification but i dont knw abt scjp plz send details abt scjp exam and syllabus.
what are the differences between CONS, LIST, and APPEND
Plz sent me in .net 2.0 interview Question & answers?
Please describe an example where you used object orientation in one of your programs.
how to fin top two miximum values in sql? not 2nd both max value of 1st and 2nd both have to find out
What is BASIS
How many forms can you create in a Visual Basic 6 Standard EXE project? Is there any limit on that?
what are the missinschema properties and should we pass primary key in select command
You are given some denominations of coins in an array (int denom[])and infinite supply of all of them. Given an amount (int amount), find the minimum number of coins required to get the exact amount. What is the method called?
Definition of Singleton Class? what is the Purpose of it? what is the advantage?
Hai, My name is nisha.I have NIC exam.If anybody Knows NIC previous paper pattern pls send me to nishanairp@gmail.com