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
How does a for loop work?
Is 0 an irrational number?
What happens when a thrown exception is not handled?
How dead lock situation occurs in java and how you can identify it?
Can we call virtual funciton in a constructor ?
What are autoboxing and unboxing? When does it occur?
What are the 4 types of research methods?
What is java object name?
What is runtime polymorphism or dynamic method dispatch?
What is __ init __ functions?
What is array class in java?
Write a program to print 15 random numbers using foreach of java 8?
What is the indent key?
What is difference between module and function?
Can we inherit a class with private constructor?