Differentiate constructor and a method and how are it be
used?
Answer Posted / kabita
constructor & methods are both member functions of a class.
when an object is created the constructor is invoked
automatically,bt we have to call the methods explicitly
through objectname.
methods have returntype ,bt constructors haven't.
constructors must have same name as class name bt methods
have not.
constructors are used for initialization of
objects,variables.
| Is This Answer Correct ? | 9 Yes | 0 No |
Post New Answer View All Answers
What access modifiers can be used for methods?
Tell us something about an iterator.
How will you add panel to a frame?
What is meant by class loader? How many types are there? When will we use them?
What happens if an exception is throws from an object's constructor?
What is independent and dependent variables in research?
Is null function in java?
How do you override a method in java?
What is the use of list in java?
What is the use of set in java?
What is externalizable interface?
When should I use singleton?
What is character in data type?
How to create an interface?
How can we create a synchronized collection from given collection?