设有如下程序
public class test {
public static void main(String args[]) {
Integer intObj=Integer.valueOf(args[args.length-1]);
int i = intObj.intValue();
if(args.length >1、
System.out.println(i);
if(args.length >0)
System.out.println(i -1、;
else
System.out.println(i - 2、;
}
}
运行程序,输入如下命令:
java test 2
则输出为:
A. test
B. test -1
C. 0
D. 1
E. 2
第1题:
A.public static void main()
B.public static void main(String[] args)
C.public static int main(String[] args)
D.public void main(String[] args)
第2题:
如下两个源程序文件,分别编译后,运行Example.class文件,运行结果为______。
AB.java文件代码如下;
package test;
public class AB
{
int a=60;
public void show()
{
System.out.println(”a=”+a);
}
Example.java文件代码如下:
import test.AB;
class Example
{
public static void main(String args[])
{
AB bj=new AB();
obj.show();
}
}
第3题:
下列程序段的输出结果是【 】。
public class Test {
void printValue(int m) {
do {
System.out.println("The value is"+m);
}while (--m>10);
}
public static void main (String args[]) {
int i=10;
Test t= new Test();
t.printValue(i);
}
}
第4题:
下列程序的输出结果是( )。 public class Test { public static void main (String[] args) { String s="hello"; s.replace ('r','m'); System.out.println(s); } }
A.hello
B.HELLO
C.hemmo
D.HEMMO
第5题:
下列程序的执行结果是( )。 public class Test { public static void main(String args[]) { System.out.println(5/2); } }
A.2.5
B.2
C.2.5
D.2
第6题:
下列程序中,实现将封装数据类型Integer和基本数据类型int之间的转换,以及Integer,int类型和String类型之间的转换。请将程序补充完整。
程序运行结果如下:
123
456
456
public class ex7_1{
public static void main(String[]args) {
Integer intObj;
int n;
String s;
intObj = new Integer(123);
n=intObj.__________;
System.out.printin(Integer.toString(n));
s=new String("456");
intObj=Integer._________;
System.out.println(intObj.__________);
n=Integer.parseInt(s);
System.out.println(Integer.toString(n));
}
}
第7题:
下列程序的输出结果是 class Test{ public static void main(String args[]){ int n=7; n<<=3; n=n&n+1|n+2^n+3; n>>=2; System.out.println(n); } }
A.0
B.-1
C.14
D.64
第8题:
下列程序的运行结果是【 】。
public class Test {
public static void main (String args[]) {
String s1="hello!";
System.out.println (s1.toUpperCase());
}}
第9题:
下列( )是对main ()主方法的正确表示。
A.public void static main (String args []) {…}
B.void public static main (String args []) {…}
C.static public void main (String args []) {…}
D.以上都不正确
第10题:
A.跳出循环,无输出
B.0121
C.01
D.0123