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 / k.gnaneshwar

*-> Constructor is used for initializing the variables
during object creation.
*-> that means the code required for initializing the
variable should be writen in constructor.
CONSTRUCTOR DECLARATION RULES
* Constructor look like a method.
* Constructor have no return type.
* Constructor name should be same name as the class name.

(prog)

class simpleAddition
{
int a,b; //variable declaration
simpleAddition() //constructor declaration
{
a=6;
b=3;
}
int add() // method declaration
{
return a+b;
}
}

output:- 9

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is there any sample c# code for simple threading?

886


Can you specify an access modifier for an enumeration?

933


what is an exception in .net?

899


How do you determine whether a string represents a numeric value?

886


What is the main purpose of xml?

879


What is the use of 0 in c#?

954


What is meant by enumerable in c#?

906


What is hierarchical inheritance in c#?

919


What are get and set in c#?

959


Can we use "this" command within a static method?

931


Why generics are used?

857


What does return do in for loop?

879


Explain why do I get an error (cs1006) when trying to declare a method without specifying a return type?

783


What does this keyword mean in c#?

875


What is variable in c#?

913