3.3. The OOP Model
Both C# and Java are object-oriented languages, with some striking differences and similarities in how they implement the object-oriented programming (OOP) model. Table 3.2 compares the Java and C# object-oriented programming models.
One of the most important differences between the OOP model used by Java and that of C# is that in Java all methods are, by default, virtual. This means that the method call is always on the object instantiated. Therefore,
A a = new B();
where class B inherits from A.
Calling a method on the reference a will call a method on the instantiated class B. This is not the case in C#. The method is called on the reference a unless it is explicitly marked as virtual by the superclass A and is explicitly ...
Get .NET for Java Developers: Migrating to C# now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.