+ 1
why can't we call interface static method via subclass object??
we can call a static method of a class via its subclass object, but we can't call static method of an Interface via its subclass object. why? look at the code below: https://code.sololearn.com/c6eYYTUu8qiE
6 ответов
+ 2
Nope, it definitely doesn't work.
Here's a code with interfaces, classes and static methods. Hope it's not confusing:
https://code.sololearn.com/cnpkZ1DR2hHb/?ref=app
+ 2
because static method defined inside interface belongs to that interface, not to the class that implements it.
+ 2
Yes, you could do that, it's called method "hiding". But if you try to do that with interface and class that implements it, you will get error... I will try to write a code to demonstrate these stuff...
+ 1
static methods inside a superclass also belong to that superclass. don't they?? but they can be called via their subclass's objects
+ 1
thank you so much. so the same concept is not working on interfaces.interesting
+ 1
I got it now. that was really helpful thank you so much