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 a java applet? What is an interface?
what are the different non-access specifiers in java?
What is numel matlab?
Explain about exception propagation?
Explain the importance of finalize() method.
How to perform merge sort in java?
What is the basic concept of java?
which one is more efficient int x; 1. if(x==null) 2.if(null==x) state which one either 1 or 2?
What is polymorphism and what are the types of it?
Write a program to show whether a graph is a tree or not using adjacency matrix.
What are implicit objects in java?
How do I convert a numeric ip address like 192.18.97.39 into a hostname like java.sun.com?