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
Define xslt.
What is difference between abstraction and encapsulation in c#?
Why delegates are type safe in c#?
What is the role of the datareader class in ado.net connections?
What is difference between code access and role based security?
Why do we use 0?
What is the advantage of dependency injection?
What is a console in c#?
Why do we use overloading in c#?
What is system predicate?
Okay, so an int is a value type, and a class is a reference type. How can int be derived from object?
What is better C# or VB.NET?
What is the difference between internal and protected in c#?
Explain the difference between the debug class and trace class?
What is boxing in c#?