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


Please Help Members By Posting Answers For Below Questions

What is the purpose of the main method?

763


What do you mean by Function Overloading in java?

946


What is the exception hierarchy in java?

741


Is it possible to override private or static method in java?

772


What means public static?

796


Which is the best sorting technique in java?

765


Can a main method be declared final?

821


Can we create an object if a class doesn't have any constructor ( not even the default provided by constructor ) ?

784


Can we overload the methods by making them static?

763


Can finally block be used without a catch?

759


What is object of class in java?

854


Can a class have an interface?

758


Can we declare array without size in java?

766


How do you remove duplicates in java?

763


Is node a data type in java?

739