网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
单选题
Given: 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
Compilation fails because of an error in line 13.
B
A ClassCastException is thrown at runtime.
C
1 2 3
D
Compilation fails because of an error in line 14.
E
Compilation fails because of an error in line 12.
参考答案
参考解析
解析:
暂无解析
更多 “单选题Given: 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 Compilation fails because of an error in line 13.B A ClassCastException is thrown at runtime.C 1 2 3D Compilation fails because of an error in line 14.E Compilation fails because of an error in line 12.” 相关考题
考题
public static void main(String[]args){12.Object obj=new int[]{1,2,3};13.int[] someArray=(int[])obj;14.for(inti:someArray)System.out.print(i+)15.}What is the result?()
A.123B.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.
考题
publicstaticvoidmain(String[]args){12.Objectobj=newint[]{1,2,3};13.int[]someArray=(int[])obj;14.for(inti:someArray)System.out.print(i+)15.}Whatistheresult?()
A.123B.Compilationfailsbecauseofanerrorinline12.C.Compilationfailsbecauseofanerrorinline13.D.Compilationfailsbecauseofanerrorinline14.E.AClassCastExceptionisthrownatruntime.
考题
Given:11.publicstaticvoidmain(String[]args){12.Objectobj=newint[]{1,2,3};13.int[]someArray=(int[])obj;14.for(inti:someArray)System.out.print(i+);15.}Whatistheresult?()
A.Compilationfailsbecauseofanerrorinline13.B.AClassCastExceptionisthrownatruntime.C.123D.Compilationfailsbecauseofanerrorinline14.E.Compilationfailsbecauseofanerrorinline12.
考题
下列程序的执行结果是 ( ) public class ex68{ public static void main(String[]args){ ex68 obj=new ex68(); int s=0; for(int i=1;i<=4;i++){ s+=obj.method(i); } System.out.println(s); } public int method(int n){ if(n==1) return 1; else return n*method(n-1); } }A.3B.9C.33D.153
考题
1. class A { 2. public int getNumber(int a) { 3. return a + 1; 4. } 5. } 6. 7. class B extends A { 8. public int getNumber (int a) { 9. return a + 2 10. } 11. 12. public static void main (String args[]) { 13. A a = new B(); 14. System.out.printIn(a.getNumber(0)); 15. } 16. } What is the result?() A、 Compilation succeeds and 1 is printed.B、 Compilation succeeds and 2 is printed.C、 An error at line 8 causes compilation to fail.D、 An error at line 13 causes compilation to fail.E、 An error at line 14 causes compilation to fail.
考题
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. Integer i = uew Integer(1) + new Integer(2); 13. switch(i) { 14. case 3: System.out.println(”three”); break; 15. default: System.out.println(”other”); break; 16. } 17. } What is the result?() A、 threeB、 otherC、 An exception is thrown at runtime.D、 Compilation fails because of an error on line 12.E、 Compilation fails because of an error on line 13.F、 Compilation fails because of an error on line 15.
考题
class Super { public int i = 0; public Super(String text) { i = 1; } } public class Sub extends Super { public Sub(String text) { i = 2; } public static void main(String args[]) { Sub sub = new Sub(“Hello”); System.out.println(sub.i); } } What is the result?() A、 0B、 1C、 2D、 Compilation fails.
考题
11. public static void main(String[] args) { 12. Object obj = new Object() { 13. public int hashCode() { 14. returns 42; 15. } 16. }; 17. System.out.println(obj.hashCode()); 18. } What is the result? () A、 42B、 An exception is thrown at runtime.C、 Compilation fails because of an error on line 12.D、 Compilation fails because of an error on line 16.E、 Compilation fails because of an error on line 17.
考题
11. class Converter { 12. public static void main(String[] args) { 13. Integer i = args[0]; 14. int j = 12; 15. System.out.println(”It is “ + (j==i) + “that j==i.”); 16. } 17. } What is the result when the programmer attempts to compile the code and run it with the command java Converter 12?() A、 It is true that j==i.B、 It is false that j==i.C、 An exception is thrown at runtime.D、 Compilation fails because of an error in line 13.
考题
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.
考题
11.public static void main(String[]args){ 12.Object obj=new int[]{1,2,3}; 13.int[] someArray=(int[])obj; 14.for(inti:someArray)System.out.print(i+"") 15.} What is the result?()A、123B、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.
考题
public class test( public int aMethod()[ static int i=0; i++; return I; ) public static void main (String args){ test test = new test(); test.aMethod(); int j = test.aMethod(); System.out.printIn(j); ] } What is the result?()A、 Compilation will fail.B、 Compilation will succeed and the program will print “0”C、 Compilation will succeed and the program will print “1”D、 Compilation will succeed and the program will print “2”
考题
public class Test { public static void main(String args[]) { class Foo { public int i = 3; } Object o = (Object)new Foo(); Foo foo = (Foo)o; System.out.println(“i = “ + foo.i); } } What is the result?() A、 i = 3B、 Compilation fails.C、 A ClassCastException is thrown at line 6.D、 A ClassCastException is thrown at line 7.
考题
public class Test { public int aMethod() { static int i = 0; i++; return i; } public static void main (String args[]) { Test test = new Test(); test.aMethod(); int j = test.aMethod(); System.out.println(j); } } What is the result?() A、 0B、 1C、 2D、 Compilation fails.
考题
Given: 11. static class A { 12. void process() throws Exception { throw new Exception(); } 13. } 14. static class B extends A { 15. void process() { System.out.println("B "); } 16. } 17. public static void main(String[] args) { 18. A a = new B(); 19. a.process(); 20. } What is the result? ()A、 Compilation fails because of an error in line 19.B、 An exception is thrown at runtime.C、 BD、 Compilation fails because of an error in line 18.E、 Compilation fails because of an error in line 15. F、 The code runs with no output.
考题
单选题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 Object() { 13. public int hashCode() { 14. returns 42; 15. } 16. }; 17. System.out.println(obj.hashCode()); 18. } What is the result? ()A
42B
An exception is thrown at runtime.C
Compilation fails because of an error on line 12.D
Compilation fails because of an error on line 16.E
Compilation fails because of an error on line 17.
考题
单选题class Super { public int i = 0; public Super(String text) { i = 1; } } public class Sub extends Super { public Sub(String text) { i = 2; } public static void main(String args[]) { Sub sub = new Sub(“Hello”); System.out.println(sub.i); } } What is the result?()A
0B
1C
2D
Compilation fails.
考题
单选题public class Test { public int aMethod() { static int i = 0; i++; return i; } public static void main (String args[]) { Test test = new Test(); test.aMethod(); int j = test.aMethod(); System.out.println(j); } } What is the result?()A
0B
1C
2D
Compilation fails.
考题
单选题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.
考题
单选题public class Test { public static void main(String args[]) { class Foo { public int i = 3; } Object o = (Object)new Foo(); Foo foo = (Foo)o; System.out.println(“i = “ + foo.i); } } What is the result?()A
i = 3B
Compilation fails.C
A ClassCastException is thrown at line 6.D
A ClassCastException is thrown at line 7.
考题
单选题11. public static void main(String[] args) { 12. Integer i = uew Integer(1) + new Integer(2); 13. switch(i) { 14. case 3: System.out.println(”three”); break; 15. default: System.out.println(”other”); break; 16. } 17. } What is the result?()A
threeB
otherC
An exception is thrown at runtime.D
Compilation fails because of an error on line 12.E
Compilation fails because of an error on line 13.F
Compilation fails because of an error on line 15.
考题
单选题public class test( public int aMethod()[ static int i=0; i++; return I; ) public static void main (String args[]){ test test = new test(); test.aMethod(); int j = test.aMethod(); System.out.printIn(j); ] } What is the result?()A
Compilation will fail.B
Compilation will succeed and the program will print “0”C
Compilation will succeed and the program will print “1”D
Compilation will succeed and the program will print “2”
考题
单选题11. class Converter { 12. public static void main(String[] args) { 13. Integer i = args[0]; 14. int j = 12; 15. System.out.println(”It is “ + (j==i) + “that j==i.”); 16. } 17. } What is the result when the programmer attempts to compile the code and run it with the command java Converter 12?()A
It is true that j==i.B
It is false that j==i.C
An exception is thrown at runtime.D
Compilation fails because of an error in line 13.
考题
单选题11.public static void main(String[]args){ 12.Object obj=new int[]{1,2,3}; 13.int[] someArray=(int[])obj; 14.for(inti:someArray)System.out.print(i+"") 15.} What is the result?()A
123B
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.
考题
单选题1. class A { 2. public int getNumber(int a) { 3. return a + 1; 4. } 5. } 6. 7. class B extends A { 8. public int getNumber (int a) { 9. return a + 2 10. } 11. 12. public static void main (String args[]) { 13. A a = new B(); 14. System.out.printIn(a.getNumber(0)); 15. } 16. } What is the result?()A
Compilation succeeds and 1 is printed.B
Compilation succeeds and 2 is printed.C
An error at line 8 causes compilation to fail.D
An error at line 13 causes compilation to fail.E
An error at line 14 causes compilation to fail.
热门标签
最新试卷