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

Define xslt.

939


What is difference between abstraction and encapsulation in c#?

1024


Why delegates are type safe in c#?

897


What is the role of the datareader class in ado.net connections?

910


What is difference between code access and role based security?

1086


Why do we use 0?

935


What is the advantage of dependency injection?

997


What is a console in c#?

861


Why do we use overloading in c#?

988


What is system predicate?

894


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

945


What is better C# or VB.NET?

947


What is the difference between internal and protected in c#?

1012


Explain the difference between the debug class and trace class?

892


What is boxing in c#?

982