You have the following code (line numbers are included for reference only):
You need to ensure that new instances of Connection can be created only by other classes by calling
the Create method. The solution must allow classes to inherit from Connection.
What should you do?

A.
Option A
B.
Option B
C.
Option C
D.
Option D
Explanation:
The following list provides the main features of a static class:
* Contains only static members.
* Cannot be instantiated.
* Is sealed.
* Cannot contain Instance Constructors.
Creating a static class is therefore basically the same as creating a class that contains only static
members and a private constructor. A private constructor prevents the class from being instantiated.Static Classes and Static Class Members (C# Programming Guide)
https://msdn.microsoft.com/en-us/library/79b3xss3.aspx
A
0
0
no, because you cannot instantiate an abstract class.
0
0
D – The solution should allow inheritance. Static classes cannot be inherited.
0
0
C
with the private constructor you disallow the class to be constructed with the default constructor so you will need to call that Create method.
0
0
you are right about the private constructor, but C is wrong because of the inheritance detail:
The solution must allow classes to inherit from Connection.
by using a protected constructor you allow inherited classes to have a parameterless ctor
the right answer is D
1
0
Check Comments in:
http://www.aiotestking.com/microsoft/you-need-to-ensure-that-new-instances-of-connection-can-be-created-only-by-other-classes-by-calling-the-create-method/
0
0
D
0
0
Yes answer should be D
A–>you get compile error at 05: can not create an instance of abstract class
B–>static classes can not be inherited
C–> class is inaccessible due to its protection level
1
0
answer is D.
The keyword “protects” the class from having its’ constructor called by external classes. However unlike the private keyword, protected will allow derived classes to access the class member.
So what good is it? Classes that use it will employ other means to create instances of the class. A static “CreateInstance” method within the class can call the protected constructor and return an instance.
1
0
D
0
0