《程序设计基础》试卷(A卷)

合集下载

《C语言程序设计基础》--试卷A及参考答案

《C语言程序设计基础》--试卷A及参考答案

《C语言程序设计基础》--试卷A及参考答案《c语言程序设计基础》试卷 (A卷)考试时间:90分钟闭卷任课老师:班级:学号:成绩:(每小题2分,共30分)、由C++源文件编译生成的目标文件的缺省)A、cppB、exeC、obj 、lik、下列中,不是C++合法的标识符()A、2mnB、m123C、kk 、a_1、C++中,基本数据类型不包括()、int B、float C、char 、class、x和y均为bool量,则x| |y为真的条件)、它们均为真 B、其中一个为真 C、《C语言程序设计基础》第 2 页共 6 页它们均为假 D、其中一个为假5、C++中,一个字符型数据在内存中占()字节。

A、4B、2C、1D、86、字符串常量”hello”的长度是()A、5B、6C、7D、87、以下语句,int i=2,j=2,m,n;m=i++;n=++j;则m,n,i,j的值分别为()A、2,3,2,2B、2,3,3,3C、2,2,3,3 D、3,3,2,28、假定a为一个整型数组名,则元素a[4]的字节地址为()A、a+4B、a+8C、a+16D、a+329、 x>0 || y==5的相反表达式为()。

A、 x<=0 || y!=5B、 x<=0 && y!=5C、 x>0 || y!=5D、 x>0 && y==5《C语言程序设计基础》第 3 页共 6 页10、在下面的函数声明中,存在着语法错误的是()A、void BC(int a , int)B、void BD(int , int)C、void BE(int , int=5)D、int BF(int x ; int y)11、循环体至少被执行一次的语句为()。

A、for循环B、while循环C、do循环 D、任一种循环12、已知一函数中有下列变量定义,其中属于静态变量的是()A、int a=5;B、staticdouble b;C、register char c;D、auto shortd;13、do语句能够改写为()语句。

c语言程序设计试卷及答案(A)

c语言程序设计试卷及答案(A)

《C语言程序设计》2013至2014 学年度第 1 学期期末(A)卷(考生注意:考试时间为120分钟。

答案须写在答题纸上,并注明题号,考试结束后将试卷连同答题纸一齐交)一、单项选择题(每小题2分,共40分)1.在一个C语言程序中,有并且只能有一个( )函数。

A. main函数B.自定义函数C.外部函数D.内部函数2.一个C语言程序,总是从()函数开始执行。

A. main函数B.自定义函数C.外部函数D.内部函数3.下列标识符中,不能用作变量名的是( )。

A. _1234_B. _1_2C. int_2_D. 2_int_4.下列字符常量不合法的是( )。

A. ‘2’B. ‘\t’C. ‘ab’D. ‘ \n’5.执行以下语句后的输出结果为( )。

int x; float y; y=3.6; x=(int)y+10; printf(“x=%d,y=%f”,x,y);A. x=13.6,y=3.600000B. x=13,y=3.600000C. x=13,y=3D. x=13,y=3.66.以下哪种变量类型在C语言中不存在( )。

A. 整型变量B.实型变量C. 字符串变量D.字符变量7.设m=10,n=4,则赋值运算m%=n+1执行后m的值是( )。

A. 1B. 2C. 3D. 08.下面语句执行后输出结果为( )。

int x=10,y=3,z; printf(“%d\n”,z=(x%y,x/y));}A. 0B.1C. 3D. 49. 下面语句执行后输出结果为( )。

int x=10,y=10,z=10; printf(“%d,%d,%d ”,x++,--y,++z);}A. 10,10,10B. 10,9,11C. 9,10,11D. 11,10,910.以下选项中不是C语句的是( )。

A. {int i; i++; printf("%d\n", i); }B. ;C. a=5,c=10D. { ; }11.以下程序的输出结果是( )。

C语言程序设计试卷(含答案)

C语言程序设计试卷(含答案)

.2015年春季学期《C 语言程序设计》试卷A一.选择(每道小题2分,合计30分)1、以下选项中合法的标识符是( )。

A)1_1B)1-1C)_11D)1_ _2、若函数中有定义语句:int k;,则( )。

A)系统将自动给k 赋初值0 B)这时k 中的值无定义 C)系统将自动给k 赋初值-1D)这时k 中无任何值3、以下选项中,能用作数据常量的是( ) 。

A)o115B)0118C)1.5e1.5D)115L4、设有定义:int x=2;,以下表达式中,值不为6的是( )。

A)x*=x+1 B)X++,2*x C)x*=(1+x)D)2*x,x+=25、程序段:int x=12; double y=3.141593;printf("%d%8.6f",x,y);的输出结果是( )。

A)123.141593 B)12 3.141593C)12,3.141593D)123.14159306、把2进制数10000111101转化为十进制数为( )。

A)1083B)1084 C)1085D)10867、以下是if 语句的基本形式: if(表达式) 语句 其中"表达式"( )。

A)必须是逻辑表达式B)必须是关系表达式 C)必须是逻辑表达式或关系表达式D)可以是任意合法的表达式8、有以下程序#include <stdio.h> main(){ int x; scanf("%d",&x);if(x<=3); elseif(x!=10) printf("%d\n",x);}程序运行时,输入的值在哪个范围才会有输出结果( )。

A)不等于10的整数 B)大于3且不等于10的整数 C)大于3或等于10的整数D)小于3的整数9、有以下程序#include <stdio.h> main(){ int a=1,b=2,c=3,d=0; if (a==1 && b++==2)if (b!=2||c--!=3) printf("%d,%d,%d\n",a,b,c);else printf("%d,%d,%d\n",a,b,c); else printf("%d,%d,%d\n",a,b,c);} 程序运行后输出结果是( )。

《Java语言程序设计》考试试卷(A卷)附答案

《Java语言程序设计》考试试卷(A卷)附答案

