public abstract class Parent { String name = "parent"; } public class Son extends Parent{ public void print(){ this.name = "son"; System.out.println(super.name); System.out.println(this.name); } public static void main(String[] args) t
代码如下: function Animal(){} function Dog (age){ this.name = 'fuck you' ; this.age = age } var dog = new Dog(12); console.log(dog); //{name: "fuck you", age: 12} Dog.prototype = Animal; var dog2 = new Dog(12); console.log(dog2);//{age: 12} dog2对象的n
子类继承父类属性/函数方法: #方式一:(原生方式,不建议使用) class Dongwu(object): def __init__(self,name,sex,old): self.name = name self.sex = sex self.old = old def eat(self): print("吃~~~~~~`") class Cat(Dongwu): def __init__(self,name,sex,old,num): Dongwu.__init__(self,
当java的子类和父类具有相同名字的属性时,到底java是怎么处理的. 先看代码: package com.joyfulmath.study.field; public class Person { public String name; public String getName() { return name; } } package com.joyfulmath.study.field; public class Student extends Person { public String