can you create interface instance ?
Answer Posted / zafar
No, you cannot create an instance of an interface. An
interface has no implementation - a class that implements
the interface specifies the implementation.
However, you can ofcourse have a reference variable of an
interface type that points to an instance of a class that
implements the interface. For example:
// List is an interface, ArrayList implements interface List
List data = new ArrayList();
It's good practice to program like this - program to an
interface, not an implementation. If you want to know more
about that design principle, see, for example:
[url=http://www.artima.com/lejava/articles/designprinciples.
html]Design Principles from Design Patterns[/url]
| Is This Answer Correct ? | 13 Yes | 0 No |
Post New Answer View All Answers
What is the difference between numeric and integer?
What is identifier in java?
What is JDBC Driver interface?How can you retrieve data from the ResultSet
How listener identify that the event came from a particular object?
What is a bubble sort in java?
How are multiple inheritances done in Java?
What is a numeric literal?
Explain the scope of a variable.
What is difference between local variable and global variable?
What is difference between checked and unchecked exception in java?
Does java vector allow null?
What is data member in java?
What are the various access specifiers in java?
How does thread synchronization occurs inside a monitor?
Can a class extend more than one class?