‎2006 Mar 29 2:11 PM
Guys,
I need some sample programs on polymorphism using oops.
If u provide it will be very helpful to me.
<<removed by moderator>>
regards,
vijay
‎2006 Mar 29 2:14 PM
Hi,
Check this examples <b>demo_interface</b>
<b>demo_inheritance</b> in SE38.
Regards
Vijay
‎2006 Mar 29 2:27 PM
Hi Vijay,
Polymorphism is the property of OOP whereby it allows one interface to be used for a general class of actions.It means you can ask different objects to perform different implementation in a similar way of calling.
I have also sent u a program on Polymorphism.
Regards,
Sylendra.
‎2008 Nov 02 8:21 PM
hi,
its a characteristic of OOPS wher objects fr different class react differently 2 same function call.
Shape.java
public interface Shape{
public void draw(){
}
}
Square.java
class Square implements Shape{
public void draw(){
System.out.println("Drawing a square.....");
}
}
circle.java
class Circle implements Shape{
public void draw(){
System.out.println("Drawing a Circle....");
}
}
class ShapeGenerator{
Shape shape;
public void drawSquare() {
shape=new Square();
shape.draw();
}
public void drawCircle(){
shape=new Circle();
shape.draw();
}
}
Edited by: Marcelo Ramos on Jan 6, 2009 11:36 AM