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
Why do we create public static method in java?
What is a qms manual?
Why scanner is used in java?
Which data type is class in java?
Is singleton set an interval?
How does compareto work in java?
How many times finalize method will be invoked? Who invokes finalize() method in java?
Write a program to print count of empty strings in java 8?
What are the drawbacks for singleton class?
Why runnable interface is used in java?
What is the latest version of java?
What is formatted output?
What are 5 boolean operators?
Why does java have two ways to create child threads?
What are locale settings?