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

Can inner class be public in java?

546


What is hashset in java?

524


What is return in java?

552


What is the difference between super class & sub class?

562


What is sizeof () operator?

566






What is r in java?

591


What is meant by data hiding/encapsulation?

569


What is an object in java and how is it created?

581


What value is a variable of the string type automatically initialized?

609


What is replacefirst in java?

567


What ide should I use for java?

487


Where and how can you use a private constructor?

532


What are the Static and Dynamic Variables? Differentiate them.

596


What is serialversionuid?

555


Explain different forms of polymorphism?

648