It's not a secret anymore!*
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 144
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: 787

@ 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: 19651
    
  18

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


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 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 agree. Here's the link: http://aspose.com/file-tools
 
subject: about interface
 
Similar Threads
Interfaces and Access Modifiers
Why Ejb Bean class not implementing the Remote Interface
Interfaces
creating abstract classes within an interface in java
interface inside a class