C# Programming - Constructors - Discussion
Discussion Forum : Constructors - General Questions (Q.No. 9)
9.
Which of the following statements are correct about constructors in C#.NET?
- Constructors cannot be overloaded.
- Constructors always have the name same as the name of the class.
- Constructors are never called explicitly.
- Constructors never return any value.
- Constructors allocate space for the object in memory.
Discussion:
11 comments Page 1 of 2.
Praveen patil said:
1 decade ago
Only static constructor cannot be overloaded normal constructor can be overloaded.
Sunny said:
1 decade ago
Constructor does not have return type therefor constructor can not return any value, use for initialize the data member.
Piash said:
1 decade ago
How memory is allocated for an object? can anyone explain, please.
Loz said:
1 decade ago
Isn't 3 wrong?
Can't constructors be called explicitly. For example:
using,
: base() in a constructor of an inheriting object.
Can't constructors be called explicitly. For example:
using,
: base() in a constructor of an inheriting object.
Karishma said:
1 decade ago
@Piash.
Object created=>constructor called=>memory allocated.
Memory not allocated=>consturctor not called =>object not created.
Object created=>constructor called=>memory allocated.
Memory not allocated=>consturctor not called =>object not created.
Kartik said:
1 decade ago
The constructor goes out of scope after initializing objects.
Anil said:
1 decade ago
We can call a constructor explicitly.
Example:
class demo
{
public demo()
{
//explicitly constructor is called
}
Example:
class demo
{
public demo()
{
//explicitly constructor is called
}
Mahi said:
9 years ago
Correct answer 2, 4, 5 as per my knowledge.
1). Constructor name same as its class name.
2). Constructor never have a return type.
3). In construct the memory for class members.
1). Constructor name same as its class name.
2). Constructor never have a return type.
3). In construct the memory for class members.
Genni said:
9 years ago
A destructor that allocates a memory.
Constructor not allocate the memory.
Constructor not allocate the memory.
Nikesh Rathour said:
6 years ago
The answer should be 2, 4, 5.
3 is not correct because we can call the non-static constructor explicitly and static constructor are parameter less so implicitly called.
The reason of constructor never have a return type or constructor never return any value because its not call directly by a programmer (through code) its called by the memory allocation.
3 is not correct because we can call the non-static constructor explicitly and static constructor are parameter less so implicitly called.
The reason of constructor never have a return type or constructor never return any value because its not call directly by a programmer (through code) its called by the memory allocation.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers