This week's book giveaways are in the iOS and Features new in Java 8 forums.
We're giving away four copies each of Barcodes with iOS: Bringing together the digital and physical worlds and Core Java for the Impatient and have the authors on-line!
See this thread and this one 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

Win a copy of Barcodes with iOS this week in the iOS forum
or Core Java for the Impatient in the Java 8 forum!

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

about interface

santhosh kumar vk
Ranch Hand

Joined: Aug 25, 2009
Posts: 146

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
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

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Oct 27, 2005
Posts: 19896

See my comment in

How To Ask Questions How To Answer Questions
Hiram Nascimento

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?


I agree. Here's the link:
subject: about interface