本帖最后由 黄诗宾 于 2013-3-28 08:57 编辑
- abstract class Fu{
- private String name;
- private int age;
- private double salary;
- Fu(String name,int age,double salary){
- this.name=name;
- this.age=age;
- this.salary=salary;
- }
- String getName(){
- return name;
- }
- int getAge(){
- return age;
- }
- double getSalary(){
- return salary;
- }
- abstract void work();
- }
- class Programmer extends Fu{
- Programmer(String name,int age,double salary){
- super(name,age,salary);
- }
- void work(){
- System.out.println(name+age+salary+"打程序");
- }
- }
- class Demo2{
- public static void main(String[] args){
- Programmer p = new Programmer("张三",22,2000.22);
- p.work();
- }
- }
复制代码 打印显示
这个意思是说
子类的函数可以通过子类的构造函数访问到父类的私有变量么?
|