- class Fu
- {
- static int num = 5;
- void method1()
- {
- System.out.println("fu method1");
- }
- void method2()
- {
- System.out.println("fu method2");
- }
- static void method4()
- {
- System.out.println("fu method4");
- }
- }
- class Zi extends Fu
- {
- static int num = 8;
- void method1()
- {
- System.out.println("zi method1");
- }
- void method3()
- {
- System.out.println("zi method3");
- }
- static void method4()
- {
- System.out.println("zi method4");
- }
- }
- class DuoTaiDemo4
- {
- public static void main(String[] args)
- {
- Fu f = new Zi();
- System.out.println(f.num);
- f.method4();
-
- Zi z = new Zi();
- z.method4();
- }
- }
复制代码 |