Class Methods Inheritence
Posted
by Roman A. Taycher
on Stack Overflow
See other posts from Stack Overflow
or by Roman A. Taycher
Published on 2010-06-15T11:51:37Z
Indexed on
2010/06/15
11:52 UTC
Read the original article
Hit count: 306
I was told that static methods in java didn't have Inheritance but when I try the following test
package test1;
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
TB.ttt();
TB.ttt2();
}
}
package test1;
public class TA {
static public Boolean ttt()
{
System.out.println("TestInheritenceA");
return true;
}
static public String test ="ClassA";
}
package test1;
public class TB extends TA{
static public void ttt2(){
System.out.println(test);
}
}
it printed :
TestInheritenceA ClassA
so do java static methods (and fields have) inheritance (if you try to call a class method does it go down the inheritance chai looking for class methods). Was this ever not the case,are there any inheritance OO languages that are messed up like that for class methods?
© Stack Overflow or respective owner