Is the member function virtual by default

Is member function virtual by default in scala? Is this different from Java in this matter?

When a method is overridden, you must explicitly specify this, but there is no "virtual" one.

+4
source share
2 answers

Is member function virtual by default in scala?

Yes.

Is this different from Java in this matter?

No, in Java methods are also virtual unless explicitly defined as final .

However, Java differs from Scala in that Java does not require (or does not have) the override keyword to override methods - it has an @override annotation, although (since Java 1.5) it gives a warning when overriding a method without this annotation.

+5
source

Is member function virtual by default in scala?

Yes.

Is this different from Java in this matter?

No. However, it is different from C ++ or C #.

Whether this is a good or bad idea is very reasoned.

+2
source

Source: https://habr.com/ru/post/1437411/


All Articles