Home / DeveloperSection / Interviews / How i can define a Constructor
You haven’t finished your post yet. Are you sure you want to leave and discard your draft?
Can you answer this question?
Niraj Kumar Mishra
when you want to define a constructor in your Program then you follow these rules.
• A constructor must have the same name as the class name.
• A constructor does not return anything, not even a void type.
• A constructor may take zero or more arguments.
• By default, the compiler provides a no-argument constructor.
• If you provide any constructor in your program then compiler does not provide a default constructor.
You have need login or register for voting of answers or question.
Niraj Kumar Mishra
22-Aug-2017when you want to define a constructor in your Program then you follow these rules.
• A constructor must have the same name as the class name.
• A constructor does not return anything, not even a void type.
• A constructor may take zero or more arguments.
• By default, the compiler provides a no-argument constructor.
• If you provide any constructor in your program then compiler does not provide a default constructor.