t++; break; }
System.out.prinln( “*****”);
A B C D
14在Java中,运行以下代码,输出结果是(A) public class Sample{
int i=20; int j=10; void test(){
int i=3; System.out.prinln( “result is”+(i+j)); } public sratic viod main(String[] args){
Sample t=new Sample(); t.test(); } }
A result is 30 B result is 13 C result is 33 D 编译错误
15下列Java代码编译运行后的输出结果是(X) int i=10; for(){
i--; System.out.prinln(i+” ”); if(i==10-i){
break; } }
}
t is less than 3 or equal 3***** t is bigger than 5 *****
t is less than 3 or equal 3 *****
t is less than 3 or equal 3 t is less than 3 or equal 3 *****
t is bigger than 5 ***** 死循环
A 8765 B 9876 C 98765 D 987654
第五套
1.在JAVA语言进行程序开发时,需要循环的步骤(D) (选择一项) a) 创建项目并编写源程序 b) 编译源程序 c) 运行源程序 d) 以上都包括
2.在JAVA中经常用System.out对象的print()方法实现控制台输出,则下面选项中描述正确的是(C) (选择一项) a) print()可以实现控制台输出并实现换行 b) println()在实现控制台输出前先进行换行 c) print()可以实现控制台输出,但是不换行
d) println()在实现控制台输出时,前后都进行换行
3.在JAVA中,关于编码规范的说法,错误的是(B) (选择一项) a) 遵首编码规范可以增加代码的可读性 b) 一行推荐写多行语句
c) 类名一般使用大写字母开头
d) 遵守编码规范可以使软件开发和维护更加方便
4.在JAVA中,能够去掉字符串前后空格的方法是(A) (选择一项) a) trim() b) replace() c) delete () d) substring ()
5.在JAVA中,有下面代码,其中可以正确编译的是(X) (选择一项) a) double d=(int)2; b) int i=1.34;
c) int i= (double)1 d) 以上都正确
6.在JAVA中,变量命名正确的是(D) (选择一项) a) ${student} b) 1_people c) _OK d) “name”
7.在JAVA中,使用switch语句时,如希望设置默认值,则需要使用(C)关键字 (选择一项) a) case b) do c) default
d) else
8.在JAVA中,关于类的方法,下列描述错误的是(D) (选择一项) a) 类的每一个方法都定义一个功能
b) 类的方法对应对象的属性,描述对象的静态特殊特征 c) 方法名必须以字母,下划线”_”或”$”开头
d) 方法体应该由一对大括号括起来,它包含一段程序代码
9.在JAVA中,下面的赋值语句正确的是(C) (选择一项) a) int i=1.34;
b) Boolean bool=1;
c) String str=”HelloWorld” d) 以上都正确
10.在JAVA中,如下代码的输出结果是(B) (选择一项) Public static void main(String args[]){ int i=0; if(++i<1)
System.out.println(“i小于1”); }
a) i小于1 b) 无输出 c) 编译错误 d) 运行时错误
11.在JAVA中,如下代码段的输出结果是(D) (选择一项) Public static void main(String args[]){ int i=3; do{
for(int j=3;j<4;j++){
System.out.println(“j is”+j); } i++;
}while(i>3 && i<5) }
a) j is 3 j is 4 j is 3 j is 4 b) j is 3 j is 3
c) 什么都不输出 d) j is 3
12.在JAVA中,关于类与对象的说法,正确的是(A) (选择一项) a) 代码:String s = new String();中的String是类,s是对象 b) 对象包括类,类是对象的具体表现
c) 对象拥有自己的行为和属性,和对应的类没有关系 d) 学生,可以看作是张三类或李四类的对象
13.在JAVA中,如下代码段输出的结果是(D) (选择一项) Public static void main(String args[]){ int i = 5;
String [] s = {“a”,.”b”,”c”}; for(int i =0 ;i<10; i++){
System.out.println(s[i]); } } a) abc
b) abcnullnullnullnullnullnullnull c) 编译时错误 d) 运行时错误
14.在JAVA中,有如下代码段,当i和j分别为(X)时,输出结果是“条件符合” (选择一项) if((i>30 && i<40 )|| (i ==60 && j>60)){ System.out.println(“条件符合”); }else{
Systrm.out.println(“条件不符合”)
}
a) i =35, j =40; b) i =40, j =70; c) i =60, j =60; d) i =20, j =30;
15.在JAVA中,运行下面的代码,输出结果是(B) (选择一项) Public class Sample { int i = 20; int j = 10; void text () { int i =3;
Sysem.out.println(“result is”+(i+j));
}
}
public static void Main(string[]args){ Sample t = new Sample(); t . text(); }
a) result is 30 b) result is 13 c) result is 33 d) 编译错误
16.在JAVA中,下面代码输出结果为(B) (选择一项) public static void Main(string[]args){
String s1 = new String(“hr@bdqn.com”); String s2 = new String();
s2 = s1.substring(0,s1.indexOf(“@”)); Sysem.out.println(“s2=”+s2); a) hr
b) s2=hr@ c) s2=hr d) hr@
17.在JAVA中,如下代码段的输出结果为(D) (选择一项) Public class Test{
public void method1(int i){ System.out.print(i); }
public void method2(){ int i = 2;
System.out.print(i); }
public void method3(){ System.out.print(i); }
public static void Main(string[]args){ Test test = new Test(); test.method1(5);
test.method2(); test.method3();
}
a) 5
2 2 b) 5
2 5
c) 不能正常运行,编译时出错 d) 以上都不正确
18.在JAVA中,运行下面代码后输入80,则输出结果是(B) import java.util.*; public class Hello{ int i = 20; int j = 10;
public static void Main(string[]args){ Scanner sc = new Scanner(System.in); int num = sc.nextInt(); System.out.println(num+10); } } a) 80
(选择一项)
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库javaS1复习(4)在线全文阅读。
相关推荐: