黑马程序员技术交流社区
标题:
分析程序结果
[打印本页]
作者:
xh_javaee
时间:
2016-9-13 00:17
标题:
分析程序结果
这个程序得到什么结果?
public class Dervied extends Base {
private String name = "dervied";
public Dervied() {
tellName();
printName();
}
public void tellName() {
System.out.println("Dervied tell name: " + name);
}
public void printName() {
System.out.println("Dervied print name: " + name);
}
public static void main(String[] args){
new Dervied();
}
}
class Base {
private String name = "base";
public Base() {
tellName();
printName();
}
public void tellName() {
System.out.println("Base tell name: " + name);
}
public void printName() {
System.out.println("Base print name: " + name);
}
}
作者:
taozhihui
时间:
2016-9-13 00:46
Base tell name:base
作者:
taozhihui
时间:
2016-9-13 00:47
Base print name:base,Dervied tell name:derived,Dervied print name:derived
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2