Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 04-12-2008
Member
 
Join Date: Dec 2008
Posts: 31
Run - Time polymorphism with Overriden method in JAVA

Hello Friends,

I am New to this forum as well as New to the Programming world of JAVA, I am little bit confused about how run-time polymorphism takes place in the Overridden method.It would be much more helpful for me, If anyone suggest this with an self explanatory code.Please help.

Thanks for all those who replies.
Reply With Quote
  #2  
Old 04-12-2008
Member
 
Join Date: Nov 2008
Posts: 43
blush Re: Run - Time polymorphism with Overriden method in JAVA

Hi NAYASA,

I will like to help you,Check the solution below, this will help you to understand the Run Time polymorphism in Override method.

Quote:
class A
{
int num1,num2;
void calc(int a,int b)
{
num1=a;
num2=b;
}

void show()
{
System.out.println("Calling Method from A");
}
}

class B
{
super(a,b);

void show()
{
System.out.println("Calling Method from B");
return num1*num2;
}
}

class C
{
super(a,b)

void show()
{
System.out.println("Calling Method from B");
return num1*num2/2;
}
}


class override{

public static void main(String args[])

A a = new A();
B b = new B();
C c = new C();

A ref = new A();

ref =b;
ref.show();
}
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Run - Time polymorphism with Overriden method in JAVA"
Thread Thread Starter Forum Replies Last Post
Dynamic and Static Polymorphism in Java Ardent Software Development 4 19-08-2010 03:37 PM
Inheritance and polymorphism in static method Vodka Software Development 5 04-03-2010 11:46 AM
Runtime polymorphism Vs Compile time polymorphism Owen Fernandes Software Development 4 03-02-2010 11:06 AM
Is java supports polymorphism? beelow Software Development 3 19-11-2009 11:30 AM
What is method overriding and method overloading in java beelow Software Development 3 17-11-2009 08:20 AM


All times are GMT +5.5. The time now is 03:47 PM.