File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Interface question.... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Interface question...." Watch "Interface question...." New topic

Interface question....

Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
So, Interface's can only 'extend' other interfaces, right?

I thought they could implement one to many interfaces, but I guess they can only extend one to many interfaces.

Just wanted to make sure.

I also have an ENUM question as well,

in the following code:

I don't see how it knows that 'DOG("woof")' calls the enum's constructor without using a 'new' operator?


Justin Fox

You down with OOP? Yeah you know me!
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

Hi Justin,

Yes, interfaces use the "extends" keywords, followed by a list of extended interfaces -- there can be one or more. Classes extend classes, classes implement interfaces, interfaces extend interfaces, interfaces implement nothing.

About the enum: the compiler doesn't really "know" so much as it "assumes"; at that point, it's expecting to see enum values, and if it sees an open-paren, then that's assumed to be a constructor call. It "assumes' rather than "knows" because that's the only choice, and if the syntax turns out to be wrong, then it's an error.

[Jess in Action][AskingGoodQuestions]
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
Cool deal,

Thanks for clearing that up for me.

I'm studying for the scjp so be prepared for mucho posts .

Thanks again,

Justin Fox
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15093

An enum is like a special kind of class. The enum constants are like public static final members of the class. Have a look at this:

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
Yeah, once I figured out what it was 'assuming' i guess, I could kinda visualize a 'behind the scenes' declaration of the animals.

Thanks again,

Justin Fox
[ July 03, 2008: Message edited by: Justin Fox ]
I agree. Here's the link:
subject: Interface question....
It's not a secret anymore!