问题:
1.public class Test {
2.public static void main (String args[]) {
3.class Foo {
4.public int i = 3;
5.}
6.Object o = (Object) new Foo();
7.Foo foo = (Foo)o;
8.System.out.printIn(foo. i);
9. }
10.}
What is the result?()
A . Compilation will fail.
B . Compilation will succeed and the program will print “3”
C . Compilation will succeed but the program will throw a ClassCastException at line 6.
D . Compilation will succeed but the program will throw a ClassCastException at line 7.
1.public class Test {
2.public static void main (String args[]) {
3.class Foo {
4.public int i = 3;
5.}
6.Object o = (Object) new Foo();
7.Foo foo = (Foo)o;
8.System.out.printIn(foo. i);
9. }
10.}
What is the result?()
● 参考解析
本题暂无解析
相关内容
相关标签