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 nested and inner classes ?
Say any two properties in beans?
Write a program to show whether a graph is a tree or not using adjacency matrix.
Explain the difference between an object-oriented programming language and object-based programming language?
What is classname class in java?
Why is it called buffering?
Is map sorted in java?
Can we have any code between try and finally blocks?
How to set the permissions to a file in java?
What is the difference between char and char *?
How to display all the prime numbers between 1 and n (n is the number, get the input from user)
Which is better arraylist or vector?
Explain constructors and types of constructors in java.
Can we increase array size dynamically in java?
What are different ways of object creation in java ?