Linked Questions

32 votes
1 answer
20k views

I'm playing around Java 8's new features recently and observed an interesting behaviour: This is okay: Class A { static void staticMethodInA() {println();} } Class B extends A {} B.staticMethodInA()...
SexyNerd's user avatar
  • 1,144
-1 votes
1 answer
442 views

interface A { public static void print(){ System.out.println("interface A"); } } class B implements A{ public static void main(String[] args){ A obj = new B(); obj.print(); //Not possible....
Satya's user avatar
  • 8,386
1 vote
2 answers
66 views

Consider a class A that implements an interface B which has a static method info(). Why is not possible to do A.info()? If it was a default method, it would be possible to do A.info() and I don't ...
dyso's user avatar
  • 37
576 votes
24 answers
457k views

NOTE: This question predates Java 8. As of Java 8, static methods are allowed in interfaces. However, they cannot be declared abstract (required to be overridden) in the manner requested by this ...
cdmckay's user avatar
  • 32.4k
173 votes
16 answers
198k views

I was reading A Programmer’s Guide to Java™ SCJP Certification by Khalid Mughal. In the Inheritance chapter, it explains that Inheritance of members is closely tied to their declared ...
Algorithmist's user avatar
  • 6,723
144 votes
13 answers
98k views

I was learning through interfaces when I noticed that you can now define static and default methods in an interface. public interface interfacesample2 { public static void method() { ...
Vipin Menon's user avatar
  • 3,382
155 votes
14 answers
109k views

The topic says the most of it - what is the reason for the fact that static methods can't be declared in an interface? public interface ITest { public static String test(); } The code above gives ...
Henrik Paul's user avatar
18 votes
1 answer
4k views

I've created a Kotlin subclass of a Java class: class AlarmReceiver : WakefulBroadcastReceiver() { companion object { const val ACTION_NOTIFY = "..." } override fun onReceive(...
Ronald Martin's user avatar
0 votes
0 answers
215 views

I was looking in capability of defining static methods in interfaces in Java8. I was kinda confused to see that static methods in interfaces are not inherited by the implementing classes or interfaces....
Satya Nand kanodia's user avatar
5 votes
1 answer
241 views

When hiding a static field, there's no restriction on what access level does the field have in subclass, it can be even non-static and of other data type. On the other side, when hiding a static ...
Bax's user avatar
  • 4,526