生姓名: 学号: 班级: 专业 命题: 审批:--------------------------------------------------------- 密 ---------------------------- 封 --------------------------- 线 -----------------------------------------------------------**工学院高等学历继续教育2019年第 一 学期《Java 语言程序设计》考试试卷(A 卷、开卷)附答案---------------------------------------------------------- 密 ---------------------------- 封 --------------------------- 线 ----------------------------------------------------------- 学生姓名: 学号: 班级: 专业 命题: 审批:**学院高等学历继续教育2019 学年第一学期科目:《Java语言程序设计》考试试卷试题A试题答案及评分标准命题教师:** 使用班级:函计19-3一、单项选择题(在每小题的四个备选答案中,选出一个正确答案,并将正确答案的序号填在题干的括号内。

每小题1分,共15分)1.C2.D3.A4. A5.D6.C7. B8. A9. B 10. C 11.C 12.A13.A 14.B 15.C二、填空题(本大题共15题15空,每空1分,共15分)1. ;2.class3. ,4. break5.退出6. /*7. 赋值8. 循环9. return 10. equals 11. 0 12. 标签13. , 14. 类变量 15. this三、问答题(本大题共3题,每题10分,共30分)1.什么是Java编程语言(10分)答:Java是一门面向对象的计算机编程语言。

Java语言与面向对象程序设计基础A卷

Java语言与面向对象程序设计基础A卷

Java 语言与面向对象程序设计基础试题 第1页(共10页) Java 语言与面向对象程序设计基础试题 第2页(共10页)一、判断题(判断下列说法是否正确,正确打“√”,错误打“×”,每小题2分,共20分) 1. Java 有两类程序:Java Application 和Java Applet ,其中Java Applet 程序由嵌入到浏览器中的解释器解释运行。

( ) 2.Java 程序里,创建新的对象用new 调用构造方法,回收无用的对象使用关键字free 。

( ) 3.Java 的类不允许多重继承,但接口支持多重继承。

( ) 4.Applet 是一种特殊的Panel ,它是Java Applet 程序的最外层容器。

( ) 5.Java 语言中的数组元素下标总是从0开始,下标可以是整数或整型表达式。

( ) 6.构造方法是一种特殊的方法,名字与类名一致,但返回类型都为void 型。

( ) 7.无论Java 源程序包含几个类的定义,若该源程序文件以A.java 命名,编译后生成的都只有一个名为A 的字节码文件。

( ) 8.在不同的软硬件平台上,Java 的各种数据类型所占用的内存长度不同,因此程序的可移植性不强。

( ) 9.Java 系统的标准输入对象是System.in ,标准输出对象有两个,分别是标准输出System.out 和标准错误输出System.err 。

( ) ( ) 二、单项选择题(每小题2分,共40分) 1.在编写Java Applet 程序时,需要在程序的开头写上( )语句。

A .import java.awt.* ; B .import java.applet.* ; C .import java.io.* ; D .import java.awt.event.* ; 2.以下声明正确的是( )。

A .public static int x; B .default int x; C .abstract double d; D .abstract final int x; 3.Java application 中的主类需包含main 方法,main 方法的返回类型是( )。

08工业工程程序设计基础试卷(A卷,带答案)

08工业工程程序设计基础试卷(A卷,带答案)

08⼯业⼯程程序设计基础试卷(A卷,带答案)⼴东海洋⼤学 2007 —— 2008 学年第⼆学期《⼯业⼯程程序设计基础》课程试题课程号: 1410029-0√ 考试√ A 卷√ 闭卷□考查□ B 卷□开卷(答题注意事项:1、试卷内容采⽤4号或⼩4号宋体,页⾯和页码已排好,⽆需调整;2、按学校规定的阅卷要求进⾏评分;3、流⽔阅卷时,阅卷教师签名签在试卷⾸页左上⽅得分统计表实得分数栏的下⽅;4、出题时,所有题⽬集中书写,学⽣答题时,除客观题直接填在试卷上外,主观题统⼀答在所附⽩纸上。

)⼀、填空题(每空1分,共15)1.在C++中,运⾏时多态性是通过使⽤继承和虚函数实现的。

2.⽤来派⽣新类的类称为基类,⽽派⽣出的新类称为它的⼦类或派⽣类 3.如果⼀个类⾄少有⼀个纯虚函数,就称这个类为抽象类。

4.模板定义中标识类型的参数必须⽤关键字 class 修饰。

5.构造函数是对象被创建时⾃动执⾏,对象消失时⾃动执⾏的成员函数为析构函数。

6.⼀个类的成员可分为数据成员和成员函数两类。

7.继承是对象的⼀个特点,继承可分为单⼀继承和多重继承。

8.将成员函数放在类外,所⽤的作⽤域运算符为∷。

9.类的访问权限有___ 、和三种。

⼆、单项选择题(每题1分,共20分)1.设变量m ,n ,a ,b ,c ,d 均为0,执⾏(m = a==b)||(n=c==d)后,m ,n 的值是 ____D___ A. 0,0 B. 0,1 C. 1,0 D. 1,12.C 语⾔提供的预处理功能包括条件编译,其基本形式为 # XXX 标识符程序段 1 # else程序段 2班级:姓名:学号:试题共页加⽩纸张密封线GDOU-B-11-302#endif这⾥XXX可以是___D_____。

A.define或 includeB.ifdef 或includeC. ifdef 或ifndef或 defineD.ifdef或 ifndef或 if3.若a为⼆维数组,它有m列,则a[i][j]在数组中的位置是____c___A. i*m+jB. j*m+iC. i*m+j-1D. i*m+j+14.以下叙述不正确的是—D———:A.⼀个C++序可由⼀个或多个函数组成B.⼀个C++序必须包含⼀个main函数C.C++的基本组成单位是函数D.在C++中,注释说明只能位于⼀条语句的后⾯5.若⽤数组名作为函数调⽤时的实参,则传递给形参的是 A 。

南京信息工程大学2010-2011(1)C语言和程序设计基础试卷-A

南京信息工程大学2010-2011(1)C语言和程序设计基础试卷-A

D)其之前最近的且尚未配对的 if 配对 x;则下面没有错误的是 。 B) switch((int)x%2.0) { case 0:a++;break; case 1:b++;break; default:a++;b++; } D) switch((int)(x)%2) { case 0.0:a++;break; case 1.0:b++;break; default:a++;b++; }
第 3 页 /共 9 页
printf("x=%d,y=%d\n",x,y); } 2.下面程序运行的结果是 。 #include<stdio.h> int main() { int n[2],i,j; for(i=0;i<2;i++) n[i]=0; for(i=0;i<2;i++) for(j=0;j<2;j++) n[j]=n[i]+1; printf("%d\n",n[1]); return 0; } 3.下面程序运行的结果是 #include<stdio.h> int f(int); int main() { int z; z=f(5); printf("%d\n",z); return 0; } int f(int x) { if(x==0||x==1) return 1; else return x*f(x-1); } 4.以下程序执行后输出的第一个数是 #include <stdio.h> void increment (void); int main(void) { increment ( ); increment ( ); increment ( ); return 0; } void increment (void) { static int x=1;

java程序设计试卷A

java程序设计试卷A

java程序设计试卷A一、选择题(每小题2分,共30分)1、在创建某类的对象时应该()A、先声明对象,然后才能使用对象B、先声明对象,为对象分配内存空间,然后才能使用对象C、先声明对象,为对象分配内存空间,对对象初始化,然后才能使用对象D、以上述说法都对2、以下说法中对Java中定义的父类与子类的关系描述正确是的()A、一个子类可以有多个父类,一个父类也可以有多个子类B、一个子类可以有多个父类,但一个父类只可以有一个子类C、一个子类可以有一个父类,但一个父类可以有多个子类D、上述说法都不对3、给定如下Java 程序片断:class A{ public A(){ System.out.println("pido"); }}class B extends A{ public B(){ System.out.println(" online"); }public static void main(String[] args){ B b=new B(); }}上述程序将()A、不能通过编译B、通过编译,输出为: pido onlineC、通过编译,输出为: onlineD、通过编译,输出为: pido4、给定以下程序段,如下:int i=0,j=-1;switch(i){ case 0:j=1; case 2:j=2; default:j=5; }System.out.print("j="+j); 编译运行,正确的是()A、j=-1B、j=1C、j=2D、j=55、下面关于Java构造函数的描述正确的是()A、类必须有显式定义构造函数B、它的返回类型是voidC、它和类有相同的名称,但它不能带任何参数D、以上描述都是错误的6、在Java编程中,用来执行Java类文件的命令是()A、javacB、javaC、appletviewerD、以上都不对7、如下程序片段,体现了Java的()概念public void aMethod(String s) {........}public void aMethod(int i) {........}public void aMethod(int I,float f) {........}A、多继承B、重载C、重写D、多态8、如下Java升序片段Integer a = new Integer(3); Integer b = new Integer(3); System.out.println(a==b);运行后,该程序段的输出结果是()A、trueB、falseC、0D、19、分析下面的Java程序段:class testException{public static void main(String args[]) { int n[]={0,1,2,3,4}; int sum=0;try{ for(int i=1;i<5;i++) sum=sum+n[i]; System.out.println("sum="+sum);}catch(ArrayIndexOutOfBoundsException e) { System.out.println("数组越界"); } finally{ System.out.println("程序结束"); }}}输出结果将是()A、10 数组越界程序结束B、10 程序结束C、数组越界程序结束D、程序结束10、有如下Java程序声明String s1=new String(“pido”);String s2=new String(“online”);String s3=new String("0"); 以下选项中能够通过编译的是()A、s3=s1+s2B、s3=s1&s2C、s3=s1||s2D、s3=s1&&s211、从下面的布局管理器中选择按行放置控件、从左到右、从上到下,当一行装满时开始新的一行的布局管理器()A、CardLayoutB、FlowLayoutC、BorderLayoutD、GridLayout12、选择正确生成text field的代码,此text field最多能够显示10个字符(假定其字体有固定大小)并最初显示“pido”串()A、new TextField("pido", 10) ;B、new TextField(10,"pido");C、new TextField("pido",max,10);D、new TextField("pido",10,max);13、在子类构造方法内可以对超类的构造方法(super())进行调用的位置是()A、子类构造方法的任何地方B、子类构造方法的第一条语句处C、子类构造方法的最后一条语句处D、不能对超类的构造方法进行调用14、传递4,0来运行下列代码中的方法divide(int a, int b)public void divide(int a, int b){ try { int c = a / b; }catch (Exception e) { System.out.print("Exception "); }finally { System.out.println("Finally"); }}程序的输出结果是()A、打印输出: Exception FinallyB、打印输出: FinallyC、打印输出: ExceptionD、没有任何输出15、在单一文件中import、class和package的正确出现顺序是()A、package, import, classB、class, import, packageC、import, package, classD、package, class, import二、填空题(每空2分,共30分)16、Java中用于明确抛出一个异常的关键字是__________;17、设x=2.5,a=7,y=4,则表达式x+a%3*(int)7的值为__________;18、面向对象程序设计的三大特性为__________、继承性、__________;19、int a[]={1,2},b=2,i=0;则a[i++]+=b;执行后:i=__________ ,a[i]= __________;20、如下程序段class A{ int var1=1; int var2;public static void main(String args[]){ int var3=3; A a=new A();System.out.println(a.var1+a.var2+var3);}}的运行结果是__________;21、程序段String s= "Jessica "; char c=s.charAt(6); 运行后c的值是__________;22、”mypido".equals(new Button("mypido"))的返回结果是__________(填true或false);23、在Java语言中,Panel默认的布局管理器是__________;24、程序段int i=1; int j=i++; if((i>++j)&&(i++==j)) i+=j; 运行后i的值是__________;25、如下Java程序段char c=’a’;switch (c){ case ’a’: System.out.println("pido");default: System.out.println(" online");}的运行结果是__________;26、Java的字符类型采用的是Unicode编码方案,每个字符的Unicode码占用__________b;27、有如下语句:public static PidoStr定义,则变量PidoStr是一个_________变量(填写全局或局部);28、如果一个抽象类中的所有方法都是抽象的,就可以用另一种方式________来定义;三、程序分析题(每小题5分,共20分)29、写出下列程序的运行结果。

Python程序设计期末考试试卷及答案

Python程序设计期末考试试卷及答案

《Python 程序设计基础》期末考试试卷(A )适用班级考试形式班级 姓名 学号一、选择题 (每题2分,共40分)1.下列选项中,不属于Python 的数据类型的是( ) A 、字符串 B 、数组 C 、列表 D 、字典 2.下列选项中,不符合python 变量命名的是()。

A 、01_testB 、test_01C 、pytestD 、_py_test_ 3.以下对字典的说法错误的是A 、字典可以为空B 、字典的键不能相同C 、字典的键不可变D 、字典的键的值不可变 4.以下说法错误的是A 、元组的长度可变B 、列表的长度可变C 、可以通过索引访问元组D 、可以通过索引访问列表 5.list 类型的内置方法pop( )的作用是A 、置顶指定元素B 、给元素排序C 、删除指定元素D 、插入指定元素 6.以下说法正确的是A 、python 属于低级语言B 、python 是面向过程的C 、python 属于解释性语言D 、python 是非开源的 7.在Python 语言中,数据的输入是通过( )来实现的。

A .input( )函数B .print( )函数C .output( )函数D .abs( )函数8.为了提高程序的可读性,可以在该语句后面添加注释语句,Python 程序中用作注释的标识符是( ) A .: B .# C ., D .!9.下列 Python 表达式的值为偶数的是( )A .12*3%5B .len (“Welcome”)C.int (3.9) D .abs (-8)10.可以被计算机直接执行的语言是( ) , Python 语言属于( )语言。

A .机器,高级 B .高级,汇编 C .高级,机器 D .汇编,高级11.在Python 中,不同的数据,需要定义不同的数据类型,可用方括号“[]”来定义的是( a ) A .列表 B .元组 C .集合 D .字典 12.有python 程序如下: S=input ( ) print (S * 3)运行后通过键盘输入6,则运算结果是( )题 号 一 二 三 四 总分 总分人 得 分阅卷人 得分A.666 B.SSS C.18 D.S*313.在编写python程序时缩进的作用是()。

C程序设计试卷A卷

C程序设计试卷A卷

杭州师范大学信息科学与工程学院2007-2008学年第1学期期末考试《C程序设计》试卷(A)班级:学号:姓名一、根据C程序设计的有关概念,判断以下表述的正确性。

对的在括号内填上(×)1.在C源程序中将语句“if(x==5) y++;”误写作“if(x=5) y++;”,将导致编译错误。

(√)2.设变量定义为 char s[]= ”hello”,则数组s 中有6个元素。

(×)3.若表达式sizeof(int)的值为2,则int类型数据可以表示的最大整数为 216-1。

(×)4.C的double类型数据可以精确表示任何实数。

(×)5.函数原型为“void sort(float a[],int n)”,调用该函数时,形参数组a被创建,实参数组各元素的值被复制到a数组各元素中。

(×)6.'B'和”B”在内存中的表示没有区别。

(×)7.a是一维数组名,数组元素a[1]还可以写作“*(a++)”。

(√)8.若文件打开方式为”w”而该文件已经存在,则文件中原有数据被清空。

(×)9.p为指向字符串的指针变量,*p表示所指的字符串。

(√)10.表达式(15>>2)&2 的值是2。

二、单项选择题(最佳选择)(共20分,每小题2分)1.C语言规定函数的返回值的类型是由( D )。

A.return语句的表达式所决定B.调用该函数时的主调函数返回值类型所决定C.调用该函数时系统临时决定D.在定义该函数时所指定的函数返回值类型所决定2.C语言在判断逻辑值时,以( C )作为逻辑“真”值。

A.true B.t 或 y C.非0值D.数值03.设有定义:char s[12]={”string”};则printf(”%d”,strlen(s));的输出是( A )。

A.6 B.7 C.11 D.124.设ch是char型变量,其值为’A’,则表达式:ch = (ch>=’A’ && ch<=’Z’)?(ch+32):ch 的值是( B )。

计算机科学与技术专业专接本入学考试(2009秋季)A卷1

计算机科学与技术专业专接本入学考试(2009秋季)A卷1

绝密★启用前2009年北京联合大学秋季高职升本科基础课、专业基础课考试考试科目程序设计基础(总分:100分考试时间:120分钟)注意事项:1. 试卷共8 页,用钢笔或圆珠笔直接将答案写在试卷上。

2. 答卷前将密封线内的项目填写清楚。

注意:本试卷共五道大题。

题号一二三四五总分题分30 10 10 20 30 100得分一、选择题(本大题共15个小题,每小题2分,共30分)得分评卷人1.以下关于C程序组成特点的叙述中错误的是( c )A)C程序的基本组成单位是函数B)C语言不允许在函数中定义函数C)C语言不允许在一行内写多条语句D)分号是C语句的组成部分2.以下不能用于描述算法的是( d )A)N-S图B)传统流程图C)自然语言D)E-R图3.以下不能作为用户标识符的是( c )A)_128 B)MAIN C)3D D)f2x4.设变量均已正确定义并赋值,以下错误的赋值语句是( b )A)++x; B)x+y=z; C)a=b=c; D)x=y+z;5.以下合法的字符常量是()A)’65’B)’\’C)’n’D)’\08’6.设有定义:int a=20,b=020;,则语句printf(“%d,%d“,a,b);的输出结果是()A)20,15 B)20,16 C)20,20 D)20,177.设有如下程序段:int a=2,b=1,c=3;if(a<b) c=a; a=b;b=c;执行上述程序段后,a、b、c中的值应该是()A)a=1,b=2,c=3 B)a=1,b=2,c=2 C)a=1,b=3,c=3D)a=2,b=1,c=38.以下选项中,与n=i++ 完全等价的表达式是()A)n=i,i=i+1B)n+=i+1 C)i=i+1,n=i D)n=++i9.有以下程序:main( ){ int i,sum;for(i=1; i<5;i++,i++) sum+=i;printf("%d\n",sum); }程序的输出结果是()A)随机值B)10 C)4 D)910.以下程序的功能是计算正整数123的各位数字之和:main( ){ int n=123,sum=0;while(n!=0){ sum=sum+n%10;n= ; }printf("sum=%d\n",sum);}程序的下划线处应填入的是()A)n%10 B)n%100 C)n/10D)n/10011.要求定义一个具有6个元素的int型一维数组,以下选项中错误的是( )A)int a[ ]={1,2,3,4,5,6}; B)int a[2*3]={0};C)#define N 3 D)#define N 6 int a[N+N]; int *a[N];12.有以下程序:main( ){ char str[20]=”String\0xy\n”;printf("%d\n",strlen(str));}程序的输出结果是()A)6 B)7 C)9 D)12 13.有以下函数:int fun(int x, int y){ return x>y ? y : x ; }此函数的功能是()A)返回x和y中较大的数B)总返回“假”C)返回x和y中较小的数D)总返回“真”14.有以下程序main( ){int x[3][3]={ {1,2,3},{11,12,13},{21,22,23} };int i;for(i=0 ; i<3; i++ ) printf("%d ", x[i][i]);}程序运行后的输出结果是( )A)1 11 21 B)2 12 22C)3 13 2 D)1 12 2315.以下叙述中错误的是()A)C语言的源程序文件是文本文件B)由C程序生成的数据文件是由记录组成的C)扩展名为.obj的C程序文件是二进制代码文件D)扩展名为.exe的C程序文件可以执行二、填空题(本大题共10个空,每空1分,共10分)1. C 程序从编写到运行主要经历的步骤包括:编辑、【1】 编译源代码 、【2】 连接目标程序 、运行。

南京信息工程大学2009-2010(1)C语言期末考试试卷A(后附答案)

南京信息工程大学2009-2010(1)C语言期末考试试卷A(后附答案)

南京信息工程大学试卷2009 - 2010 学年第 1学期程序设计基础/C语言程序设计课程试卷( A 卷) 本试卷共 9 页;考试时间 120分钟;任课教师;出卷时间 2010 年 1月学院专业2009 年级班学号姓名得分一、单项选择题 (每小题 1分,共 12分)1.一个C程序的执行是从A.本程序的main函数开始,到main函数结束B.本程序文件的第一个函数开始,到本程序文件的最后一个函数结束C.本程序的main函数开始,到本程序文件的最后一个函数结束D.本程序文件的第一个函数开始,到本程序main函数结束2.下面四个选项中,均是不合法的用户标识符的选项的是A. A p_o doB. float lao _AC. b-a while intD. _123 temp INT3.表达式18/4*sqrt(4.0)/8值的数据类型为A.floatB. charC.doubleD.不确定4.设有如下定义struct ss{ char name[10];int age;char sex;}std[3],*p=std;下面各输入语句中错误的是。

A.scanf("%d",&(*p).age); B.scanf("%s",&);C.scanf("%c",&std[0].sex); D.scanf("%c",&(p->sex));5.有如下定义:int a[3][4]={1,3,5,7,9,11,13,15,17,19,21,23},(*p)[4];下面表示正确的是A.p=a[0]; B.p=*a;C.p=&a[0][0]; D.p=a;6.能正确表示“当x的取值在[1,10]和[200,210]范围内为真,否则为假”的表达式是。

A.(x>=1) && (x<=10) && (x>=200) && (x<=210)B.(x>=1) | | (x<=10) | | (x>=200) | | (x<=210)C.(x>=1) && (x<=10) | | (x>=200) && (x<=210)D.(x>=1) | | (x<=10) && (x>=200) | | (x<=210)7.以下程序段的循环次数是。

《Python程序设计》试卷A与参考答案

《Python程序设计》试卷A与参考答案

《Python程序设计》期末试卷A一.单选题(每小题2分,共40分。

)1、表达式 3 // 5 的值为_______________。

A、0B、1C、0.6D、22、表达式int(str(34)) == 34的值为___________________。

A、TrueB、FalseC、1D、03、表达式 3<5>2 的值为_______________。

A、TrueB、FalseC、1D、04、表达式 3<<2 的值为_______________。

A、12B、6C、3D、95、list(map(str, [1, 2, 3]))的执行结果为_____________________。

A、('1','2','3')B、['1','2','3']C、(1,2,3)D、'1','2','3'6、语句x = 3==3, 5执行结束后,变量x的值为_____________。

A、(True,5)B、5C、TrueD、[True,5]7、Python语句list(range(1,10,3))执行结果为___________________。

A、[1,4,7]B、[1,4,7,10]C、[0,3,6,9]D、[3,6,9]8、切片操作list(range(7))[::2]执行结果为________________。

A、[0, 2, 4, 6]B、[1,3,5]C、[1,3,5,7]D、[2,4,6]9、表达式“[2] in [1, 2, 3, 4]”的值为________________。

A、TrueB、FalseC、1D、010、使用切片操作在列表对象x的开始处增加一个元素3的代码为_________。

A、x[0:0] = [3]B、x[0:0] = 3C、x[0:1] = [3]D、x[0:1] = 311、已知 x = {1:2},那么执行语句 x[2] = 3之后,x的值为________________。

c语言程序设计期末考试试卷(A)

c语言程序设计期末考试试卷(A)
A、7B、8 C、6 D、2
4、表达式18/4*sqrt(4.0)/8值的数据类型为。
A)、int B)、float C)、double D)、不确定
5、若有以下定义,则能使值为3的表达式是D。
Int k=7,X=12;
A、X%=(k%=5)B、X%=(k-k%5)
C、X%=k-k%5 D、(X%=k)-(k%=5)
t=((t=(a<b)?a:b)<c)? t:c;
s=a+b+c-u-t; a=u;
b=s; c=t; return s;
}
运行时输入: 5 –7 3,输出结果:
4、#include <stdio.h>
#include<stdlib.h>
#defineNEW(struct info *)malloc(sizeof(struct info))
三、程序阅读题(每题5分共30分)
1.#include <stdio.h>
void main( )
{ int k=0;
char c='A';
do {
switch (c++)
{ case 'A': k++; break;
case 'B': k--;
case 'C': k+=2; break;
case 'D': k=k%2; break;
B、aa是指针变量,它指向含有两个数组元素的字符型一维数组
C、aa数组的两个元素分别存放的是含有4个字符的一维字符数组的首地址
D、aa数组的两个元素中各自存放了字符'a'和'A'的地址

Java程序设计基础本部(A)

Java程序设计基础本部(A)

Java程序设计基础本部(A)湖南农业⼤学课程考核试卷课程名称(全称):Java 程序设计基础(双语)课程代码:20638B3考核时间:2010 年 11 ⽉5⽇试卷号: A 考核对象:信息⼯程07-1、信息⼯程07-21. Given the file FirstClass.java:1: import java.*;2: public c lass FirstClass{ }3: public interface Second{ } 4: abstract c lass SecondClass{ }What error w ill the compiler likely generate? ()A. Package java not found in import.B. None. The file will compile fine.C. Public interface Second must be defined in a file c alled “Sec ond.java ”.D. Public class FirstClass must be defined in a file called “FirstClass.java ”. 2. Which of the following class definitions are legal? ()A. private class A{ }B. final abstract class F{ }C. abstract class E;D. public class C{ } 3. Given the following code:1:public class Century implements Runnable { 2: public void run( ){3: for(int year=1990; year<2000; year++){ 4: try {Thread.sleep(1000);5: }catch(InterruptedException e){ } 6: }7: System.out.println(“Happy new millennium!”)} } 8:class CountUp{9: public static void main(String args[]){ 10: Century ourCentury = new Century( ); 11: //…… 12:}}You now wish to begin the thread from another class. Which is the proper code, placed in the class CountUp at line 11, to begin the thread ()I 、Choose one correct answer (Total 40 points ,each question 2 points )A. Thread t=new Thread(ourCentury);B. Thread t=new Thread(this);t.start( ); t.start( );C. Thread t=new Thread(ourCentury);D. Thread t=new Thread(this);ourCentury.start( ); ourCentury.run( );4. Assuming the array is declared as a class member, which of the following will declare an array and initialize it with five numbers? ()A. Array a=new Array(5);B. int [] array;C. int array[]=new int[5];D. int a []=new int(5);5. Examine the following code:1: class StringLiteral{2: public static void main(String[] args){3: String java= “Java”, va= “va”;4: System.out.print( java== “Java” );5: System.out.print( java==( “Ja”+va ) );6: System.out.print( java.equals( “Ja”+va ));7: } } ()A. true true trueB. true false trueC. true true falseD. false true true6. Complete the following sentence.finally clauses ().A. are executed only after a try block executes with no exceptionsB. are only executed if an exception is thrown but no matching catch clause is found.C. are always executed after try and catch blocks.D. are only executed if a catch clause is executed in the current method.7. Which of the following is not a benefit of encapsulation ? ( )A. Clarity of codeB. Code efficiencyC. The ability to add functionality later onD. Modification requires less coding changes8. What does a Java programmer have to do in order to release an object that is no longer needed?()A. Use the delete statement.B. Call the finalize( ) method for the object.C. Call System.gc( ).D. Nothing.9. Which of the following assignment is not correct? ()A. double f = 11.1;B. double d = 5.3E12;C. double d = 3.14159;D. float d = 3.14.10. Given the uncompleted code of a class:1: public class A{2: public void baz( ){3: System.out.println(“A”);}}4: public class B extends A{5: public static void main(String[] args){6: A a=new B( );7: a.baz( );}8: public void baz( ){9: System.out.println(“B”);}}What will happen when you compile and run this program? ()A. The program compiles, runs, and displays A in the standard output.B. The program compiles, runs, and displays B in the standard output.C. The program compiles, but throws a runtime exception.D. The program does not compile.11. Of the following objects, which can not have locks ?()A. Thread objectsB. Runnable ObjectsC. Primitive typesD. Object objects12. Given the following code:1:import java.io.*;2:public class Inventory{3:public static void main(String[] args) throws IOException{4:FileInputStream inFile= new FileInputStream(“surplus.dat”);5:DataInputStream inData= new DataInputStream( inFile );6:String s= inData.readUTF( );7:System.out.println( s );8:inData.close( ); }9:}Assume there is a file in the current directory called “ surplus.dat ” that contains a string of Unicode characters. What will happen if you attempt to compile and run this block of code?()A. The file will not compile.B. The file will compile, but the class will generate an error when run.C. The class will run and overwrite the file called “ surplus.dat ” and then it will overwrite alldata in the file.D. The class will run and read-in the first line of UTF characters as a string, then display it onthe screen.13. Assume you have an object that is used to contain two values: a and b. Which of the following methods in its class can prevent concurrent access problems? ()A. public int read(int a, int b){ return a+b; }public void set(int a, int b){ this.a=a; this.b=b;}B. public synchronized int read(int a, int b ){return a+b;}public synchronized void set(int a, int b){ this.a=a; this.b=b;}C. public int read(int a, int b){ synchronized(a){ return a+b; }}public void set(int a, int b){ synchronized(b){ this.a=a; this.b=b;}}D. public synchronized synchronized(this) int read(int a, int b ){return a+b;}public synchronized synchronized(this) void set(int a, int b){ this.a=a; this.b=b;}14. What is the default layout manager for a Panel container? ()A. FlowLayoutB. BorderLayoutC. GridLayoutD. CardLayout15. Which modifier is NOT legal in Java? ( )A. privateB. publicC. protectedD. protect16. Given the following code:import java.awt.event.*;import java.awt.*;class Test implements ...{// do something }Which listeners must be inserted in the place ... to enable the program to pick up ActionEvent and WindowEvent? ()A. ActionListenerB. WindowListenerC. ActionListener,WindowListenerD. ActionListener,ContainerListener17. What is the main task that java command in JDK does? ()A. Executes codeB. V erifies codeC. Loads codeD. Compiles code18. Given the follow ing command to run a correct c lass:java MyTest a b cWhich statement is true? ( )A. args[0] = MyTest a b cB. args[0] = MyTestC. args[0] = aD. arg s[1]= “b”19. Given the follow ing code:1: int I=0;2: outer:3: while( true ){4: I++;5: inner:6: for (int j=0; j<10; j++){7: I+=j;8: if ( j == 3)9: continue inner;10: break outer;}11: continue inner;}12: System.out.println ( “I is”+I );What w ill be the value of I when it is printed? ( )A. 1 ;B. 2;C. 3 ;D. 4 ;20. Which statement can be compiled correctly:( )A. import java.awt.*;package Mypackage;class Myc lass {}B. import java.awt.*;class MyClass{}package MyPackage;C. /*This is a comment */package MyPackage;import java.awt.*;class MyClass{}D. None1. Overidden methods may add exceptions from new hierarchies to the method ’s exceptionspec ification. () 2. It is impossible to change the contents of a String variable. () 3. Constructors must have the same name as the class itself.() 4. An abstract class can be instantiated using the new operator. ()5. A static method cannot be overridden.( )6. All c lasses share a single root, the Object c lass. ()7. When two or more methods in the same c lass have the same name, they are said to beoverloaded. () 8. FileInputStream c lass allow you to create a new file to disk. () 9.A File object encapsulates the properties of a file or a path, and also contain the methods forreading/writing data from/to a file.()10. A continue statement can only be used in a loop . () 1. Function: Let severs communicate with c lients. Please finish the follow ing code.(Case ....-.sensitive .........) Client code :try{Socket client = new Socket(host, 2004); }catch(IOException e){} Server code :try{ServerSocket server = new ServerSocket((1) );}catch(IOException e){} Socket socket = null; try{socket = (2) ; //waiting for communicating(3) ; //get inputstream}catch(IOException e){}finally{(4) ; //close socket }2.Finish the following code.( Case ....-.sensitive .........) import java.awt.Frame;II 、Dec ide correct or wrong (Total 20 points ,each question 2 points , “√”means right, “X ” means wrong )III 、Fill the following blanks (Total 20 points ,each blank 2 points )import java.awt.Button;import java.awt.event.ActionListener;import java.awt.event. ___(5)_______________ ; public class DemoFrame __(6)________ Frame{ public DemoFrame(){addButton("Hello world"); }private void addButton(final String text){ Button b=new Button(text);b.addActionListener( (7)__________ ); add(b); }public static void main(String [] args){(new DemoFrame()).show();} }class MyListener _(8)________ ActionListener { public void _(9)______ (ActionEvent e){ System.out.println("Button "+text+" pressed"); } };3. Which method is used to signal the thread waiting on an object that they may continue? (10)________ is used to signal the thread waiting on an object that they may continue.1. Given the follow ing code: public c lass WaitTest{public static void main(String[] args){ System.out.print(“1 ”); synchronized(args){System.out.print(“2 ”); try{args.wait(); }catch(InterruptedExc eption e){} }System.out.print(“3 ”); } }What is the result of trying to compile and run this program:IV 、Write the results after code is executed.(Total 10 points ,each question 5points )2. Given the following codeclass Bow l {Bow l(int marker) {System.out.println("Bow l(" + marker + ")");}}class Table {static Bow l b1 = new Bow l(1);Table() {System.out.println("Table()");}static Bow l b2 = new Bow l(2);}class Cupboard {Bow l b3 = new Bow l(3);static Bow l b4 = new Bow l(4);Cupboard() {System.out.println("Cupboard()");}static Bow l b5 = new Bow l(5);}public c lass StaticInitialization {public static void main(String[] args) {System.out.println("Creating new Cupboard() in main");}static Table t2 = new Table();static Cupboard t3 = new Cupboard();}Running the preceding code prints:V、programming(Total 20 points,no.1 8 points, no.2 12 points)1. Please write a Java applet program to draw an oval. The center of the oval is (80,100) and width 50, height 70.import java.awt.*;public class DrawCircle extends Canvas{public static void main(String[] args){new DrawCircle();}public DrawCircle(){setSize(50, 50);}public void paint(Graphics g){g.drawOval(80,100,50,70);}}2.Please write a java application program. Use “BufferedReader”class to read all data in file “hello.txt” and print them.湖南农业⼤学课程考核参考答案与评分标准课程名称(全称):Java程序设计基础(双语)课程代码:20638B3考核学期:2010—2011 年秋季试卷号:A考核对象:2007级信息⼯程专业课程负责⼈签名:⼀、选择题(本⼤题共40分,每⼩题2分)1-5 C D A C B6-10 C B D D B11-15 C D B A D16-20 C A D A C⼆、判断题(本⼤题共10分,每⼩题1分)1-5 ×√√×√6-10 √√××√三、填空题(本⼤题共20分,每⼩题2分)1.2004 2. server.accept( ) 3.socket.getInputStream( ) 4. socket.close( ) 5.ActionEvent或者* 6. extends7. new MyListener 8. implements 9. actionperformed10. notify( )或者notifyAll( )四、程序阅读(本⼤题共10分,每⼩题5分)1. 1 22. Bowl(1)Bowl(2)Table( )Bowl(4)Bowl(5)Bowl(3)Cupboard( )Creating new cupboard( ) in main五、程序设计(本⼤题共20分,第⼀题8分,第⼆题12分)1.import java.awt.*; 或者import javax.swing.*; (1分)import java.applet.Applet; (1分)public class Circle extends Applet { (1分)public void paint(Graphics g){ (1分)g.drawOval(55,65,50,70); (4分)}}}2.import java.io.*; (1分)class Test{ (使⽤了异常处理2分)public static void main(String args[]) throws IOException{ String str;FileReader fr=new FileReader("hello.txt"); (创建输⼊流对象2分)BufferedReader bfr=new BufferedReader(fr); (创建缓冲流2分)while((str=bfr.readLine())!=null){ System.out.println(str); (读取⽂件信息并输出4分)}fr.close(); (关闭流1分)}}。

2009-20010学年第2学期《C语言程序设计基础》考试题(A)

2009-20010学年第2学期《C语言程序设计基础》考试题(A)

2009-20010学年第2学期期末考试试题(A)卷课程名称《程序设计基础(C语言)》任课教师签名集体出题教师签名姬涛审题教师签名吕涛考试方式(闭)卷适用专业本部非计算机本科考试时间(120 )分钟一、单项选择题(每题1分共30分)请将单项选择题答案填在下面表格中:A) 2x33 B) _2X C) x.y D) #x22.下列浮点数的表示中不正确的是▁▁▁A) 107. B) 12E5 C) e5 D) 12e53.下列不正确的转义字符是▁▁▁A)'\\' B)‘\"’ C) '\n' D) '\091'4.下列运算符中优先级最低的是。

