class A{
{
System.out.println("d");
}
B b = new B();
}
class B{
B(){
System.out.println("c");
}
}
public class Demo{
public static void main(String[] args){
new A();
}
}
public class Demo {
{
System.out.println("构造代码块");
}
public static void main(String[] args) {
{
System.out.println("普通代码块");
}
Demo demo = new Demo();
}
}
局部内部类中访问局部变量,局部变量需要被final修饰
A. private class A{ public A getA(){ return new A(); } }
B. private abstract class A{ public abstact void method(); }
C. public abstract class A{ public static abstract void method(); }
D. public abstract class A{ public abstract final void method(); }
E. public interface Demo { public void method(); }
F. public interface Demo { private static final String s = “a”; }
抽象类要让子类继承并重写抽象方法,使用private修饰便不能被继承和重写,使用final修饰也不能被重写,使用static修饰,可以类名直接调用方法,但抽象方法没有主体调用无意义,所以abstract不能和private,final,static共用
局部变量Illegal modifier for parameter num; only final is permitted
局部变量只能 final修饰
类Illegal modifier for the class A; only public, abstract & final are permitted
抽象方法The abstract method method in type A can only set a visibility modifier, one of public or protected
This method requires a body instead of a semicolon
修饰类只能使用public、protected、final、abstract关键字
接口中只有常量和抽象方法,常量修饰符为public static final
|
|