A B C D
13在Java中,运行以下代码,输出结果是(C) public sratic viod main(String[] args){
int t=2; while(t<10){ if(t<=3){
t++;
System.out.prinln( “t is less than 3 or equal 3”); }else if(t>5){
System.out.prinln( “t is bigger than 5”); t++; break; }
System.out.prinln( “*****”);
}
A t is less than 3 or equal 3***** t is bigger than 5 *****
B t is less than 3 or equal 3 *****
C t is less than 3 or equal 3 t is less than 3 or equal 3 ***** t is bigger than 5 ***** D 死循环
14在Java中,运行以下代码,输出结果是(B) 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){
} }
输出0行星星 输出1行星星 输出3行星星 输出5行星星
}
System.out.prinln(“*****”);
}
Sample t=new Sample(); t.test();
A B C D
15下列Java代码编译运行后的输出结果是() int i=10; for(){
i--; System.out.prinln(i+” ”); if(i==10-i){
break; } } A 8765 B 9876 C 98765 D 987654
第四套
1、在JAVA中,分析如下代码段,b应该为(D)数据类型才能使之编译通
过
StringBuffer a=new StringBuffer(”B2C”); B=a.toString(); A int B char C String
D StringBuffer
2 在JAVA中,如下代码输出结果是(* *) int j=1; switch(j){ case 1:
System.out.print(“*”+” ”); j++; case 2: j=1;
System.out.print(“*”+” ”);
break;
}
result is 30 result is 13 result is 33 编译错误
case 3:
System.out.print(“***”+” ”); case 4:
System.out.print(“到此结束!”); Break; } A *
B * ** *** 到此结束! C * ** * ** D * ** ***
3下列关于JAVA的包说法错误的是(C)
A 包允许将类组合成较小单元,便于找到和使用相应的类文件
B JAVA中的包其实类似windows中的目录,他是为了更好的保护类、数据和方法等
C 不同的包中不能出现类名相同的类
D 使用package创建包,使用import引入包
4在JAVA中类定义如下 public class Javatest{······}
下列选项(B)创建了Javatest的一个对象 A Javatest j= Javatest(); B Javatest j=new Javatest(); C Javatest j=newclass Javatest(); D Javatest j=new Javatest;
5在Java中,下面关于面向对象的优点,说法不正确的是(D)
A通过面向对象的程序设计,可以使用“类”来模拟现实世界中实体的特征和行为
B对象的行为和属性被封装在类中,调用时不需要关注内部具体实现 C通过类的模拟,可以创建多个类的对象,从而增加了代码的重用性 D使得程序规模庞大
6关于Java确的是(A)(选两项)中定义数组的方法,下面选项中正 A int[]arr=new int[6]; B int[6]arr=new int[]; C int[6]arr=null; arr=new int[6];
D int[]arr=new int[6]{1,2,3,4,5,6};
7在Java中,下面(B)结果中代码至少被执行一次 A if条件结构 B while循环结构
C do-while循环结构 D for循环结构
8阅读给出的Java代码, 能够添加在下划线中使得输出显示为11的选项是(D) public static void main(String args[]){ int x=5; double y=6.5; int z=______ Sytem.out.print(z) }
A x+y
B x+(double)y C (double)x+y D x+(int)y
9在Java中,以下程序的编译运行结果是(A) Class Point{ Int x; Boolean z; Void output(){ System.out.prinln(x); System.out.prinln(y);
} Public static void main(String[] args){
Point pt=new Point(); Pt.output(); } }
A 运行出错 B 输出:0 true C 输出:0 false D 输出:0 0
10下列Java代码编译运行后的输出结果是(C) public class Test{ public sratic viod main(String[] args){ String s=”1” System.out.prinln(s.concat(“2”)); System.out.prinln(s); }
}
A 1212 B 2121 C 121 D 211
11给定Java代码片段如下所示,则该程序运行后输出结果是(D)
int i=1; int j=i++;
if(i>++j)&&(i++==j){ i+=j; } A 1 B 2 C 3 D 4
12.阅读给出的Java代码,代码运行的结果是(B) public class Demo{ public sratic viod main(String[] args){ int i=9; while(--i>0){ if(i%2==0){
break; }else{ System.out.prinln( “*****”); } }
System.out.prinln(“*****”); }
}
A 输出0行星星 B 输出1行星星 C 输出3行星星 D 输出5行星星
13在Java中,运行以下代码,输出结果是(C) public sratic viod main(String[] args){
int t=2; while(t<10){ if(t<=3){
t++;
System.out.prinln( “t is less than 3 or equal 3”); }else if(t>5){
System.out.prinln( “t is bigger than 5”);
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库javaS1复习(3)在线全文阅读。
相关推荐: