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 the characteristics of Final,Finally and Finalize keywords.
Why is multiple inheritance not supported in java?
What is a void in java?
Is a method a procedure?
What is the purpose of object oriented programming?
What is tree node in java?
What is difference between equals and hashcode method?
Does a function need a return?
What is getclass () getname () in java?
Is it possible for a yielded thread to get chance for its execution again?
What are accessor methods in java?
How are the elements of a gridbaglayout organized in java programming?
Explain an algorithm to find depth of a binary tree.
What is passing by reference in java?
What is a protected class in java?