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
What 4 doubled?
What is meant by the value of a variable?
What happens if we don’t override run method ?
Can a class have more than one object?
What is difference between static class and normal class?
What is the difference between abstract class and interface1? What is an interface?
Why inputstreamreader is used in java?
why java does not support unsigned keyword?
What is meant by vector class, dictionary class, hash table class, and property class?
Give reasons supporting that string is immutable.
How do you clear an arraylist in java?
What is overloading and overriding in java?
Can an interface implement another interface?
What is the primitive type short?
What are exceptions