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
when we use mantis? how learn mantis?
in cobol,wat is the difference in using 'set index in occurs clause' ....and 'occurs depending-on clause'
Display names and numbers of employees who have 5 years or more experience and salary less than Rs.15000 using array of structures (name, number, experience and salary)
Is buffer size and file block size is similar? If similar,at which case it will be same size?
write a sql qwery which include joining of two tables 4 marks mainframe
is it acceptable if we declare multiple exceptions in same overridden method.
What binary value will be internally stored for NULL for the type S9(1) COMP 3 in mainframe
What is the Difference between in memory database and physical database
Write a function which accepts a sentence as input parameter.Each word in that sentence is to be reversed. Space should be there between each words.Return the sentence with reversed words to main function and produce the required output. for eg:- i/p: jack jill jung kill o/p: kcaj llij gnuj llik
When we delete logfiles such as screenshots how does it affect the ldf file? Ive seen huge change while adding screenshots in the ldf file but a very minor one deleting them.Please Explain
Hai, My name is nisha.I have NIC exam.If anybody Knows NIC previous paper pattern pls send me to nishanairp@gmail.com
How to connect to ms word wit VB ojective is to prepare s/w to generate question paper , selects questions randomly from the ms access , database
what is the certificates in biztalk?
can we retrieve only integer/String type columns from a table,if yes how?
I am work in it aompenei