1. An abstract class can still be implemented: it can have members, non-abstract methods or attributes, and the interface cannot have implementations and member variables.
2. A. Net class can only be derived from a base class, that is, the base class is abstract. However, A. Net class can implement multiple interfaces as needed.
3. abstract classes can be derived from other classes or from one or more interfaces, while interfaces can only be derived from another interface.
4. abstract classes can have common methods and attributes. Even if they are abstract, all the Members in the interface are not public.
5. abstract classes can contain static methods and static members, and define constants at the same time. Interfaces do not contain any of them.
Appendix: typical examples of abstract classes:
Using system;
Abstract class vehicle // defines the vehicle class
{
Public int wheels; // Public Member: Number of wheels
Protected float weight; // protected member: Weight
Public Vehicle (int w, float g ){
Wheels = W;
Weight = g;
}
Public Virtual void speak (){
Console. writeline ("the W vehicle is speaking! ");
}
};
class car: Vehicle // defines the car type
{< br> int passengers; // Private member: number of passengers
Public Car (int w, float g, int P): Base (W, g)
{< br> wheels = W;
Weight = g;
passengers = P;
}< br> Public override void speak () {
console. writeline ("the car is speaking: di-di! ");
}< BR >}
Class truck: Vehicle // define the truck class
{
Int passengers; // Private member: Number of passengers
Float load; // Private member: Load
Public truck (int w, float g, int P, float L): Base (W, g)
{
Wheels = W;
Weight = g;
Passengers = P;
Load = L;
}
Public override void speak (){
Console. writeline ("the truck is speaking: Ba-Ba! ");
}