JAVA 子父类对象变量的特点

来源:互联网 发布:pl sql develope 编辑:程序博客网 时间:2024/05/15 17:46

//仅作为学习笔记


/*子父类对象出现后,类成员的特点:类中的成员:1,变量2,函数3,构造函数1,变量、如果子类中出现非私有的同名成员变量时,子类访问本类中的对象要用rhis,子类中药访问父类中的同名变量,用supersuper的使用和this 的使用几乎一致this代表的是本类对象的引用super代表的是父类对象的引用*/class father{String word = " wo shi lao die !";}class sun extends father{String word = " lao die zao shang hao !";void show(){System.out.println("The word is \"" + this.word + "\"");System.out.println("The word is \"" + super.word + "\"");}}class ExtendDemo{public static void main(String []args){sun s = new sun();s.show();}}



原创粉丝点击