ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   SiteMap shows list of All Categories in this site.
Google
 
Categories  >>  Software  >>  Microsoft Related  >>  C Sharp
 
 


 

 
 Visual Basic interview questions  Visual Basic Interview Questions
 C Sharp interview questions  C Sharp Interview Questions
 ASP.NET interview questions  ASP.NET Interview Questions
 VB.NET interview questions  VB.NET Interview Questions
 COM+ interview questions  COM+ Interview Questions
 ADO.NET interview questions  ADO.NET Interview Questions
 IIS interview questions  IIS Interview Questions
 MTS interview questions  MTS Interview Questions
 Crystal Reports interview questions  Crystal Reports Interview Questions
 BizTalk interview questions  BizTalk Interview Questions
 Dot Net interview questions  Dot Net Interview Questions
 Exchange Server interview questions  Exchange Server Interview Questions
 SharePoint interview questions  SharePoint Interview Questions
 Microsoft Related AllOther interview questions  Microsoft Related AllOther Interview Questions
Question
What is a private constructor? where will you use it?
 Question Submitted By :: Kiran
I also faced this Question!!     Rank Answer Posted By  
 
  Re: What is a private constructor? where will you use it?
Answer
# 1
we can declare the constructor private  ,it is called
private constructor.
 
Is This Answer Correct ?    1 Yes 5 No
Sri
 
  Re: What is a private constructor? where will you use it?
Answer
# 2
When you declare a Constructor with Private access modifier 
then it is called Private Constructor.

If you declare a Constructor as private then it don't allow 
to create object for its derived class,i.e you loose 
inhirect facility for that class.
Ex:
Class A
{
// some code
 Private Void A()
 {
 //Private Constructor
 }
}

Class B:A
{
//code
}

B obj = new B();// will give Compilation Error

Because Class A construcor declared as private hence its 
accessbility limit is to that class only ,Class B can't 
access. As i explained the heirarchy of Constructors in the 
previous qn, when we create a object for Class B that 
constructor will call constructor A but class B have no 
rights to access the Class A constructor hence we will get 
compilation error.
 
Is This Answer Correct ?    18 Yes 0 No
Ramkishore Mateti
 
 
 
  Re: What is a private constructor? where will you use it?
Answer
# 3
When we want to control the object instantiation 
or trying to implement singleton pattern
 
Is This Answer Correct ?    6 Yes 1 No
Nitesh
 
  Re: What is a private constructor? where will you use it?
Answer
# 4
private constructor access only that class. we can't access 
in other class.we can use the private constructor in 
singleton patteren.
 
Is This Answer Correct ?    3 Yes 0 No
Dsr
 
  Re: What is a private constructor? where will you use it?
Answer
# 5
In singleton pattern the constructor is not private but
protected.

Go for private constructor when your class has methods which
do not require object creation. ex. (Math class in c#).
Like If your class has all static method, you need not to
create an object in that case go for private constructor.
 
Is This Answer Correct ?    1 Yes 0 No
Saurabh
 

 
 
 
Other C Sharp Interview Questions
 
  Question Asked @ Answers
 
why do we use Overloading, Overriding, Boxing, Unboxing, and what is the use of these ? eXensys2
What C# keyword class access modifier specifies that the class is concrete and CANNOT be derived from?  3
In Main function another function is there and to that function if we pass string as parameter ,then that string value is passed by value or reference type? Honeywell3
An abstract class is inherited, an Interface also inherited(multiple inheritance), How it differences. Synechron1
Diff b/w casting and boxing Wipro4
datagridview using updata in windows c#  1
How to assign default value to nullable types? Did nested nullable types are allowed TCS2
Why multiple inheritance is not possible in c#  4
What?s a delegate?  2
int i,string s, String s1 Which is valuetype which is refrence type. Synechron3
What are strin concatation methods in c#? Phoenix-Technologies1
what is an internal specifier? what happens internally when I use access specifier Internal ? rsystems4
what is a template? Choice-Solutions2
What?s the difference between the System.Array.CopyTo() and System.Array.Clone()?  4
Can multiple catch blocks be executed?  4
What?s a multicast delegate? Visual-Soft2
What is Serialization and how do we implement (in real time scenario)  1
Did it possible to cast a generic type of derived class to generic type of base class? TCS1
Use of Checked and UnChecked operators? TCS1
When static constructor is invoked? TCS6
 
For more C Sharp Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com