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
Describe different states of a thread.
Give a practical example of singleton class usage?
When can you say a graph to be a tree?
When will you define a method as static?
Explain about arraylist?
What are sets in java?
Explain public static void main(string args[]).
What is the difference between final, finally and finalize() in java?
What do you mean by local variable and instance variable?
What is return in java?
What is a local, member and a class variable?
What are the core java topics?
What are keywords in java?
What is thread safe in java?
How can you make a class serializable in java?