Thursday, March 29, 2018

Can interfaces have static methods or java class stati'fy interface method?

The following is allowed:-




public interface JustImplementMe
{
public void ClimbMountain();
}


The following is not allowed:-



public interface StaticMethodInterface
{

public static void Climb();
}


The following is allowed:-



public class Classic implements JustImplementMe
{
public void ClimbMountain()
{


}
}


The following is not allowed:-



 public class ClassicMusic implements JustImplementMe    
{
public static void ClimbMountain()

{
// static method cannot hide the instance method in JustImplementMe
}
}


Why is it so? Thanks.

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...