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
What is the difference between scrollbar and scrollpane?
What are the two parts of a conditional statement?
Can we increase array size dynamically in java?
What are the important features of Java 11 release?
which class is the wait() method defined in? : Java thread
Can we write any code after throw statement?
When should the method invokelater() be used?
Why does java have two ways to create child threads? Which way is better?
What is mutable object and immutable object?
Explain the concept of proper inheritance?
Can we create a class inside a class in java?
Explain the importance of join() method in thread class?
Is char a data type in java?
How are multiple inheritances done in Java?
Justify your answer that you can't define a method inside another method in java, if you can then how?