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

why ,we are using jsp and html.which one is better?

2 Answers   Photon,


how to fing linkedlist is circular or not?

1 Answers   TCS,


What is split return?

0 Answers  


explain local datetime api in java8?

0 Answers  


List out five keywords related to exception handling ?

0 Answers  


can you create interface instance ?

54 Answers   Fidelity, TCS,


How to connect to a remote database using Applet?

0 Answers  


Does java trim remove newline?

0 Answers  


What is a parameter in simple terms?

0 Answers  


What is a line break example?

0 Answers  


what is use of marker interface? give me good example?

2 Answers  


What is the nested interface?

0 Answers  


Categories