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 are different types of encoding?
Which programming language is best in future?
What is final modifier?
What about features of local inner class?
Can you override a final method?
What is the preferred size of a component in java programming?
How are the elements of a gridbaglayout organized in java programming?
What are the benefits of immutable objects?
What is t type java?
when should you use stringbuilder class in a program?
What are the difference between string, string builder, and string buffer in java?
How do you add spaces in java?
What is the difference between static binding and dynamic binding?
What does the “static” keyword mean?
Is ruby built on java?