| Author |
about interface
|
santhosh kumar vk
Ranch Hand
Joined: Aug 25, 2009
Posts: 115
|
|
hi,
can we use calss in interface, I went to one interview thay asked me how to use class in interface please tell me how to use the class in interface.
|
 |
Ninad Kulkarni
Ranch Hand
Joined: Aug 31, 2007
Posts: 774
|
|
@ santhosh
UseAMeaningfulSubjectLine
Use Java forum for this question.
|
SCJP 5.0 - JavaRanch FAQ - Java Beginners FAQ - SCJP FAQ - SCJP Mock Tests - Tutorial - JavaSE7 - JavaEE6 -Generics FAQ - JLS - JVM Spec - Java FAQs - Smart Questions
|
 |
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12617
|
posted

0
|
|
I'm not sure what you mean by "using a class in an interface."
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
See my comment in http://www.coderanch.com/t/475635/Java-General/java/annotation
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Hiram Nascimento
Greenhorn
Joined: Jul 09, 2009
Posts: 13
|
|
Hi Santhosh,
Yes, that's possible. I can give you an example from the Java Collections API.
Considering that an ArrayList (class) IS-A (implements) List (interface), you can call its methods by using a List interface reference.
Another example:
I could either create an IPod reference, but using the Player reference I get the benefits of polymorphism.
Does it make sense for you?
Hiram
|
 |
 |
|
|
subject: about interface
|
|
|