Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What is a private constructor? where will you use it?

Answer Posted / ramkishore mateti

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 ?    29 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the difference between a namespace and assembly name in .net?

884


Can abstract class have constructor?

814


What tool we have to use to install assembli in gac folder.

854


What is a delegate how is it type safe?

812


What is wpf c#?

830


What is array and types of array in c#?

941


When should I use static in C#?

935


Is it good to use var in c#?

808


How do partial classes work in c#?

879


Okay, so an int is a value type, and a class is a reference type. How can int be derived from object?

893


What is Assembly. and Describe type of assembly. why most developer happy with private assembly.

914


What is sqlconnection in c#?

867


Define c# delegate?

947


Name some string escape sequences in c#.

989


Is boxing an implicit conversion?

968