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 do you understand by java virtual machine?
Can we modify the throws clause of the superclass method while overriding it in the subclass?
can I implement my own start() method? : Java thread
why are there separate wait and sleep methods? : Java thread
what is bmg file and how to create that files?what will it contailn?
What is an empty string in css?
What is string intern in java?
Explain about complier design(phases)
Why java is object oriented?
How variables are declared?
What is a two-pass assembler?
what are the states associated in the thread? : Java thread
How is Object Oriented Programming different from Procedure Oriented Programming?
What does 3 dots mean in java?
What is meant by class loader? How many types are there?