Hello,guoqiao:
Thank you for your kindly help. I learned a lot from your reply.
Acturally, I am confused with your last code. let's say
Base b = new Sub();
b.amethod(100);
In this case, in my opinion, it will use the amethod() in the Sub class, since the actural object type of b is Sub, the reference type of b is Base, so, i think
java will decide which method will be used based upon the object type.
I haven't tried that, let's compile and see what will happen.
By the way, when i do the mock exam for programmer
test, i always can't figure out the compile time error and runtime error. I know there is something wrong with the code, but sometimes it is very difficult to choose the compile time error or runtime error.
If u have any experience in this field, hope u can give me some hints.
Anyone who knows where i can find some useful resources about this topic can feel free to reply to me.
Thanks a lot.
Honggui