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

Describe the process as to how substring() methodology mechanisms in java.

0 Answers  


What is the Concept of Encapsulation in OOPS

0 Answers   HCL,


What is the difference between an interface and an abstract class?

0 Answers   Cyient,


If a method is declared as protected, where may the method be accessed?

0 Answers  


Given: 10. interface A { void x(); } 11. class B implements A { public void x() { } public voidy() { } } 12. class C extends B { public void x() {} } And: 20. java.util.List list = new java.util.ArrayList(); 21. list.add(new B()); 22. list.add(new C()); 23. for (A a:list) { 24. a.x(); 25. a.y();; 26. } What is the result? 1 Compilation fails because of an error in line 25. 2 The code runs with no output. 3 An exception is thrown at runtime. 4 Compilation fails because of an error in line 20.

3 Answers  






what is static import in java? Explain

0 Answers  


how its run?

0 Answers  


What is Java Reflection API? Why it’s so important to have?

0 Answers  


where is .equals() method and how is it different from == operation <giving some confusing implementation> Is hashing related to these?

4 Answers   iFlex,


Given a singly linked list, how will you print out its contents in the reverse order? Can you do it with consuming any extra space?

0 Answers   Akamai Technologies,


What are dot operator queries?

0 Answers   Atos Origin,


what is mean by overriding in which situation we wil use?

5 Answers   Atlas Systems, CSC, DCPL,


Categories