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 final class modifier?

645


What’s a deadlock?

706


Why stringbuilder is not thread safe in java?

684


What is the use of callablestatement?

666


Mention some interfaces implemented by linked list in java.

640






Explain the difference between abstraction and encapsulation.

626


What are the Main functions of Java?

711


How does the java compiler work?

614


What do you mean by collectors in java 8?

620


Explain java thread life cycle.

672


What is immutable data?

698


What does opcode mean?

652


What is a numeric digit?

671


What is autoboxing in java?

700


Explain all java features with real time examples

1307