This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes about interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "about interface" Watch "about interface" New topic
Author

about interface

santhosh kumar vk
Ranch Hand

Joined: Aug 25, 2009
Posts: 148
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: 802

@ 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

I'm not sure what you mean by "using a class in an interface."
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 20078
    
  30

See my comment in http://www.coderanch.com/t/475635/Java-General/java/annotation


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
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

 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: about interface
 
It's not a secret anymore!