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 is %02d?
Does printwriter create a file?
define polymorphism in java
What is java lang object?
Can you give few examples of final classes defined in java api?
Define array. Tell me about 2-D array.
Can an object be null?
What is a flag value?
whatis Home interface and Remoteinterface? with example?
Is there any limitation of using inheritance?
What is use of super keyword in java?
What is the difference between hashset and treeset in java?
What is math floor in java?
Which is bigger float or double java?
What are the new features in java 8?