example of Polymorphism in Java

Asked on February 06, 2015
Can any tell me about the Polymorphism in Java ?

Replied on February 06, 2015
Polymorphism in java is a concept by which we can perform a single action by different ways. There are two types of polymorphism in java: compile time polymorphism and runtime polymorphism. We can perform polymorphism in java by method overloading and method overriding.

Replied on February 06, 2015
// Example of polymorphism in java
package programs;
class Car {
void drive(){
System.out.println("Driving");
}
}
class Honda extends Car{
void drive(){
System.out.println("Driving at speed 45km/h is safe");
}
public static void main(String[] args) {
Honda c= new Honda();
c.drive();
}
}