public class Base
{
private String baseName = "base";
public Base()
{
callName();
}
public void callName()
{
System. out. println(baseName);
}
static class Sub extends Base
{
private String baseName = "sub";
public void callName()
{
System. out. println (baseName) ;
}
}
public static void main(String[] args)
{
Base b = new Sub();
}
}
这题考的是成员内部类 结果是什么
public class A {
public A(){
System.out.println("A3");
}
{
System.out.println("A1");
}
static {
System.out.println("A2");
}
}
class B extends A {
public B(){
System.out.println("B3");
}
{
System.out.println("B1");
}
static {
System.out.println("B2");
}
public static void main(String[] args) {
A a1=new B();
B a2=new B();
}
}
这题考的是静态代码块 构造代码块 多态的基本知识
|
|