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.

Answers were Sorted based on User's Feedback



Explain constructor. ..

Answer / kamlesh sharma

constructors are special type of member functions of class
which is used to initilized a object

1. constructors are as same name of the class
2. don't have any return type
3. don't return any value


Types
1 default constructor
2 parametrized constructor and
3 copy constructures

constructors can be overload

Is This Answer Correct ?    15 Yes 0 No

Explain constructor. ..

Answer / subramanyam

Constructors are used for initialization.

Is This Answer Correct ?    11 Yes 1 No

Explain constructor. ..

Answer / 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

Explain constructor. ..

Answer / rajkamal busi

Constuctor is a Method/Fuction

- Having Same Name of that Class(which it belongs to).
- which doesn't have any Return Type.
- and Get Executed Automatically when ever Object is
Created for that class.

Mostly Constuctor is Used for Initialization of Objects.

Is This Answer Correct ?    6 Yes 0 No

Explain constructor. ..

Answer / 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

Explain constructor. ..

Answer / kousik

Main Advantage of Cons:
1)Object Initialization
2)Class don't have Private access specifier through use of private constructor avoid inheritance.
3)Types:a)static b)Instance
a)--Default automatically crates and no arguments are not supplied.
b)-Same name of class but we have n no of arguments.

Is This Answer Correct ?    0 Yes 3 No

Explain constructor. ..

Answer / kamlesh sharma

I am not a Great programmer,i dont know to write a single
line of code also, so i am explaning constructor in words,
without giving you an example program.

frankly to tell, i just watched like a movie when my friend
was typing about constructor,i know only eating, chating,
drinking, sleeping.

My friend just wrote my Name because he don't like to
propagate his name.

And my friend Name is Phani and anyone can contact him at:
phani121@yahoo.co.in, because he is a gem in programming
languages.

Is This Answer Correct ?    1 Yes 14 No

Post New Answer

More C Sharp Interview Questions

Where do we use serialization in c#?

0 Answers  


What is int32?

0 Answers  


What?s the top .NET class that everything is derived from?

3 Answers  


what is webapplication? what is windows application? what is the extension for both . in what purpose we r using webapplication. in which situation we r using windowns application

1 Answers  


What is the difference between “finalize” and “finally” methods in c#?

0 Answers  


In a stored procedure 4 select stmts there.If error comes in one select stmt will remaining normally executes?

7 Answers   Microsoft,


Can I do things in il that I can't do in c#?

0 Answers  


Which config file has all the supported channels/protocol?

0 Answers  


class Program { void add() { int x=10, y=20; fun(); Console.WriteLine("{0}", sum); } void fun() { int sum; sum = x + y; } static void Main(string[] args) { Program f =new Program(); f.add(); } } Debug above program.....

3 Answers   HCL,


What is namespace give the example?

0 Answers  


Can we inherit partial class in c#?

0 Answers  


What is the keyword used to prevent a class from being inherited by another class?

0 Answers   Siebel,


Categories