单项选择题
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.
相关考题
-
多项选择题
Whichtwodeclarationspreventtheoverridingofamethod?()
A. Final void methoda() {}
B. Void final methoda() {}
C. Static void methoda() {}
D. Static final void methoda() {}
E. Final abstract void methoda() {} -
多项选择题
public class OuterClass { private double d1 1.0; //insert code here } You need to insert an inner class declaration at line2. Which two inner class declarations are valid?()
A. static class InnerOne { public double methoda() {return d1;} }
B. static class InnerOne { static double methoda() {return d1;} }
C. private class InnerOne { public double methoda() {return d1;} }
D. protected class InnerOne { static double methoda() {return d1;} }
E. public abstract class InnerOne { public abstract double methoda(); } -
多项选择题
Whichtwostatementsaretrueregardingthecreationofadefaultconstructor?()
A. The default constructor initializes method variables.
B. The default constructor invokes the no-parameter constructor of the superclass.
C. The default constructor initializes the instance variables declared in the class.
D. If a class lacks a no-parameter constructor,, but has other constructors, the compiler creates a default constructor.
E. The compiler creates a default constructor only when there are no other constructors for the class.
