Presentation is loading. Please wait.

Presentation is loading. Please wait.

Bayu Priyambadha, S.Kom. * Poly = Many, Morph = form * Polymorphism refers to a principle in biology in which an organism or species can have many different.

Similar presentations


Presentation on theme: "Bayu Priyambadha, S.Kom. * Poly = Many, Morph = form * Polymorphism refers to a principle in biology in which an organism or species can have many different."— Presentation transcript:

1 Bayu Priyambadha, S.Kom

2 * Poly = Many, Morph = form * Polymorphism refers to a principle in biology in which an organism or species can have many different forms or stages * Polymorphism is the capability of an action or method to do different things based on the object that it is acting upon * Overloading, overriding and dynamic method binding are three types of polymorphism.

3 * Define two or more methods within the same class that share the same name, as long as their parameter declarations are different class Overloading { void test() { System.out.println("No parameters"); } void test(int a, int b) { System.out.println("a and b: " + a + " " + b); } void test(float a) { System.out.println("Inside test(double) a: " + a); } }

4 * Ability to define a behavior that's specific to the sub class type class Animal { public void move() { System.out.println("Animals can move"); } class Dog extends Animal { public void move() { System.out.println("Dogs can walk and run"); }

5 * has definition A mechanism by which, when the compiler can't determine which method implementation to use in advance, the runtime system (JVM) selects the appropriate method at runtime, based on the class of the object * has definition The process of binding a call to a particular method. This is performed dynamically at run-time due to the presence of polymorphism

6 * applies to data values and static members * has definition A mechanism by which the compiler determines which method implementation to use in advance, based on the type of the reference (regardless of the actual class of the object)

7


Download ppt "Bayu Priyambadha, S.Kom. * Poly = Many, Morph = form * Polymorphism refers to a principle in biology in which an organism or species can have many different."

Similar presentations


Ads by Google