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

Is array serializable java?

525


What data type is a string?

515


How we can execute any code even before main method?

555


What is the function of static in java?

544


What is the major difference between linkedlist and arraylist?

513






What is the transient keyword?

635


Describe how to implement singleton design pattern in struts.

537


What is meant by collection in java?

557


what is singleton class in java?

623


What are constants and how to create constants in java?

559


Is void a data type?

540


What is the difference between the jdk 1.02 event model and the event-delegation model introduced with jdk 1.1?

621


What are the differences between forwarding () method and sendredirect() methods?

625


What are thread groups?

578


Can java list be null?

557