Pages

Method over loading

A) Method over loading:   Writing 2 or more methods with the same name, but with a difference in the method signatures is called method over loading. In method over loading JVM understand in the method is called depending upon the difference in the method signature.
Method overriding: writing 2 or more methods in super & sub classes with same name & same signatures is called method overriding. In method overriding JVM executes a method depending on the data type of the object.
Achieving method overloading & method overriding using instance methods is an example of dynamic polymorphism.
Achieving method overloading & method overriding using instance methods is an example of dynamic polymorphism.
2) Static polymorphism:   The polymorphism exhibited at compile time is called Static polymorphism. Here the compiler knows which method is called at the compilation. This is also called compile time polymorphism or static binding.
Achieving method overloading & method overriding using
1) private 2) static 3) final methods, is an example of Static polymorphism.
Note:   A final method is a method written in a final class. A class is declared as a final is called final class.
Ex:   final class A
Note:   final key word before class name prevents inheritance. We can create sub classes to a final class.
Ex:   final class A
         class B extends A // invalid
à We can not override final methods, only final methods overloading.

          Converting 1 data type into another data type is called casting.