Can I have constructor in Interface?
Answers were Sorted based on User's Feedback
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 |
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 |
Can a constructor be made final?
Explain about fail safe iterators in java?
What is included in core java?
How many types of flags are there?
How do you end a program?
Is list thread safe in java?
How to check if linked list contains loop in java?
How do you remove all elements from an arraylist in java?
Can we change the scope of the overridden method in the subclass?
What is meant by vector class, dictionary class, hash table class, and property class?
How do you escape json?
What are the two basic ways in which classes that can be run as threads may be defined?