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 lazy initialization in java?

0 Answers  


Given a singly linked list, find the middle of the list in a single traversal without using temporary variable.

0 Answers   Fidelity,


What is java’s garbage collected heap?

0 Answers  


how to write a program for chat function using core java

1 Answers   Satyam,


Is null a value?

0 Answers  






Explain about serializable interface in java?

0 Answers  


Explain super keyword in java.

0 Answers  


Which object oriented concept is achieved by using overloading and overriding?

0 Answers  


What is local variable and instance variable?

0 Answers  


What is the purpose of the file class in java programming?

0 Answers  


public class BatchTest { public static void main(String[] args) { Runtime run = Runtime.getRuntime(); try { Process p = run.exec("cmd start /c D:/test.bat"); System.out.println(p.exitValue()); } catch (Exception e) { e.printStackTrace(); } System.out.println("FINISHED"); } }

0 Answers  


What are integer overflows and underflows and how to handle them?

3 Answers   Wipro,


Categories