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 final keyword and when to use it?
What is the purpose of the runtime class in java programming?
What is difference between jdk,jre and jvm?
What is native code?
What is difference between an object and a class?
What are the different types of sorting in java?
which class is the wait() method defined in? : Java thread
What is the function of compareto in java?
What is the difference between length and size in java?
What do you understand by the term string pool?
What is the purpose of object oriented programming?
Can vector have duplicates in java?
What is difference overloading and overriding?
What is compareto?
How do you check if an arraylist is not empty?