A) 算术运算符 B)关系运算符 C)赋值运算符 D)逗号运算符5.若有以下定义和语句,则输出结果是▁▁▁int u=010,v=0x10,w=10;printf(“%d,%d,%d\n”,u,v,w);A)8,16,10 B)10,10,10 C)8,8,10 D)8,10,10 6单精度数x=2.0,y=3.0,下列表达式中y的值为7.0的是▁▁▁▁▁A) y/=x*27/4 B) y+=x+2.0C) y-=x+8.0 D) y*=x-3.07.有整型变量x,双精度变量y=3.5,表达式:x=(double)(y*3+((int)y%4))执行后,x的值为▁▁▁A) 11 B) 11.5 C) 13 D) 13.58. 设有int a=3; 则表达式(a++ * 1/2) 的值是▁▁▁▁▁▁A)1 B)1.0 C)1.5 D)29. 下面程序的输出是。

#include <stdio.h>void main( ){ int x=0,y=1,z;z=(x++<=0)&&(!(y--<=0));printf("%d %d %d\n", x,y,z);}A) 0 0 1 B) 0 1 1C) 1 0 1 D) 1 1 110. 已知小写字母a的ASCII码为97,大写字母A的ASCII码为65,若有以下定义和语句则输出结果是char c1='b',c2='d';printf("%d,%c\n",c2-c1,c2-'a'+’A’);A)2,d B)2,DC)3,D D)输出结果不确定11.若从键盘上输入3,则程序的输出结果是。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

