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 are ER diagrams?
what is the use of thread?Justify it by project point of view
What is a pattern what is an anti pattern?
Can we serialize arraylist in java?
What is the difference between array and array list in java?
Write a program to search a number in the given list of numbers.
What is the purpose of a statement block?
Is there any way to skip finally block of exception even if some exception occurs in the exception block?
How to check if a list is sorted in java?
Why is boolean important?
How hashset works internally in java?
What is off heap memory?