CSharp - What is the output: private constructors

Question

What is the output from the following code

using System;
class ParentClass
{
    private ParentClass() { }
    public void ShowClassName()
    {
        Console.WriteLine("Inside Parent.ShowClassName");
    }
}
class ChildClass : ParentClass //Error
{
    //Some code
}


Click to view the answer

the program will give you a compilation error.

Note

If a class has only private constructors, it cannot be sub classed.

Related Quiz