2

I have noticed that MSDN is very careful about the terms "inherit" and "implement".

We implement interfaces, but inherit non-abstract classes. I suppose that full methods of abstract class are inherited, but abstract methods are implemented.

  • What term should we use when an abstract class consists of both full and abstract methods? Abstract class has no instances on one hand (this is a characteristic of an interface), on other hand it may contain full methods (this is a characteristic of a class).
Am_I_Helpful
  • 18,735
  • 7
  • 49
  • 73
Anton Lyhin
  • 1,925
  • 2
  • 28
  • 34
  • 1
    "extends" and "inherits from" are used interchangeably in most OOP languages to indicate deriving from a base class, whether or not the base class is abstract or not doesn't change the relationship. The addition of extension methods is reason enough to not confuse things by using "extends" for inheritance relationships when discussing .net, IMO. "implements" always refers to implementing an interface. – Preston Guillot Feb 24 '16 at 19:15
  • 1
    suppose, you should use term "override" – T.S. Feb 24 '16 at 21:30
  • A class that inherits from another class may override virtual methods of its base class (and it *must* to if those methods are abstract), but an inheritance relationship doesn't necessarily imply overridden behavior, e.g. a valid (albeit likely poorly thought out...) inheritance relationship may only include adding additional methods/fields to a sub-class, without overriding any behavior at all. – Preston Guillot Feb 25 '16 at 17:06
  • A class could override only a few (not all) virtual methods from its base abstract class if it is also declared abstract. – Marco Guignard Aug 16 '16 at 10:48

1 Answers1

5

I suppose that full methods of abstract class are inherited, but abstract methods are implemented.

NO. Abstract methods(defintion) are overridden by base class' overriding methods.

An abstract method declaration introduces a new virtual method but does not provide an implementation of that method. Instead, non-abstract derived classes are required to provide their own implementation by overriding that method.

What term should we use when an abstract class consists of both full and abstract methods?

The definition of abstract class itself states that it could contain methods defintions as well, but it should have at least one abstract method.

Abstract class has no instances on one hand (this is a characteristic of an interface), on other hand it may contain full methods (this is a characteristic of a class).

Abstract class is obviously a category of a class.

Am_I_Helpful
  • 18,735
  • 7
  • 49
  • 73
  • I have not seen the term "extend" in .net. It is possible to create an abstract class without abstract methods and there is no compilation errors, I have just checked it. – Anton Lyhin Feb 24 '16 at 19:06
  • @Spirit you didn't have to check. I could tell you. The only thing word "abstract" does, it prevents to create direct instance of the class without being inherited. Otherwise, it can look just like regular class, with constructor, etc. I mean, potentially. Of course, the other thing it does, allows for virtual methods – T.S. Feb 24 '16 at 21:41
  • 1
    Virtual methods can be defined on any non-sealed class in C#, *abstract* methods can only be defined on abstract classes. – Preston Guillot Feb 25 '16 at 17:32
  • @PrestonGuillot - I agree, but, I think this was not asked in the question. – Am_I_Helpful Feb 25 '16 at 17:34