Explain role of constructor in a java application?
Answer Posted / sindhura
A constructor in java has the same name as that of the
class. Whenever the statement such as classname objectname
is encountered, it calls the constructor to initialise the
values for the object. It doesnot return anything and as
soon as the object is created constructor would be called.
ex. : if there is a class called A
A a = new A();
here A a statement would call the constructor immediately
to initialise the values for a object.
| Is This Answer Correct ? | 10 Yes | 1 No |
Post New Answer View All Answers
What is the difference between an object-oriented programming language and object-based programming language?
When is an object subject to garbage collection?
What is a pattern what is an anti pattern?
In how many ways we can do synchronization in java?
What is exception handling in java?
Explain about fail fast iterators in java?
What does it mean that a method or field is “static”?
Is string pool garbage collected?
What do you understand by java virtual machine?
What is meant by class and object in java?
What is parsing a string?
Which is the best approach for creating thread ?
How do we access static members in java?
What is the map interface in java programming?
What best practices should you follow while writing multithreaded code in java?