Explain, why the constructor is required in implemented
class?

Answers were Sorted based on User's Feedback



Explain, why the constructor is required in implemented class?..

Answer / vimalan

constructor is used for initializing the class
variables.if constructor is not there,variables might be
taken the garbage values.To avoid garbage
values ,constructor is used.

Example:
Java:
int i;

initial value i=0;

C:
int v;
v=8823

Is This Answer Correct ?    6 Yes 2 No

Explain, why the constructor is required in implemented class?..

Answer / snehaaa

when u have the class name like bicycle,how u'l initialize the values for bicycle with different 1 parameters,2 parameters,
3 parameters by using object?. for that u'l create example like 3 parameter constructors -> bicycle(speed,wheels,gear)and cal this constructor like bicycle b=new bicycle(10,2,4); this is use of constructor to initialize the values for class

Is This Answer Correct ?    1 Yes 0 No

Explain, why the constructor is required in implemented class?..

Answer / sekhar

Constructor is like a method.It can be invoked as soon as
we create an object for the class.We can overload
constructor.to call them we need pass parameters in main
method.

Is This Answer Correct ?    3 Yes 3 No

Explain, why the constructor is required in implemented class?..

Answer / ejp

A constructor isn't required so the question is futile. Both
answers above are wrong.

Specifically, in reply #1, 'if constructor is not
there,variables might be taken the garbage values' is itself
complete garbage.

Reply #2, is mostly irrelevant, but this statement 'to call
them we need pass parameters in main method' is also wrong.
Parameters are not required, and the reference to the main
method is pointless.

Is This Answer Correct ?    2 Yes 3 No

Post New Answer

More Core Java Interview Questions

Tell me how many ways are there to initialise an integer with a constant.

0 Answers   Aricent,


What is navigable map in java?

0 Answers  


What is mean by exception?

0 Answers  


What is a parameter in a function?

0 Answers  


why abstract class does not have object creation

6 Answers   Value Labs,






Does a class inherit the constructors of its superclass in java programming?

0 Answers  


Can we overload the constructors?

0 Answers  


Does hashset allow duplicates in java?

0 Answers  


Why char array is preferred over string for storing password?

0 Answers  


State two differences between C and Java.

0 Answers   Syntel, Visa,


What is length in java?

0 Answers  


What is java developer skills?

0 Answers  


Categories