why the constructor should be used in class,if there is no
constructor what will happen?

Answers were Sorted based on User's Feedback



why the constructor should be used in class,if there is no constructor what will happen?..

Answer / 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

why the constructor should be used in class,if there is no constructor what will happen?..

Answer / devarathnam c,kotagudibanda(po

Hi... Nothing will happen the compilet will supply the
default constructor of the class.Normally canostructor can
be used to instantiate an object.

Is This Answer Correct ?    1 Yes 0 No

why the constructor should be used in class,if there is no constructor what will happen?..

Answer / yamini

Constructor is used initialize certian paramameters to each
object on their creation.We can also overload
constructors.So we can initialize objects with diff params.

Is This Answer Correct ?    0 Yes 0 No

why the constructor should be used in class,if there is no constructor what will happen?..

Answer / ravikiran

constructor is used to initialize the variables during the
creation of instances.
If there is no constuctor no object will be gets created.

Is This Answer Correct ?    0 Yes 3 No

Post New Answer

More Core Java Interview Questions

What is meant by packages?

4 Answers  


What is java util collection?

0 Answers  


From the two, which would be easier to write: synchronization code for ten threads or two threads?

0 Answers  


How do you create a first line indent?

0 Answers  


When we should use serialization?

0 Answers  






Can you call one constructor from another if a class has multiple constructors?

0 Answers  


What restrictions are placed on method overloading and method overriding?

5 Answers  


What is return data type?

0 Answers  


What is the current version of java?

0 Answers  


What is difference between static and abstract class?

0 Answers  


why the primitive data type have classes?

4 Answers  


class A{ m2(){ } } class B extends A{ m2(){ } } class c extends B{ m2(){ } } class my_class extends c{ m2(){ } pulic static void main(){ ...My_class a = new my_class(); super.super.super.m2(); is this is leagal if not find what is the legal procedure in order to call A's version of m2(); }

8 Answers   Logica CMG,


Categories