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 / sarath
Both of them have different purpose.
A Class have state(Fields) and behaviour(Methods). But in Interface we are telling a common behaviour.
for example I have a class called ABCBycycle.java . It implements some common behaviour of bycyle from Bycycle interface,
by implementing the Bycycle interface we are telling that ABCBycycle.java have some common behaviour of bycyle.
So iterface not the blue print of state and behaviour.
But Class is the blue print of some state and behaviour
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Is zero a positive integer?
What is hashmap in java?
What is map and hashmap in java?
What does super keyword do?
What is factor r?
What is the format specifier?
How is a variable stored in memory?
explain the concept of virtual method invocation in polymorphism in detail?
What is array length in java?
Which methods are used during serialization and deserialization process?
What is the difference between length and length() method in java?
Can one thread block the other thread?
What is the static import?
How to create com object in Java?
What is core java used for?