Mid OOP

Can abstract classes have constructors?

  • Yes, constructors are used to initialize fields in derived classes.

abstract class Vehicle

protected string Brand;

public Vehicle(string brand) { Brand = brand; }

class Car : Vehicle

public Car(string brand) : base(brand) { }

More from C# Programming Tutorial

All questions for this course