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

Can the interface be final?

580


What is main function purpose?

523


How do you use compareto method?

531


What is default constructors?

543


How do you declare an array that will hold more than 64KB of data?

639






Tell us something about set interface.

564


What’s the difference between callable and runnable?

547


how to create multithreaded program? Explain different ways of using thread? When a thread is created and started, what is its initial state? Or extending thread class or implementing runnable interface. Which is better? : Java thread

597


What is charat java?

542


Why is java architectural neutral?

615


How do you add an element to an arraylist in java?

487


Tell us something about different types of casting?

519


Highest level event class of the event-delegation model?

3503


Can set contain duplicates?

551


What is character in data type?

549