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
What will happen if non-synchronized method calls a static synchronized method and what kind of lock it acquires?
Why generics are used in java?
What is object-oriented programming?
Explain the significance of class loaders in bootstrap?
Explain how can you debug the Java code?
Why is multiple inheritance not supported in java?
Is java platform independent?
What does exp mean in math?
What are the differences between getting and load method?
What is difference between wait and notify in java?
Describe the various concepts related to object oriented programming (oop).
What is the symbol for average?
Can a static method be final?
What is double parsedouble in java?
How do I write a self declaration?