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


Please Help Members By Posting Answers For Below Questions

What is the r character?

583


What is the best way to findout the time/memory consuming process?

554


What is the difference between abstract classes and interfaces?

505


What is string syntax?

544


which one is more efficient int x; 1. if(x==null) 2.if(null==x) state which one either 1 or 2?

9187






What is the difference between a static and a non-static inner class in java programming?

523


Explain the protected field modifier?

589


Is java 11 paid version?

506


What is the use of keywords in java?

551


How can you set the applet size?

567


How can you read content from file in java?

595


Is a method a procedure?

553


What is the use of accept () method in java?

606


How many decimal places is a double?

531


Can we define private and protected modifiers for the members in interfaces?

531