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


Please Help Members By Posting Answers For Below Questions

What is class level lock ?

816


Can an interface have a class?

773


Explain access specifiers?

926


How variables are stored in memory?

739


How are the elements of a gridbaglayout organized?

807


What is starvation?

949


What is JVM and is it platform independent?

787


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.

820


What are synchronized methods ?

844


Which software is used for java programming?

784


Explain the difference between treeset and treemap in java?

767


Is a boolean 1 bit?

845


If try block is successfully executed, Then Is Finally block executed?

843


How do you sort in descending order in java using collections sort?

715


What is the benefit of inner / nested classes ?

742