Virtual Function in JAVA

Author posted by Jitendra on Posted on under category Categories JAVA and tagged as Tags with 15 Comments on Virtual Function in JAVA

Example and explanation of Virtual Function in JAVA

The programmers coming from c++ background to Java normally think that where is the Virtual function?  In Java there is no keyword names “virtual“.

Definition of Virtual from wiki:

In object-oriented programming, a virtual function or virtual method is a function or method whose behaviour can be overridden within an inheriting class by a function with the same signature to provide the polymorphic behavior.

Therefore according to definition, every non-static method in JAVA is by default virtual method except final and private methods. The methods which cannot be inherited for polymorphic behavior is not a virtual method. Continue reading “Virtual Function in JAVA”