publicclassYikes{publicstaticvoidgo(Longn){System.out.println(”Long);}publicstaticvoidgo(Shortn){System.out.println(”Short);}publicstaticvoidgo(intn){System.out.println(”int);}publicstaticvoidmain(String[]args){shorty=6;longz=7;go(y);go(z);}}Whatistheresult?()
A.intLong
B.ShortLong
C.Compilationfails.
D.Anexceptionisthrownatruntime.
第1题:
若给fun函数的形参s传送字符串:"abc-6354abc",则函数的返回值是( )。(字符串中包括空格)
long fun(char S[])
{long n;int sign;
for(;isspace(*s)||islower(*s);s++);
sign=(*s=='-')?-1:1;
if(*s=='+'||*s=='-')s++;
for(n=0;isdigit(*s);s++)
n=10*n+(*S-'0');
return sign*n;
}
第2题:
A.byte, short, int, long, float, double
B.boolean, byte, short, char, int, long, float, double
C.byte, short, char, int, long, float, double
D.byte, short, char
E.int, long, float, double
第3题:
执行完1题的三行代码后,接着执行下面的三行代码: System.out.println(s == s1); System.out.println(s == s2); System.out.println(s1 == s2); 输出的结果是:()
A.true true true
B.false false true
C.false fasle false
D.true true false
第4题:
阅读下面求质数的程序 import java.lang.Math.*: public class MorePrimesTest { public static void main(String[] args) { long[] primes=new long[20]; primes[0]=2L; primes[0]=3L; long number=5L; outer: for(int count=2;count<primes.length;number+=2L) { long limit=(long)Math.ceil(Math.sqrt((double)number)); for(int i=1;i<count&&primes[i]<=limit;i++) { if(number primes[i]==OL)continue outer; } primes[count++]=number; } for(int J=0;j<primes.length;j++) { long n=primes[j]; System.out.println(n); } } } 程序下画线处应填入的正确选项是
A.&
B.*
C./
D.%
第5题:
9、请阅读下面的代码 String s1=new String(“abc”); String s2=s1.intern(); String s3=”abc”; System.out.println(s1==s2); System.out.println(s2==s3); System.out.println(s1==s3); 下列选项中,程序的输出结果为()
A.false true false
B.false false false
C.false true true
D.false false true