what is default constructor and parameterised constructor
with example?



what is default constructor and parameterised constructor with example?..

Answer / tushar

Default constructor: this constructor is created by the compiler automatically whenever an object is created.User don't have to write default constructor every class has its default constructor
Parameterized constructor: this constructor is exclusively written by the coder to assign the initial value to an instance variable.By creating parameterized constructor you can overwrite the default constructor.

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More Core Java Interview Questions

What is the difference between Array and Hash Table?

0 Answers   Impetus,


abstract class A{ int list []=new int [100]; A(int x,int y){ rondom n=new rondom(); for (int i==;i<100;i++); list [i]=x+r.next int(y-x+1); abstract sort (); abstract binary sarch(int temp); class B extends A{

3 Answers  


What are the different types of methodologies?

0 Answers  


Can we override the overloaded method?

0 Answers  


What is bean? Where it can be used?

0 Answers  


Is set ordered?

0 Answers  


Difference between process and thread?

0 Answers   HP,


What is static and a non-static inner class?

3 Answers  


Can we create a constructor in abstract class?

0 Answers  


In case of inheritance what is the execution order of constructor and destructor?

0 Answers   Agilent,


What is preparedstatement in java?

0 Answers  


What is static method with example?

0 Answers  


Categories