why the constructor should be used in class,if there is no
constructor what will happen?
Answer Posted / bindhu
In Java, initialization of every object possible
by providing a constructor. If a class has a constructor,
Java automatically calls that constructor when an object is
created. So initialization is guaranteed.
If we don't define a constructor for a class, a default
parameterless constructor is automatically created by the
compiler.
| Is This Answer Correct ? | 6 Yes | 0 No |
Post New Answer View All Answers
What is Major and importance difference between for and foreach loop ?
why Interface used?
Is null a keyword in java?
What is array size in java?
Can you override private or static method in java?
Where are the local variables stored?
What is a singleton class in Java?
What is class forname used for?
Can we return null in java?
How many digits is int32?
Explain purpose of sleep() method in java?
What do you mean by JVM?
Why is method overloading not possible by changing the return type in java?
What are the differences between heap and stack memory in java?
Which of the classes will have more memory allocated?