Hi Jane,
Initially I shared your idea,but when I looked carefully, here is what I found:
You said static methods are not inherited ,I tried this:
class stat{
static void Mystat(){
System.out.println("Mystat from stat");
}}
class statDemo extends stat{
public static void main(String[] arg){
Mystat();}}
Result:MyStat from stat
This means it did inherit,isn't it ?(doubts are always there).
Now what I think is,firstly, when the member is private 'the parent method is taken in the derived', and is not overriden(
you should'nt as you said).
Secondly, when the member is static I believe, Dynamic Dispatch does'nt work, may be bcoz it is class method and not instance method.The reason why Iam saying is bcoz of this
class Base{
static void BaseStat(){
System.out.println("Base.");
} }
class Gbase extends Base{
static void BaseStat(){
System.out.println("Gbase.");
}}
class Dbase extends Gbase{
static void BaseStat(){
System.out.println("Dbase.");
}}
public class Derived{
public static void main(String[] arg){
Base b1=new Base();
System.out.println("Base b1=new Base():");
b1.BaseStat();
b1=new Gbase();
System.out.println("Base b1=new Gbase():");
b1.BaseStat();
b1=new Dbase();
System.out.println("Base b1=new Dbase():");
b1.BaseStat();
}}
RESULT:
Base b1=new Base():
Base.
Base b1=new Gbase():
Base.
Base b1=new Dbase():
Base.
Please correct me if Iam wrong.
Thanks