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...

Explain constructor.

Answer Posted / vinay tiwari

//Constructor is a special member function its name is same
//as class name.It is used to allocate memory to object and
initilizes
//its field .you can also say that it is used to initilized
the object
//constructor invoke automatically when the object of its
class is created
class a
{
public int i;
public a()//default constructor
{
i=10;
}
public a(int x)//parameterized constructor
{
i=x;
}
public a(a ob)//copy constructor
{
i=ob.i;
}
public void display()
{
System.Console.WriteLine(i);
}
}
class b
{
static void Main(string [] args)
{
a ob=new a();
ob.display();
a ob1=new a(77);
ob1.display();
a ob2=new a(ob);
ob2.display();
}
}

Is This Answer Correct ?    10 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Will the following code compile and run?

979


Can we extend static class in c#?

905


How can you set image source dynamically from c# application to ”test.png” file?

1073


Why do we use delegates?

851


Why do I get a "cs5001: does not have an entry point defined" error when compiling?

992


What do you understand by 'access specifiers' in C#?

892


Is c# a backend language?

967


Why are strings immutable c#?

924


Can scriptable objects have methods?

889


What does void mean unity?

943


What is string concatenation?

983


Is arraylist generic in c#?

877


In languages without exception-handling facilities, we could send an error-handling procedure as a parameter to each procedure that can detect errors that must be handled. What disadvantages are there to this method?

1115


Why to use “finally” block in c#?

1093


What is meant by console programming?

916