考考你们的java基础。
不要拿编译器运行,直接写出答案来哦。。。
package com.wen.test;
public class TestExtends {
public static void main(String[] args) {
A a = new B();
B b = new B();
}
}
abstract class A {
abstract void a();
static {
E e = new E();
}
C c = new C();
public A() {
System.out.println( "hello,this is a ");
a();
}
}
class B extends A {
static int b =1;
C c = new C();
void a() {
System.out.println(b);
}
public B() {
System.out.println( "hello,this is b ");
}
}
class C {
public C() {
System.out.println( "hello,this is c ");
}
}
class E {
public E() {
System.out.println( "static e ");
}
}
------解决方案--------------------static e
hello,this is c
hello,this is a
1
hello,this is c
hello,this is b
hello,this is c
hello,this is a
1
hello,this is c
hello,this is b
汗,看看这个
------解决方案--------------------感觉是这样 基本顺序如下
e
c
a
1
c
b
c
a
1
c
b
------解决方案--------------------static e
hello,this is c
hello,this is a
1
hello,this is c
hello,this is b
hello,this is c
hello,this is a
1
hello,this is c
hello,this is b
------解决方案--------------------static e
hello,this is c
hello,this is a
1
hello,this is c
hello,this is b
hello,this is c
hello,this is a
1
hello,this is c
hello,this is b