单选题11. public static void main(String[] args) { 12. Object obj =new int[] { 1,2,3 }; 13. int[] someArray = (int[])obj; 14. for (int i: someArray) System.out.print(i +“ “) 15. } What is the result? ()A 1 2 3B Compilation fails because of an error in line 12.C Compilation fails because of an error in line 13.D Compilation fails because of an error in line 14.E A ClassCastException is thrown at runtime.
单选题
11. public static void main(String[] args) { 12. Object obj =new int[] { 1,2,3 }; 13. int[] someArray = (int[])obj; 14. for (int i: someArray) System.out.print(i +“ “) 15. } What is the result? ()
A
1 2 3
B
Compilation fails because of an error in line 12.
C
Compilation fails because of an error in line 13.
D
Compilation fails because of an error in line 14.
E
A ClassCastException is thrown at runtime.
参考解析
解析:
暂无解析
相关考题:
多选题Integer i = new Integer (42); Long 1 = new Long (42); Double d = new Double (42.0); Which two expressions evaluate to True?()A(i ==1)B(i == d)C(d == 1)D(i.equals (d))E(d.equals (i))F(i.equals (42)
单选题1. interface TestA { String toString(); } 2. public class Test { 3. public static void main(String[] args) { 4. System.out.println(new TestA() { 5. public String toString() { return “test”; } 6. } 7. } 8. } What is the result?()A testB nullC An exception is thrown at runtime.D Compilation fails because of an error in line 1.E Compilation fails because of an error in line 4.F Compilation fails because of an error in line 5.
单选题class super { public float getNum() {return 3.0f;} } public class Sub extends Super { } Which method, placed at line 6, will cause a compiler error?()A Public float getNum() {return 4.0f; }B Public void getNum (){}C Public void getNum (double d){}D Public double getNum (float d) {retrun 4.0f; }
单选题public class ArrayTest { public static void main(String[] args) { float fl[], f2[]; fl = new float[10]; f2 = f1; System.out.println(“f2[0]= “ + f2[0]); } } What is the result?()A It prints f2[0] = 0.0.B It prints f2[0] = NaN.C An error at line 5 causes compile to fail.D An error at line 6 causes compile to fail.E An error at line 6 causes an expectation at runtime.
单选题Which constructs a BufferedIputStream?()A New BufferedInputStream(“in.txt”);B New BufferedInputStream(new File(“in.txt”));C New BufferedInputStream(Writer(“in.txt”));D New BufferedInputStream(new Writer(“in.txt”));E New BufferedInputStream(new InputStream(“in.txt”));F New BufferedInputStream(new FileInputStream(“in.txt”));
单选题package foo; import java.util.Vector; private class MyVector extends Vector { int i = 1; public MyVector() { i = 2; } } public class MyNewVector extends MyVector { public MyNewVector() { i = 4; } public static void main(String args[]) { MyVector v = new MyNewVector(); } } What is the result?()A Compilation succeeds.B Compilation fails because of an error at line 5.C Compilation fails because of an error at line 6.D Compilation fails because of an error at line 14.E Compilation fails because of an error at line 17.
多选题Which lines of code are valid declarations of a native method when occurring within the declaration of the following class?() public class Qf575 { // insert declaration of a native method here }Anative public void setTemperature(int kelvin);Bprivate native void setTemperature(int kelvin);Cprotected int native getTemperature();Dpublic abstract native void setTemperature(int kelvin);Enative int setTemperature(int kelvin) {}
单选题public static void test(String str) { int check = 4; if (check = str.length()) { System.out.print(str.charAt(check -= 1) +“, “); } else { System.out.print(str.charAt(0) + “, “); } } and the invocation: test(”four”); test(”tee”); test(”to”); What is the result?()A r, t, t,B r, e, o,C Compilation fails.D An exception is thrown at runtime.
多选题class ClassA {} class ClassB extends ClassA {} class ClassC extends ClassA {} and: ClassA p0 = new ClassA(); ClassB p1 = new ClassB(); ClassC p2 = new ClassC(); ClassA p3 = new ClassB(); ClassA p4 = new ClassC(); Which three are valid?()Ap0 = p1;Bp1 =p2;Cp2 = p4;Dp2 = (ClassC)p1;Ep1 = (ClassB)p3;Fp2 = (ClassC)p4;
多选题Use the operators "", which statements are true? ()A0000 0100 0000 0000 0000 0000 0000 00005 gives 1000 0000 0000 0000 0000 0000 0000 0000B0000 0100 0000 0000 0000 0000 0000 00005 gives 1111 1100 0000 0000 0000 0000 0000 0000C1100 0000 0000 0000 0000 0000 0000 00005 gives 1111 1110 0000 0000 0000 0000 0000 0000D1100 0000 0000 0000 0000 0000 0000 00005 gives 0000 0110 0000 0000 0000 0000 0000 0000