《程序设计基础》试卷(A 卷)
注意:1、考试时间: 90 分钟; 2、班级、姓名、学号必须写在指定地方; 3、适用班级: 4、考试方式:
一、填空题 (每空 2 分,共 20 分)
1、C 程序是由函数构成的,其中有且只能有 1 个主函数,每个C 程序总是从它开始执行,并且以 ; 作为结束符。

2、C 语言中三大基本结构有:顺序结构、 选择结构 、 循环结构 。

3、‘A ’+3的结果是 68 。

4、若已定义x 和y 为double 类型,则表达式x=1,y=x+3/2 的值是 2.5 。

5、C 语言中逻辑运算符 ! 的优先级高于算术运算符。

6、符号“a”和‘a’的区别是 “a ”2字节 ‘a ’1字节 。

7、C 语言的预处理语句以____#_____开头。

8、有如下输入语句:scanf(“a=%d,b=%d ,c=%d”,&a ,&b ,&c );为使变量a 的值为1,b 的值为3,c 的值为2,从键盘输入数据的正确形式应是 a=1,b=3,c=2 。

二、选择题 (每小题 3 分,共 30 分)
1、下列叙述中错误的是( D )。

A 、 if 语句允许用户选择是否执行某个操作。

B 、 if else 语句允许用户选择执行两个操作中的某个操作。

