/* 子类可以重写父类中的方法,甚至是root class中的方法,比如NSObeject 的new方法,但是后提示警告如下 Method is expected to return an instance of its class type 'Student', but is declared to return 'void' */ #import <Foundation/Foundation.h> @interface Student : NSObject + (void)new; @en…
代码 public class Test { public static void main(String[] args) { Shape shape = new Circle(); System.out.println(shape.name); shape.printType(); shape.printName(); } } class Shape { public String name = "shape"; public Shape(){ System.out.println(…