Differentiate constructor and a method and how are it be
used?
Answer Posted / pranab dutta
A constructor is a member function of a class that is used
to create objects of that class where as a method is an
ordinary member function of a class.
Constructor has the same name as the class itself and
Member has its own name.
A Constructor has no return type, and is invoked using the
new operator.. Whereas a Member has a return type (which
may be void), and is invoked using the dot operator.
| Is This Answer Correct ? | 8 Yes | 1 No |
Post New Answer View All Answers
Where are register variables stored?
What things should be kept in mind while creating your own exceptions in java?
Name few java util classes introduced with java 8 ?
What is the difference between C++ and Java and your preferences?
What is arguments in java?
why not override thread to make a runnable? : Java thread
What is meant by nested loop?
What are some examples of variable costs?
What is difference between synchronize and concurrent collection in java?
What is difference between equals and hashcode method?
What is the use of default method in interface in java?
What is a method signature java?
How does split work in java?
what is method reference in java 8?
Difference between association, composition and aggregation?