C 、 switch 语句允许用户选择执行多个操作中的某个操作
D 、 多分支选择结构只能使用switch 语句实现 2、以下不正确的C 语言标识符是( D )
A 、ABC
B 、abc
C 、a_bc
D 、ab.c
3、按照C 语言规定的用户标识符命名规则,不能出现在标识符中的是( B )。

A 、大写字母 B 、连接符 C 、数字字符 D 、下划线
4、将int 型变量n 转换成float 型变量的方法是( B )。

A 、float n
B 、(float)n
C 、float(n)
D 、(int )n
5、( A )是构成C 语言的基本单位。

A 、函数
B 、子函数
C 、过程
D 、子过程 6、下面关于运算符优先顺序的描述中正确的是( B )。

A 、关系运算符< 算术运算符< 赋值运算符< 逻辑与运算符 B 、逻辑运算符< 关系运算符< 算术运算符< 赋值运算符 C 、赋值运算符< 逻辑与运算符< 关系运算符< 算术运算符 D 、算术运算符< 关系运算符< 赋值运算符< 逻辑与运算符 7、在C 语言中,要求参加运算的数必须是整数的运算符是( C )。

A 、/ B 、! C 、% D 、= = 8、char 型常量在内存中存放的是( B )。

A 、ASCII 代码值
B 、BCD 代码值
C 、内码值
D 、十进制代码值 9、以下程序的输出结果是( B ) Main() {
Int x=10,y=4; Printf(“%d\n ”,x/y);
}
A、1
B、2
C、3
D、4
10、在C语言中,当while语句构成的循环的条件为( D )时,结束循环。

