Can I have constructor in Interface?

Answers were Sorted based on User's Feedback



Can I have constructor in Interface?..

Answer / saroj kumar biswal

no we can't have constructor in an interface, why bcz constructor is used to initialize the instance variable stored in an object. Constructor is called concurrently while creating object. We can't create object to interface & also we can't provide instance variable to interface. So we can't use constructor in an interface

Is This Answer Correct ?    30 Yes 3 No

Can I have constructor in Interface?..

Answer / suresh

No a interface should not have constructor,
Because, interface will not extends with object class.
if any class extends with object class then atleast one
constructor should be there, if user fail to keep the
constructor the compiler will keep a default constructor
with first statement as super();.

Is This Answer Correct ?    6 Yes 2 No

Post New Answer

More Core Java Interview Questions

What does microservices mean?

0 Answers  


where can we get jAVA project orientation traing in HYDERABD

0 Answers  


Why a dead thread occurs?

0 Answers  


How define set in java?

0 Answers  


How GC (Garbage Collector) knows the objects reference is unused.Whether GC removes the unused object Parmanently or it maintains something.

2 Answers  






what is the difference between ArrayList and Vector

19 Answers   KPIT, Sasken, Satyam, Span Infotech, Wipro,


How to set the Heap size in Java ?

2 Answers   HCL,


What do you mean by Hash Map and Hash Table?

0 Answers   Atos Origin,


Can an unreachable object become reachable again?

3 Answers  


What is thread pool? How can we create thread pool in java?

0 Answers  


1.what is the exact difference between applet and frame? 2.Do we use main method in frames?

5 Answers  


How do you load an HTML page from an Applet ?

2 Answers  


Categories