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 / reddy

The purpose of interface is to have abstract methods and
the class which implemnts the interface has to define the
methods in the interface.
The reason why java collections have both interfaces and
classes is interface will have common methods which will be
needed by one or many classes. The classes which wants to
behave like this interface will implement this interface
and define methods in the interface.

Is This Answer Correct ?    14 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

When would you use a static class?

746


Can you tell me range of byte?

745


What is the locale class in java programming?

744


What is the difference between the file and randomaccessfile classes?

794


Explain the Propertie sof class?

819


State the significance of public, private, protected class?

840


Can you achieve runtime polymorphism by data members?

841


What does  mean in regex?

761


What is empty list in java?

822


How many types of parsers are there?

774


What does the string method compareto () do?

748


what is the difference between a threads start() and run() methods? : Java thread

752


Difference between keyword and identifier.

772


What is the byte order of byte buffer?

774


What do you mean by exception handling in Java?

968