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 maximum size of array in java?

732


How many types of design patterns are there?

786


What is string intern in java?

766


How does thread synchronization occurs inside a monitor? What levels of synchronization can you apply?

762


What is the full form of jpeg?

729


What is main in java?

781


Does importing a package imports its sub-packages as well in java?

750


What is the purpose of javac exe?

782


Explain garbage collection in java?

746


What is balanced tree in java?

713


How can we pass argument to a function by reference instead of pass by value?

821


Who is the owner of java?

755


What is a conditional statement explain with example?

763


Will the jvm load the package twice at runtime?

832


what is object slice?

1767