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 |
what is actual real time using of oops concepts in projects(Interface,polymorphism.abstraction.........)
What is port number in java?
What is variable explain?
What is difference between final and immutable?
Difference between Linked list and Queue?
difference throws and throw in java
What is the purpose of static keyword in java?
How can we find size of the object ?
Have you worked on bits programming? examples?What is bit? How many bits are there in the byte?
Thanks A.jyotsna, Can u tell me differnce between abstract class and interface vikash
What is the hashcode () and equals () used for?
What are the data types supported by java? What is autoboxing and unboxing?