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
How can you make sure that your singleton class will always return single instance in multi-threaded environment?
What do you mean by chromounits in java8?
If two threads have same priority which thread will be executed first ?
What is the difference between final, finally and finalize() in java?
What is the benefit of abstract class?
What is the difference between the boolean & operator and the && operator in java programming?
How many ways can we create the string object?
What is a parameter in matrices?
Define "Access specifiers" in java.
How to create a custom exception?
Explain OOPs concept.
Can we create an object of private class?
Can we override private method?
How will you print number in reverse (descending) order in BST.
What are the types of sockets in java?