Home  >  Forum  >  Core Java
Post New Query

example of Polymorphism in Java


joined on
September 16,2014
Asked on February 06,2015
Can any tell me about the Polymorphism in Java ?
joined on
September 16,2014
Replied on February 06,2015

Polymorphism in java is a concept by which we can perform a single action by different waysThere 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.
joined on
March 15,2013
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();
 }
 }


Write Answer








Copyright ©2017 concretepage.com, all rights reserved |Privacy Policy | Contact Us