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 ? | 8 Yes | 0 No |
Post New Answer View All Answers
List some oops concepts in java?
Why is String immutable?
what is the difference between yielding and sleeping? : Java thread
Is .net better than java?
Is null a keyword in java?
Can we use catch statement for checked exceptions when there is no chance of raising exception in our code?
Outline the major features of java.
what is the purpose of the runtime class?
What is package private scope in java?
Can you make a constructor final?
What is array length?
What is map java?
What is string array?
When is the garbage collection used in Java?
Should database connections be singleton?