Should I always annotate a class which has only protected constructors by design with abstract keyword? Why?
Let’s suppose the class does not have abstract members.
If no, could you give some examples?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
No. A type with only protected constructors is still creatable – either through a static factory method on the type, or via reflection (including, as one option, totally skipping the constructors).
An abstract type is never creatable.
Mark the type as abstract: if it is abstract. So: does it make sense for an object of that type (rather than a subclass) to exist?