• Post Reply Bookmark Topic Watch Topic
  • New Topic

Doubt about access rules for inherited static method.  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I know that there is no subscription static methods, but I understand the concept of why the following code does not compile:



This is due simply to the fact that static methods can be accessed through methods instantiable?

Grateful for the attention, hugs ;D
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahh.. you are not overriding it properly

It should be like this

public class A {
public static void foo() {}
}

public class B extends A {
public static void foo() {}
}


Well, there is no use of overriding a static method..but still.. compilation error was because access level in base class was public..and in extended class it was default.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!