java期中考察卷_“程序设计基础-Java”期中测试答卷(试卷在后)

41528d3028836879cd698677c3999917.gif“程序设计基础-Java”期中测试答卷(试卷在后)

“程序设计基础-Java”期中测试答卷 (试卷在后)专业___________学号____________姓名___________一.单项选择题(每空1分)1、 2、 3、 4、 5、 6、 7、 8、 9、 10、 11、12、 13、 14、 15、二、填空题(每题2分)1、 2、3、 4、5、 6、7、 8、9、 10、三、程序阅读题(每题5分)1、2、3、4、5、四、程序(段)填空题(每空4分)(1) (2)(3) (4)(5) (6)(7) (8)(9) (10)“程序设计基础-Java”期中测试一.单项选择题1. 已知int a=3,b=4,c=9;,以下表达式值不为零的是______。A.a/b B.c/b/a C.c%a D.c%b2. 以下选项中不正确的整型常量是_____。A. 12L B. -10 C. 1,900 D. 0 x123 3. 设z=false,则表达式 !!!z 的值是______。A.0 B.1 C.false D.true4. 表达式 !(x>0||y>0) 等价于_____。A.!x>0||!y>0 B.!(x>0)||!(y>0) C.!x>0 将得到______。A.012 B.12 C.10 D.188. 设x=5,y=6,则表达式(x!=0) A.b,c B.语句不合法 C.98, 99 D.b,9913. 以下选项中不正确的实型常量是_____。A.1E3.2 B.2.3e-1 C..23 D.2.3e014. 下列运算符中,优先级从高到低依次排列为_____。A.!, if(i>2) if ( i0y= 0 x=0-1 xk) break; else s += k; System.out.println( k+“ “+ s);6. 输入12345#后,下列程序段的输出结果是_____。import java.io.*;public class T1{public static void main(String []args)throws IOException{ char c;for(c=(char)System.in.read(); (char)System.in.read()!= # ; c=(char)System.in.read())System.out.print(c);}}7. 用下列for循环将小写字母逆序输出(即从z到a), 其语句应为:for (i=0; i后,下列程序的输出结果是_______,该程序的主要功能是_______。 (其中ch=(char)System.in.read(); 表示读入一个字符)import java.io.*;public class T1{public static void main(String []args)throws IOException{char ch;long number=0;while((ch=(char)System.in.read()) 6 ) ;while(ch!= ? public class T1{public static void main(String []args){int j,k,n;long f,s;Scanner in=new Scanner(System.in);n=in.nextInt();s=0; f=1;for(k=1;k , 则以下程序的输出结果是_______。import java.io.*;public class T1{public static void main(String []args)throws IOException{int m=0, sum=0;char c, oldc= + ;do {c=(char)System.in.read();if(c= 0 ) m=10*m+c - 0 ;else {if(oldc== + ) sum += m;else sum -= m;m=0;oldc=c;System.out.print(sum+“,“);}} while(c!= = );}}四、程序(段)填空题1.输入1 个正整数 n, 计算并输出 s 的前n项的和。S = 1 -1/2 + 1/3 - 1/4 + 1/5 -1/6 + ……import java.util.*;public class T1{public static void main(String []args){// S = 1 -1/2 + 1/3 - 1/4 + 1/5 -1/6 + ……int k, flag, n;float s;Scanner in=new Scanner(System.in);n=in.nextInt();flag=1;___(1 )___;for (k=1 ; k= 0 &&ch0?1:(x==0?0:-1) 或:y=(x>=0)?(x>0?1:0):-1 或: y=x==0?0:(int)(x/Math.abs(x))3、false4、i=1,s=455、4 66、137、System.out.print((char)( z -i))8、6 49、2213610、2三、程序阅读题1、2 12、k=6,x=03、2#18#4、1#3#21#1173#5、0,-10,5,2,-3,四、程序填空题:1、 (1)s=0 (2)flag*1.f/k (3)flag=-flag2、 (4)max=x (5)x!=-1 (6)x=in.nextInt()3、 (7)z=x (8)x=y4、 (9)x!=0 (10)y=y*2+t

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值