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


Please Help Members By Posting Answers For Below Questions

What is boolean false?

516


Explain about complier design(phases)

620


What about main() method in java ?

565


What is the function of http?

522


What is the benefit of lambda expressions?

486






What are the 4 versions of java?

551


What is qualitative variable?

514


What are the high-level thread states in java programming?

575


Explain differences between collection api and stream api?

606


What is the old name of java?

499


What is mutable object and immutable object?

624


Explain listiterator and methods in listiterator?

541


What is the use of isempty in java?

531


What is callable java?

548


how to know the total memory occupied by the objects in the ArrayList(Array list may contain duplicate objects)

1899