Thursday, 29 March 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

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...