类方法子类和父类
来源:互联网 发布:淘宝上老款诺基亚来源 编辑:程序博客网 时间:2024/05/29 08:49
public class Animal { public static void testClassMethod() { System.out.println("The class method in Animal."); } public void testInstanceMethod() { System.out.println("The instance method in Animal."); }}
public class Cat extends Animal { public static void testClassMethod() { System.out.println("The class method in Cat."); } public void testInstanceMethod() { System.out.println("The instance method in Cat."); } public static void main(String[] args) { Cat myCat = new Cat(); Animal myAnimal = myCat; Animal.testClassMethod(); myAnimal.testInstanceMethod(); }}
The class method in Animal.The instance method in Cat.
Summary
The following table summarizes what happens when you define a method with the same signature as a method in a superclass.Note: In a subclass, you can overload the methods inherited from the superclass. Such overloaded methods neither hide nor override the superclass methods—they are new methods, unique to the subclass.
- 类方法子类和父类
- 父类和子类的构造方法
- 父类和子类的构造方法
- 子类继承抽象父类的方法和抽象父类的子类的一些问题
- 父类和子类的相互转换及父类调用子类的方法
- 子类覆盖父类方法
- 父类调用子类方法
- 子类调用父类方法
- 子类调用父类方法
- 子类的父类和接口有相同的方法
- 子类继承和调用父类的构造方法
- 父类与子类之间变量和方法的调用
- c++ 父类和子类的方法调用
- 父类与子类之间变量和方法的调用
- 子类继承和调用父类的构造方法
- 子类继承和调用父类的构造方法
- 子类调用父类方法:c++和java的不同
- js中的子类继承父类的方法和属性
- 怀念Delphi--希望它能雄起!
- 队列,数组实现,指针实现的源码详细讲解
- ADF中给VO动态添加检索基准,过滤数据(一)
- Tlist
- Android 中文 API (101) —— AsyncTask
- 类方法子类和父类
- android sp wp
- 一篇关于文件挂载的心得,解决了mount: 您必须指定文件系统类型的问题
- 貌似在ubuntu下架了个web服务器,上传上次的flex调色板
- android-ndk-r6编译运行NDK例子
- C++Primer读书笔记(十)
- 3193 经典神奇打表
- windows DNS 服务器递归查询超时机制
- ios ipad 不调用 viewVillAppera 的解决办法