目录 代码示例 注意事项 代码示例 public class OverrideExercise { public static void main(String[] args) { Person jack = new Person("jack", 18); System.out.println(jack.say()); Student smith = new Student("smith", 18, 1, 99); System.out.println(smith.…
1.子类继承的方法只能操作子类继承和隐藏的成员变量名字类新定义的方法可以操作子类继承和子类新生命的成员变量,但是无法操作子类隐藏的成员变量(需要适用super关键字操作子类隐藏的成员变量.) public class ChengYuanBianLing { public static void main(String[] args) { // TODO Auto-generated method stub CheapGoods cheap=new CheapGoods…
类的继承 父类-子类 关键字 extends 新建一个父类 public class Person { private String name; private int age; public void run() { System.out.println("Person run"); } } public class Student extends Person { public void run() …
使用new关键字来做调用 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { class Program { public class Aminal { public string Name; // 定义宠物的名字 public void PrintNam…