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 / easwar
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 ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is class level lock ?
Can an interface have a class?
Explain access specifiers?
How variables are stored in memory?
How are the elements of a gridbaglayout organized?
What is starvation?
What is JVM and is it platform independent?
Write a regular expression to validate a password. A password must start with an alphabet and followed by alphanumeric characters; its length must be in between 8 to 20.
What are synchronized methods ?
Which software is used for java programming?
Explain the difference between treeset and treemap in java?
Is a boolean 1 bit?
If try block is successfully executed, Then Is Finally block executed?
How do you sort in descending order in java using collections sort?
What is the benefit of inner / nested classes ?