父亲和儿子的继承关系
class Father { private int asset=10000; public int setAsset(int asset) { this.asset=asset; return asset; } public int getAsset() { return asset; } } class Son extends Father { private int asset=5000; public int setAsset(int asset) { this.asset=asset; return asset; } public int getAsset() { return asset; } } class AssetDemo2 { public static void main(String[] args) { Son s=new Son(); Father f=s; System.out.println(s.getAsset()); System.out.println(f.getAsset()); System.out.println("-----------"); //s.setAsset(200); //f.setAsset(300); //System.out.println(s.setAsset(200)); System.out.println(f.setAsset(300)); System.out.println("-----------"); System.out.println(s.getAsset()); System.out.println(f.getAsset()); } }