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
Write a console application and implement the ternary operator to decide whether the age a user entered after being prompted is allowed to vote or not(given that only citizens between 18 and 120 years only inclusive can vote). Use exception handling for non-numerical input.
Is a games console a computer?
What is gui in c#?
what are the Disadvantages of vb
What is a string in c#?
What is console application with example?
What you mean by inner exception in c#?
What is the use of partial methods?
What are Memory foot print of an exe?
What does type safety mean?
How many aware interfaces are there?
What is jagged array?
Is c and c# the same?
What is concrete class in c# with example?
What does xpath return?