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
Do you know why doesn't the java library use a randomized version of quicksort?
What is meant by oops concept in java?
What is class level lock ?
What is the reason behind using constructors and destructors?
What is classes in java?
Explain what is Marker interface?
How does remove work in java?
Variable of the boolean type is automatically initialized as?
What are serialization and deserialization?
What is the use of using enum to declare a constant?
What is the difference between compile-time polymorphism and runtime polymorphism?
What are the four integer types supported by java?
What is math floor in java?
In a container there are 5 components. I want to display all the component names, how will you do that?
What is keyword in oop?