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 synonym of string?

773


Why there is no call by reference in java?

694


Can a class extend 2 classes in java?

773


Is it possible to define a method in java class but provide it’s implementation in the code of another language like c?

816


What are the advantages and disadvantages of object cloning?

780


I am a fresher and know core java, c languge, html, css etc if I am illegible for any job then send it on my email tatranakshay276@gmail.com

1357


why not override thread to make a runnable? : Java thread

751


What is a null check?

755


How to use Media tracker Class.

856


What is an image buffer?

728


Which is better stringbuffer or stringbuilder?

719


What is class level lock ?

800


Difference between collection, collection and collections in java?

797


What is derived datatype?

880


How to check if a list is sorted in java?

780