Java programming for out friends, understand the Java compiler and Jvm is very helpful. Here is my little sense, be regarded as the Java compiler and Jvm little understanding of the small temper it.
class Shuiguo{
void display(){
System.out.println("shuiguo");
}
}
class Pingguo extends shuiguo{
void display(){
System.out.println("pingguo");
}
void showtype(){
System.out.println("I AM AN Apple");
}
}
public class Test{
public static void main(String[] args){
Shuiguo sg1 = new Shuiguo();
Pingguo pg = new Pingguo();
Shuiguo sg2 = new Pingguo();
sg1.display();
pg.display();
sg2.display();
2. Please note that when testing sg2.display (); happen when the details. The compiler is Shuiguo sg2 type detected, and then view the member method below Shuiguo display (); test passed. In other words, sg2 really call display (); this method is who, the compiler is not to ignore, he is only concerned about the type of reference variable if the following is called the reference member variable.
3. In the main method to add a few lines of code are as follows
Test can be resolved through 310-055 friends such code, I got SUN certified to 1 month, there are many of them can not be resolved, some still need the help of friends, get friends SCJP certification basic than I am proficient. Last I heard Testinside good learning materials, my friend bought, but also successfully passed the exam, it is really amazing.
This article is free for republishing
Source: http://ludy1987.articlealley.com/scjp-310055-study-tour-2105159.html