The code below leads to an error "interface expected here"
Here an interface is created (MyInterface) and it inherits(extends) the Thread class which is not possible at all. Why? Because an interface can inherit only another interface, not any class. As Thread is a class, it cannot be inherited by any interface.
The code below is correct as the interface inherits another interface Runnable
A similar type of error is posted at no interface expected here
public interface MyInterface extends Thread
{
}
Here an interface is created (MyInterface) and it inherits(extends) the Thread class which is not possible at all. Why? Because an interface can inherit only another interface, not any class. As Thread is a class, it cannot be inherited by any interface.
The code below is correct as the interface inherits another interface Runnable
public interface MyInterface extends Runnable
{
}
A similar type of error is posted at no interface expected here
0 comments:
Post a Comment