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 are advantages and disadvantages of OOPs?
What is the difference between heap memory and stack memory?
Difference between comparator and comparable in java?
How many bits is a double?
What are data types in oop?
What is the use of :: in java?
Can we override static methods in java?
Explain the difference between abstraction and encapsulation.
What is a java developer salary?
how come we know the object is no more used in the class?
How many digits can a float hold?
How does map works in java?
Can a static method be overridden in java?
What is difference between final and immutable?
What does int [] mean in java?