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 purpose of tostring() method in java?
How is treeset implemented in java?
What are filterstreams?
Can we make main() thread as daemon?
What is boolean used for?
Variables used in a switch statement can be used with which datatypes?
Describe what happens when an object is created in java ?
Which sorting is best in java?
how to write a program for sending mails between client and server
What is a boolean structure?
What is files manifesting?
What are the methods used to implement for the key object in the hash map?
What is gc()?
What is an object’s lock and which object’s have locks?
What are drawbacks of singleton class?