Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7904831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:15:11+00:00 2026-06-03T10:15:11+00:00

Constructors of an abstract class shouldn’t be public and they should be protected .

  • 0

Constructors of an abstract class shouldn’t be public and they should be protected. My question is about methods in that abstract class. Can we declare them as public or they should be protected too for the same reason?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T10:15:12+00:00Added an answer on June 3, 2026 at 10:15 am

    The justification for constructors on abstract types being protected is that there is simply no other entity that could call the constructor other than a derived type. Making the constructor public is meaningless in this case as it can’t ever be invoked outside the type hierarchy. Hence the recommendation is to use protected as it’s the most appropriate access modifier.

    The same logic doesn’t hold true with other members on the type. They can be freely invoked from outside the type hierarchy should their access modifier permit it.

    public abstract class Dog {
    
      // Public is appropriate here as any consumer of Dog could access
      // Breed on an instantiated object
      public abstract string Breed { get; }
    
      // Public would be meaningless here. It's not legal to say 
      // 'new Dog' because 'Dog' is abstract. You can only say 
      // 'new Poodle' or 'new Bulldog'.  Only derived types like
      // Poodle or Bulldog could invoke the Dog constructor hence it's
      // protected
      protected Dog() { }
    }
    
    public class Poodle : Dog { } 
    public class Bulldog : Dog { }
    

    Whether or not a particular member should be public or protected is highly dependent upon the particular API. The reasoning should be the exact same for abstract types as it is for non-abstract types

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In base class constructors I always see a parameterless constructor, like so: public abstract
Is a public constructor in an abstract class a codesmell? Making the constructor protected
If a public constructor in an abstract class can only be called by their
Is there any relevance of a public constructor in an abstract class? I can
Original Question Consider the following scenario: public abstract class Foo { public string Name
I am writing an abstract class and I have a variable that should be
I have a Base Class with two constructors, requiring a parameter: public abstract class
I find that my constructors are starting to look like this: public MyClass(Container con,
I've implemented an abstract factory like this public abstract class AbstractFactory { private static
I have a class TreeNode: public abstract class TreeNode<T>{ . . . public Collection<TreeNode<T>>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.