A、True
B、非0
C、1
D、0
三、判断题 (每小题 2 分,共 20 分)
(√)1、C的关键字都是小写的。

(√)2、在 C 程序中,APH 和aph 代表不同的变量。

(√)3、表达式0195 是一个八进制整数。

(×)4、A-=7等价于a=a-7。

(×)5、# define PI=3.14159
(√)6、do while语句常用在需要至少执行一次循环体的地方。

(√)7、int a=123456;
(×)8、C语言程序的基本单位是语句。

(√)9、假设所有变量均为整型,则表达式(a=2,b=5,b++,a+b)的值是8。

(×)10、程序执行总是从main开始,在程序的最后一个函数中结束。

四、程序分析题 (每小题 4 分,共 16 分) 1、下面程序运行后的输出结果是 a=3,b=1,c=1 。

(4分)
main()
{
int a=1,b=2,c=3;
if(a<c) a1 b2 c3
b=a;a1 b1 c3
a=c;a3 b1 c3
c=b;a3 b1 c1
printf("a=%d,b=%d,c=%d\n",a,b,c);
}
2、下面程序运行后的输出结果是 3 。

(4分)
main()
{ int a=1 ,b=2,sum;
sum=a+b;
printf(“sum=%d\n”,sum);
}
3、以下程序的输出结果是 4 (4分)
Main( )
{
int a=3,b=4,c;
If(a<b) c=b;a3 b4 c4
Else c=a;
Printf(“%d\n”,c);
}
4、下列程序段的输出结果是错误。

(4分)
main( )
{
int n=5;
If(n>2)
If(n<5)
Printf(“正确\n”);
Else
printf(“错误\n”);
}
五、编程题 (每小题 7 分,共 14 分)
1、编写一个求0到100之间奇数之和的程序。

(7分)
#include <stdio.h>
Void Main(){
Int sum=0;
For(int i=0;i<=100;i++)
{
If(i%2!=0){
Sum = sum + i;
}
}
Printf(“%d”,sum);
}
2、计算前N个自然数的积,其中数字N由用户输入。

(7分)void main()
{
int n,sum=1;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
sum = sum*i;
}
printf("%d",sum);
}。

相关文档
最新文档