No Virtual Keyword In Java And No Final Keyword In C# Explained
Contents
- Java and C# Methods Behaviour Difference
- Why C# Implements Methods As Non-Virtual By Default?
- How Java Deal With This?
- References
Note: If you are new to object oriented programming and don’t know about polymorphism much please refer this post before proceeding further.
Java and C# Methods Behaviour Difference
When you write any method in Java you are actually writing a virtual method because Java implements it by default, and to make it non-virtual we have to make use of final keyword in Java. However, In C# all methods you write are final (non-virtual) by default and to make it virtual you have to use virtual keyword.