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
Can we call the run() method instead of start()?
Does java linked list allow duplicates?
What is difference between an object and a class?
What does 3 dots mean in java?
How many types of the indexof method are there for strings?
What are the supported platforms by java programming language?
What is singleton pattern?
What are the types of sockets in java?
What are the differences between getting and load method?
Is string a wrapper class?
How can a gui component handle its own events in java programming?
How do you reverse sort in java?
What is an class?
What is a static method in java?
What is re-factoring in software?