EverCrest Message Forums
You are not logged in. Login or Register.
Author
Topic: I leave for my test in 45 minutes. Java question
Aaron (the good one)
posted 12-08-2004 12:44:27 PM
About interfaces.


A class can extend only one other class into itself. If I wanted to extend more than one class I have to use an interface. My teacher hasn't really gone over it too much so I'm asking you guys. How would I make an interface that would have extend 3 other classes into itself?

Galbadia Hotel - Video Game Music
I am Canadian and I hate The Tragically Hip
Aaron (the good one)
posted 12-08-2004 01:28:12 PM
You are all useless.

USELESS

Galbadia Hotel - Video Game Music
I am Canadian and I hate The Tragically Hip
Alidane
Urinary Tract Infection
posted 12-08-2004 01:54:18 PM
...uhh, multiple inheritance is achieved by just sticking another name on the end of that inherit clause.

class soandso inherits foo,bar.

Is that what you need?

Iulius Czar
Pancake
posted 12-08-2004 02:51:25 PM
quote:
Alidane wrote this then went back to looking for porn:

class soandso inherits foo,bar.

... except you can't do that in java, because it doesn't support multiple inheritance.

The best way to accomplish the task is to make an instance variable for each class you are "inheriting". It's not that much more cumbersome.

There is no way to leverage interfaces to allow you to inherit more than one class.


[edit] So how'd your test go?

Iulius Czar fucked around with this message on 12-08-2004 at 02:52 PM.

Aaron (the good one)
posted 12-08-2004 04:31:34 PM
There was nothing on it except the definition of 'Interface'. That bastard said that we needed to know interfaces and he puts that simple question on the test.

Oh well I still did well. I couldn't get a custom exception to work. I extended RuntimeException but it wouldn't catch an ArrayOutofBoundsException so I just commented the catch out and put a 'catch (Exception e)'.

Galbadia Hotel - Video Game Music
I am Canadian and I hate The Tragically Hip
Alidane
Urinary Tract Infection
posted 12-08-2004 05:40:56 PM
quote:
A sleep deprived Iulius Czar stammered:
[QB]... except you can't do that in java, because it doesn't support multiple inheritance.

Wrong word, right idea. You can realize multiple interfaces, but you can't do multiple inheritance.

In my defense, I'd just woken up and I haven't written any Java code in over six months...haha. Next quarter's gonna hurt.

All times are US/Eastern
Hop To: