What is the difference between constructor and method?
Answer Posted / rattaiah addanki
methods:
modifiers_list Return_type Method_name(Parameter_list)
public void withdraw(int accno)
{
business logic
}
1) method is used to provide the business logic of the project
2) the methods are executed whenever wee are calling that
methods.
3) every method having return type.
Constructors:-
Modifiers_list Constructor_name(parameters)
ex:- public Test(int i)
1) where as constructors are used to create object.
2) the constructor is executed then only object is created.
3) at the time of object creation the constructors are
executed no need of calling.
4) if we want to execute any code at time of the object
creation then we should go for constructors concept.
Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Differentiate between postfix and prefix operators in java.
What is t in generics in java?
What is the char data type?
How do you achieve singleton?
Which variables are stored in heap?
How do you allocate memory to object?
How do you delete a list in java?
Can a static method be overridden in java?
Where pragma is used?
Give a practical example of singleton class usage?
In how many ways we can do exception handling in java?
What is files manifesting?
What does a void function return?
What does isempty () do in java?
Explain what pure virtual function is?