3下列程序段运行的结果为( )。 public class Test{ static void print(String s,int i){ System.out.pdntlnC String: "+s+",int:"+i); } static void print(iht i,String s){ System.out.prinflnCint:"+i+",gtring:"+s); } public static void main(String[] args){ print(99,"Int first"); } }
A.String:String first,int: 11
B.int: 11,String:Int first
C.String:String first,int:99
D. int:99,Stfing:Int first
第1题:
下列程序的运行结果是【 】。
public class Test {
public static void main (String args[]) {
String s1="hello!";
System.out.println (s1.toUpperCase());
}}
第2题:
下列程序段运行的结果为 public class Test{ static void print(String s,int i){ System.out.println("String:"+s+",int:"+i); } static void print(int i,String s){ System.out.println("int:"+i+",String:"+s); } public static void main(String[]args){ print(99,"Int first"); } }
A.String:String first,int:11
B.int:11,String:Int first
C.String:String first,int99
D.int:99,String:Int first
第3题:
下列程序的执行结果是 ( ) public class Test { public int aMethod() { satic int i=0; i++; System.out.println(i); } public static void.main(String args[]) { Test test=new Test(); test.aMethod(); }
A.编译错误
B.0
C.1
D.运行成功,但不输出
第4题:
下面程序段的输出结果是 class Base { int i; Base() { add(1); } void add(int v) { i+=v; } void print() { System.out.println(i); } } class Extension extends Base { Extension() { add(2); } void add(int v) { i+=v*2; } } public class Test { public static void main(String args[]) { bogo(new Extension()); } static void bogo(Baseb){ b.add(8); b.print(); } }
A.9
B.18
C.20
D.22
第5题:
下列程序段运行的结果为 public class Test{ static void print(String s,int i){ System.out.println("String:"+s+",int:"+i); } static void print(int i, String s){ System.out.println("int:"+i+",String:"+s); } public static void main(String [] args){ print(99,"Int first"); } }
A.String:Stringfirst,int:11
B.int:11,String:Int first
C.String:String first,int:99
D.int:99,String:int first
第6题:
下面程序代码运行结果为( )。 import java.awt.*; public class Test { public static void main (String args[]) { String s1="a+b+c"; String s2="+"; int i=s1.lastIndexOf (s2); System.out.println(i); } }
A.0
B.1
C.2
D.3
第7题:
下列程序的运行结果是( )。 public class test{ private String[]data={¨10","10.5"); public void fun{ double s=0: for(int i=0;i<3;j++){ try{ s=s+Integer.parseInt(data[i]); catch(Exception e){ System.out.print("errorl:"+data[i]); } } } public static void main(string[]args){ try{ test d=new test: fun: }catch(Exception e){ System.OUt.println("error2") } } }
A.errorl:10.5
B.error2
C.errorl:10.5 error2
D.以上都不对
第8题:
下列代码的执行结果是( )。
public class Test{
public int aMethod( ){
static int i=0;
i++;
System.out.println(i):
}
public static void main (String args[]){
Trest test=new Test ( );
test aMethod( ):
}
}
A.编译错误
B.0
C.1
D.运行成功,但不输出
B.
C.
D.
第9题:
下列程序的运行结果是( )。 public class test{ private String[]data={¨10","10.5"}, public void fun( double S=0; for(int i=0;i<3;i++){ try{ s=s+Integer.parseInt(data[i]); catch(Exception e){ System.out.print(“errorl:”+data[i])。 } } } public static void main(string[]args){ try{ test d=new test; fun; }catch(Exception e){ System.out.println("error2") } } }
A.errorl:10.5
B.error2
C.errorl:10.5 error2
D.以上都不对
第10题:
A. 0
B. 1
C. 2
D.3
第11题:
error1:10.5
error2
error1:10.5error2
以上都不对
第12题:
4.0,36.0
3.0,40.0
3.0,36.0
4.0,40.0
第13题:
下面代码段的输出结果为( )。 public class Test { public static void main(String sss[]) { int i=0xFFFFFFFl; int j=~i; } }
A.0
B.1
C.14
D.-15
第14题:
下列程序运行后的输出结果为( )。 public class Test { public static void main (String args[]) { int i,j,p,s; s=0; for (i=1;i<=4; i++) { p=1; for(j=1;j<=i:j++) p=p*j; s=s+p; } System.out.println(s); } }
A.46
B.33
C.30
D.40
第15题:
下列代码的执行结果是public class Test{ public int aMethod(){ static int i=0; i++; System.out.println(i); } public static void main(String args[]){ Test test= new Test(); test. aMethod(); }}
A.编译错误
B.0
C.1
D.运行成功,但不输出
第16题:
下列程序执行之后,输出的结果是______。 public class ex4 { public static void main(String[] args) { int j=0; for(int i=3;i>0;i--) { j+=i; int x=2; while(x<j) { x+=1; System.out,print(x); } } } }
A.3555
B.35556666
C.33453456
D.345
第17题:
如下程序是为变量i赋值。若程序的输出结果是180。请将程序补充完整。
注意:不改动程序结构,不得增行或删行。
class Base
{
int i;
Base()
{
add(10);
}
void add(int v)
{
i+=v;
}
void print()
{
System.out.println(i);
}
}
class Extension extends Base
{
Extension()
{
add(______);
}
void add(int v)
{
i+=v*2;
}
}
public class ConstructTest3
{
public static void main(String args[])
{
bogo(new Extension());
}
static void bogo(Base b)
{
b.add(60);
b.print();
}
}
第18题:
阅读下列代码 public class Test { public static void main(String args[]) { String s = "Test"; switch (s) { case "Java": System.out.print("Java"); break; case "Language": System.out.print("Language"); break; case "Test": System.out.print("Test"); break; } } } 其运行结果是( )。
A.Java
B.Language
C.Test
D.编译出错
第19题:
下列程序输出结果为( )。 public class test { public static void main (String args[]) { int a=0; outer:for(int i=0;i<2;i + +) { for(int j=0;j<2;j+ +) { if(j>i) { continue outer; } a+ +; } } System.out.println(a); } }
A.0
B.2
C.3
D.4
第20题:
下列程序的输出结果是 class Demo { void test( ) { Systeme.out.pnnt("NO");} void test(int i) { System.out.print(a);} void test(int a,int b) { System.out.print(a+b);} } class Test { public static void main(String args[ ] ) { Demo de=new Demo( ); de.test( ); de.test(5); de.test(6,8); } }
A.No 5 6 8
B.5 6 8 No
C.No 5 14
D.8 6 No 5
第21题:
下列程序的输出结果是 ( ) class Derao { void test() { Systeme.out.print("NO");} void test (int i) {System.out.print(a);} void test(int a,int b) {System.out.print(a+b);} } class Test { public static void main(String args[]) { Demo de=new Demo(); de.test(); de.test5.; de.test(6,8); } }
A.No568
B.568No
C.No514
D.86No5
第22题:
A.编译错误
B.200
C.100200
D.100
第23题:
Compilation will fail.
Compilation will succeed and the program will print “0”
Compilation will succeed and the program will print “1”
Compilation will succeed and the program will print “2”