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
Difference between arraylist and vector.
Differentiate between a class and an object.
How many bits is a string in java?
What is Garbage Collection in Java
What is parsing and its types?
Can java cast null?
Why is the singleton pattern considered to be an anti pattern?
What is the range of the short type?
Does a function need a return?
What are abstract classes and anonymous classes?
Where are register variables stored?
What are abstract methods in java?
What is multiple inheritance? Is it supported by java?
What does @override mean?
What is the use of predicate in java 8?