`
lxtc2014
  • 浏览: 10701 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
文章分类
社区版块
存档分类
最新评论

网易2014年校招杭州站的一道题目

阅读更多
记下来只为给自己一个教训:
class Base{
	private String name = "base";
	public Base() {
		tellName();
		printName(name);
	}
	
	public void tellName(){
		System.out.println("Base tell: "+name);
	}
	
	public void printName(String name){
		System.out.println("Base print: "+name);
	}
	
}
public class Derived extends Base{
	private String name = "derived";
	
	public Derived() {
		tellName();
		printName(name);
	}
	
	public void tellName(){
		System.out.println("Derived tell: "+name);
	}
	
	public void printName(String name){
		System.out.println("Derived print: "+name);
	}
	public static void main(String[] args) {
		new Derived();
	}
}

输出:
Derived tell: null
Derived print: base
Derived tell: derived
Derived print: derived
分享到:
评论
1 楼 oyp2009 2013-10-24  
一个人都没有啊!

相关推荐

Global site tag (gtag.js) - Google Analytics