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 is ternary operator? Give an example.
What are different ways of object creation in java ?
Write a program to reverse a number in java?
What are meta-annotations?
Can a serialized object be transferred via network?
Explain the use of shift operator in java. Can you give some examples?
What is the properties class?
Can we catch more than one exception in single catch block?
What is Classloader in Java?
Which sorting is best in java?
can any body body expalin best definitions & best real time exaples for opps concepts.
What is difference between == and === in js?
How to declare objects of a class ?
What is java virtual machine? Explain
How do you reverse sort in java?