IN java collections we have both interfaces and classes.
instead of using interfaces why we can't use classes only
like that why we can't use interfaces only. why we need two
things interface and class.
Answer Posted / vanaja
Java doesn't support multiple inheritance.We achieve
multiple inheritance using interface concept.A class can
have only one super class and number of interface.And more
over interface has only abstract methods. We need a sub
class to implement it.We cannot create an object for an
interface. So we cannot use only the classes or only the
interfaces in java.
| Is This Answer Correct ? | 19 Yes | 1 No |
Post New Answer View All Answers
Explain about abstract classes in java?
Why is singleton instance static?
What is a finally block? Is there a case when finally will not execute?
Can we have static methods in an interface?
What is a finally block?
Name and explain the types of ways which are used to pass arguments in any function in java.
How many bytes is a string in java?
What are the different types of sorting in java?
how its run?
How does compareto work in java?
How to create an interface?
Difference between final and effectively final ? Why is effectively final even required ?
What is the final variable?
What is singletonlist in java?
Is a method a function?