help please!

If you specify in your code that a certain class implements a certain interface, is that interface automatically implemented by the subclasses of the class, or do you have to type "implements Interface" at the top of each subclass

i thought they would inheret it

Message was edited by:

StaceyMach

[322 byte] By [StaceyMacha] at [2007-11-26 17:42:46]
# 1

Test it out.

class Superclass implements Runnable

{

public void run()

{

//...

}

}

class Subclass extends Superclass

{

}

class Test

{

public static void main(String[] args)

{

Thread t1 = new Thread(new Superclass());

Thread t2 = new Thread(new Subclass());

}

}

Does it give you any errors?

CaptainMorgan08a at 2007-7-9 0:10:57 > top of Java-index,Java Essentials,Java Programming...
# 2

Another fun test:

abstract class Superclass implements Runnable {

// nothing here

}

class Subclass extends Superclass {

// nothing here either

}

Can you compile Subclass, and if not, why?

paulcwa at 2007-7-9 0:10:57 > top of Java-index,Java Essentials,Java Programming...
# 3
I think it also applies to the subclasses. Sorry if I am wrong, I just also learned interface
aditya15417a at 2007-7-9 0:10:57 > top of Java-index,Java Essentials,Java Programming...
# 4
To answer your question simply; Yes, everything is automatically inherited by the subclass.
Shadowicsa at 2007-7-9 0:10:57 > top of Java-index,Java Essentials,Java Programming...