有如下java程序,要让控制台输出“method”,请补齐代码( ) ----- 单选
class Demo1_InnerClass {
public static void main(String[] args) {
//补齐代码
oi.method();
}
}
class Outer {
static class Inner {
public void method() {
System.out.println("method");
}
}
}
A、Inner oi = Outer.new Inner();
B、Outer.Inner oi = new Inner();
C、 Outer.Inner oi = new Outer.Inner();
D、 Outer.Inner oi = new Outer.new Inner();
请补齐______处的代码( ) ----- 单选
class Demo1_NoNameInnerClass {
public static void main(String[] args) {
Outer o = new Outer();
o.method();
}
}
// 补齐代码
class Outer {
public void method(){
new Inter(){
public void print() {
System.out.println("---no name print---");
}
}.print();
}
}
A、class Inter{void print();}
B、interface Inter { void print(); }
C、interface Inter { public void print(){}; }
D、abstract class Inter { abstract void print(); }