14
编译错误
120
24
第1题:
有如下程序: public class MethLoad { public static void main(String args[]) { MethLoad classObj = new MethLoad(); classObj.methtest(4); classObj.methtest(4.0); } void methtest(double D) { double sum = 2*d; System.out.println("The result is:"+sum); } void methtest(int n) { int sum = 4*n; System.out.println("The result is:"+sum); } } 程序的运行结果为( )。
A.The result is:16 The result is:8.0
B.The result is:8.0 The resuR is:16
C.The result is:8 The result is:16.0
D.The resuR is:16.0 The result is:8
第2题:
classTestApp{publicstaticvoidmain(String[]args){System.out.println(multiply(2,3,4,5));}publicintmultiply(int…nums){intresult=1;for(intx:nums)result*=x;//result=result*x;returnresult;}}2、6、24、120程序运行后的输出是哪项?()
A.14
B.编译错误
C.120
D.24
第3题:
interface A{
int x = 0;
}
class B{
int x =1;
}
class C extends B implements A {
public void pX(){
System.out.println(x);
}
public static void main(String[] args) {
new C().pX();
}
}
错误。在编译时会发生错误(错误描述不同的JVM 有不同的信息,意思就是未明确的
x 调用,两个x 都匹配(就象在同时import java.util 和java.sql 两个包时直接声明Date 一样)。
对于父类的变量,可以用super.x 来明确,而接口的属性默认隐含为 public static final.所以可
以通过A.x 来明确。
第4题:
下列语句中变量result的结果为( )。 public class test { public static void main(String args[ ]) { int sum=10; int r=3; int result=sum %( ++r); System.out.println(result); } }
A.3
B.10
C.2
D.4
第5题:
有如下程序: public class MethLoad { public static void main(String args[]) { MethLoad classObj=new MethLoad(); classObj.methtest(4); classObj.methtest(0); } void methtest(double d) { double sum=2*d; System.out.println("The result is:"+sum); } void methtest(int n) { int sum=4*n; System.out.println("The result is:" +sum); } }程序的运行结果为( )。
A.The result is:16 The result is:0
B.The result is:0 The result is:16
C.The result is:8 The result is:0
D.The result is:0 The result is:8
第6题:
程序: class TestApp{ public static void main(String[] args){ System.out.println(multiply(2,3,4,5)); } public int multiply(int[] nums){ int result = 1; for(int x :nums) result *= x; return result; } } 程序运行后的输出是哪项?()
第7题:
interface DeclareStuff{ public static final int EASY = 3; void doStuff(int t); } public class TestDeclare implements DeclareStuff { public static void main(String [] args) { int x=5; new TestDeclare().doStuff(++x); } void doStuff(int s) { s += EASY + ++s; System.out.println(”s “ + s); } } What is the result?()
第8题:
public class Yikes { public static void go(Long n) {System.out.println(”Long “);} public static void go(Short n) {System.out.println(”Short “);} public static void go(int n) {System.out.println(”int “);} public static void main(String [] args) { short y= 6; long z= 7; go(y); go(z); } } What is the result?()
第9题:
class TestApp{ public static void main(String[] args){ System.out.println(multiply(2,3,4,5)); } public int multiply(int... nums){ int result=1; for(int x:nums) result*=x; return result; } } 程序运行后的输出是哪项?()
第10题:
120
24
14
编译错误
第11题:
14
编译错误
120
24
第12题:
s 14
s 16
s 10
Compilation fails.
An exception is thrown at runtime.
第13题:
A.120
B.24
C.14
D.编译错误
第14题:
A.14
B.编译错误
C.120
D.24
第15题:
以下程序运行后输出的结果是______。
public class exl7
{
public static void main(String args [])
{
int a = 0;
for(int j = 1; j <= 20; j++)
if(j%5 != 0)
a = a + j;
System.out.println (a);
第16题:
下面的语句片段中,变量result结果为( )。 public class Test { public static void main (String args[ ]) { int sum=0; int r=2; iht result=(sum==1?sum:r); System. out. println (result); } }
A.1
B.2
C.10
D.0
第17题:
( 17 )下列程序的输出结果是
public class Test{
public static void main(String[] args){
int [] array={2,4,6,8,10};
int size=6;
int result=-1;
try{
for{int i=0;i<size && result==-1;i++}
if(array[i]==20) result=i;
}
catch(ArithmeticException e){
System.out.println( " Catch---1 " );
catch(ArrayIndexOutOfBoundsException e){
System.out.println( " Catch---2 " );
catch(Exception e){
System.out.println( " Catch---3 " );
}
}
A ) Catch---1
B ) Catch---2
C ) Catch---3
D )以上都不对
答案暂缺
第18题:
class TestApp{ public static void main(String[] args){ System.out.println(multiply(2,3,4,5)); } public int multiply(int… nums){ int result = 1; for(int x :nums) result *= x; //result =result*x; return result; } } 2、6、24、120 程序运行后的输出是哪项?()
第19题:
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?()
第20题:
public class Test { private static int[] x; public static void main(String[] args) { System.out.println(x[0]); } } What is the result?()
第21题:
0
null
Compilation fails.
A NullPointerException is thrown at runtime.
An ArrayIndexOutOfBoundsException is thrown at runtime.
第22题:
0
1
2
Compilation fails.
第23题:
int Long
Short Long
Compilation fails.
An exception is thrown at runtime.
第24题:
14
编译错误
120
24