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 does the type system works when there is interoperability between a COM and .Net, i mean what exactly happens there
How do i find out the number of parameters passed into function?
a characteristic of a multiprogramming is? a.simultaneous exe of pgm instr 4m 2 appli b.concurrent processing of 2 r more prgms c.multiple cpu s d.all the abov
Definition of Singleton Class? what is the Purpose of it? what is the advantage?
qtp 9.2 14 days demo version was expired.I uninstalled how to reinstall this again
how much fee for deccan soft institute .how to block seat for sandeep sir class reply soonnnn
how do find the user exit for selected feild whatis the process and can u plz explain it
What is BASIS
What are two of your strengths that you will bring to our QA/testing team?
what will we require to build project with the help of oracle
code for connection from windows forms to sql server
1. How many jobs can we write in a single file? 2. How many maximum members can exist in a single partition data set(pds) in jcl?
what are the differences between CONS, LIST, and APPEND
1. Consider the following code in our example assembly language: ; an example bit of assembly code ROOT: W FATHER FATHER: W SON1 W SON2 SON1: W NIL W NIL ; ---------------------- SON2: W GRANDSON W NIL GRANDSON: W NIL W NIL NIL = 0 Assemble this code carefully following the two pass model, and show the symbol table at the point marked by the dashed line during each pass.
Q1.Write a C program which asks the user for a number between 1 to 9 and shows the number. If the user inputs a number out of the specified range, the program should show an error and prompt the user for a valid input.