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

Which is better stringbuffer or stringbuilder?

0 Answers  


What is the advantage of preparedstatement over statement?

0 Answers  


What are structs in java?

0 Answers  


how to use this key word in java programming?

7 Answers  


How to extract HashMap values?

5 Answers   Marlabs,






Is there a sort function in java?

0 Answers  


What does three dots mean in java?

0 Answers  


Explain about procedural programming language or structured programming language and its features?

0 Answers  


What are the characteristics of java?

0 Answers  


Can we declare main () method as non static?

0 Answers  


How do you declare an empty string?

0 Answers  


What is the differences between c++ and java? Explain

0 Answers  


Categories