已阅读5页,还剩6页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
2010复习提1 Java中对数据库查询结果集进行操作的对象是() (DA:Connection对象B:Statement对象C:DriverManager对象D:ResultSet对象2按运算符操作数的数目划分,运算符 ? :的类型是()AA:三目B:双目C:四目D:单目3 有关在Java中定义实例方法和类方法的叙述正确的是() (DA:前者有public修饰,后者没有public修饰B:前者没有public修饰,后者有public修饰C:前者有static修饰,后者没有static修饰D:前者没有static修饰,后者有static修饰4 Java代码g.drawLine(100,100,100,100)的功能是()BA:画一个圆B:画一条线段C:画一个点D:代码是错误的5有Java语句如下,则说法正确的是() C int a,b=new int3; (1分)A:此语句是错误的B:a.length的值为3C:b.length的值为3D:a.length和b.length的值都为36 以下程序代码的输出结果是()B System.out.println(100/8); (1分)A:12.5B:12C:4D:07 在Java语言中,一般不作为容器使用的是()A:JDialogB:JFrameC:JTextAreaD:JPanel8 在Java语言中,把按钮button的标题文字设置为“第一个按钮”的方法是() AA:button.SetText(第一个按钮)B:button.GetText(第一个按钮)C:button.SetLabel(第一个按钮)D:button.GetLabel(第一个按钮)9、在Java程序中声明一个数组,错误的是()CA:int a;B:int a;C:float a10;D:float a ;10、在Java程序中有定义:int x=new int45;则x.length和x3.length的值分别是() AA:4和5B:5和4C:4和3D:5和311 定义一个使用接口Java.lang.Runnable的类,必须要实现的方法是() (1分BA:start()B:run()C:init()D:paint()12、如果发生多个线程形成一个等待环,这样,所有线程都陷入相互等待的状态。这种循环等待现象称为() (1分)?A:互斥B:同步C:死锁D:临界13、下列关于线程的说法正确的是() (DA:一个线程被创建,它就立即开始运行B:使用start()方法可以使一个线程立即开始运行C:当一个线程因为抢先机制而停止运行时,它被放在可运行队列的前面D:一个正在运行的线程可能因为某些情况而进入阻塞状态14 在Java程序中有代码如下: System.out.println( (new StringTokenizer(I am a student,a).countTokens(); 则输出结果为() (1分) cA:I am a studentB:2C:3D:415、定义一个使用接口Java.lang.Runnable的类,必须要实现的方法是() BA:start()B:run()C:init()D:paint()16 在编写Java程序访问数据库的过程中,用来处理驱动程序的加载和建立新数据库连接的类是() (1分) AA:DriverManager类B:Statement类C:Connection类D:ResultSet类17、以下是创建File对象的代码,错误的是() (DA:File f1=new File(/mydir/myfile.txt);B:File f2=new File(/mydir,myfile.txt);C:File f3=new File(mydirmyfile.txt);D:File f4=new File(mydirmyfile.txt);18、在Java语言中执行如下语句后,i和j的值分别为() int i=10;int j=+i; (1分)A:11和11B:10和10C:10和11D:11和1019 、JAVA中为字符型输入/输出流提供的读字符的方法所使用的类是( )。CA、InputStream B、OutputStream C、FIleReader D、FileWriter20、以下程序代码的输出结果是()D int x=100; System.out.println(5.5+x%8); (1分)A:5.512B:5.512.5C:18D:5.5421、下列哪些字符串匹配模式”。boyw3”( )。A、boy111 B、boy!# C、boyweo D、boyboyboyboy22下列哪个关键可用来定义Java常量( )。A、 public B、static C、final D、void23、在Java程序中有代码如下: System.out.println( (new StringTokenizer(I am a student,a).countTokens(); 则输出结果为() (1分)CA:I am a studentB:2C:3D:424、为8位字节流数据提供读操作支持的类是() (1分)AA:FileInputStreamB:FileOutputStremC:FileReaderD:FileWriter25、下列有关抽象类及抽象方法的叙述错误的是() (1分)AA:使用final修饰的类是抽象类B:使用abstract修饰的方法是抽象方法C:抽象类必须被继承才能使用,抽象类不可能有实例D:抽象类可以没有抽象方法,但有抽象方法的类一定是抽象类26、设x=40 则执行y=(+x)+(x+)+1后,x,y的结果分别为( ) A、42,80 B、41,81 C、43,82 D、42,8327、在编写Java Application程序时,若需要使用到标准输入输出语句,必须在程序的开头写上( )语句。 A. import java.awt.* ; B. import java.applet.Applet ; C. import java.io.* ; D. import java.awt.Graphics ;28、有关Java语言的特点,哪种是错误的( )A、多态 B、可移植 C、多线程 D、手动垃圾回收29、J2SE是( )A、Java企业平台 B、Java标准平台 C、Java小型平台 D、Java小型平台第二版31、下列哪种操作不会跑出异常()AA:浮点数除以0得到InfinityB: i=0/0; C: 打开不存在的文件 D:a-1=100;32、于length()表述正确的是()CA: 数组有length()方法,String也有length()方法A: 数组有length()方法,String没有length()方法A: 数组没有length()方法,String有length()方法A: 数组没有length()方法,String也没有length()方法33、下列正确的句子是() (1分)DA:float 3.14;B:byte i=225;C:int k=33L;D:int p;34.在Java语言中执行如下语句后,i和j的值分别为()A int i=10;int j=+i; (1分)A:11和11B:10和10C:10和11D:11和1035、当使用FileInputStream类中的read()方法时,如果没有读入一个字节数据时,返回值为() BA:0B:-1C:trueD:false36、下列程序的输入结果是( )。StringBuffer buf1=new StringBuffer(20);buf1.append(student); System.out.println(buf1.length() + ,+ buf1.capacity();A20,20 B7,20 C0,20 D0,039、一个实现Runnabel接口的类必须要实现的方法是() (A:start()B:run()C:sleep()D:init()40、下列有关Java的叙述错误的是() (1分)DA:强类型语言B:与平台无关C:可以使用汉字变量名D:不检查数组下标越界41下列有关数组的叙述错误的是() (1分)DA:数组是将一组相同类型的数据顺序存储,组成一种复合数据类型B:在Java语言中,数组是一种引用类型,数组名如同对象名一样,是一种引用C:对于多维数组,从最高维开始,可以对每一维分配不等长的空间D:在Java语言中,数组元素可以互相赋值,而数组名不能直接赋值42.当线程A使用某个对象,而此对象又需要线程B修改后才能符合A线程的需要,这时线程A就要等待线程B完成修改工作,这种现象称为() (1分)A:线程的同步B:线程的互斥C:线程的调度43、StringBuffer类的字符对象的长度是()BA:固定长度 B:可变长度 C: 长度必须小于16个字符 D:长度必须大于16个字符44、对于catch子句的排列,下列正确的是()BA:父类在前,子类在后 B:父类在后,子类在前 C: 有继承关系的异常类不能在同一个try内 D:必须有Exception类的Catch捕捉二、阅读下列程序,写出程序运行结果。 1、class A int x,y; A(int xx,int yy)x=xx;y=yy; interface A3202int f3202(A a); interface B3202int g3202(); public class C3202 extends A implements A3202,B3202 A a=new A(x,y); C3202(int x,int y) super(x,y); this.x=x*x; this.y=y*y; public int f3202(A a)return x*a.x+x*a.y; public int g3202()return x*a.x+x*a.y; public static void main(String args) int x=10,y=20; A a=new C3202(x,y); C3202 c=new C3202(x,y); System.out.println(a.x+,+a.y); System.out.println(c.f3202(a); System.out.println(c.g3202(); 2、class A B obj; A() obj=new B(); obj.print(); System.out.println(AAA); class B public void print() System.out.println(BBB); public class Class3202 public static void main(String arg) A obj=new A();考答案:程序运行结果: BBB AAA3、写出下面程序的运行结果。 public class Class34ThreadTest public static void main(String args) Hello h=new Hello(); Thread t=new Thread(h); t.start(); class Hello implements Runnable int i; public void run() while(true) System.out.println(Hello+i+); if(i=5) break; )4、public class AAAAa public static void main(String arg) String str=.con/index.php; String regex=./; String s=str.split(regex); for(int i=0;is.length;i+) System.out.println(si); 5、public class BBBBBpublic static void main(String args)byte d=我是一个学生工大的sdfsd.getBytes();System.out.println(数组d的长度:+d.length);String s=new String(d,10,2);System.out.println(s);6、import java.io.*;public class CCCCC public static void main(String args ) File file=new File(hello.txt); char b=北京欢迎你.toCharArray(); try FileWriter out=new FileWriter(file);/writing out.write(b); out.write(你好中国); out.close(); FileReader in=new FileReader(file);/reading int n=0; while(n=in.read(b,0,2)!=-1) String str=new String(b,0,2); System.out.println(str); in.close(); catch(IOException e) System.out.println(e); System.out.println(b=+(new String(b); 7、写出下面程序的运行结果class Employee private int id; private byte sex; private String name; private String duty; private float salary; private int holidays;public Employee(int id,byte sex,String name,String duty, float salary,int holidays) this.id = id; this.sex = sex; = name; this.duty = duty; this.salary = salary; this.holidays = holidays; public String getDuty() return duty; public void setDuty(String duty) this.duty = duty; public int getHolidays() return holidays; public void setHolidays(int holidays) this.holidays = holidays; public int getId() return id; public void setId(int id) this.id = id; public String getName() return name; public void setName(String name) = name; public float getSalary() return salary; public void setSalary(float salary) this.salary = salary; public byte getSex() return sex; public void setSex(byte sex) this.sex = sex; /* * display(),无返回值,该方法能打印员工的姓名、性别以及职务 * param employeepublic void display(Employee employee) System.out.println(员工姓名为: + employee.getName(); if(employee.getSex()=1) System.out.println(员工性别为: 男 ); else if(employee.getSex()=2) System.out.println(员工性别为:女 ); System.out.println(员工职务为: + employee.getDuty(); /* * getDecMoney(int day) 返回值是int型。 * 如果请假天数=3,则扣款为30请假天数; * 如果请假天数超过3天,则扣款为50请假天数。 * param day * return */ public int getDecMoney(int day) int deduction = 0; /扣除的工资 if(day 4) deduction = 44*day; return deduction; public static void main(String args) /创建一个员工类的对象 Employee employee = new Employee(123456789,(byte) 1,的,生产帽子的(color),(float) 300.8,3); employee.display(employee); /调用display() int deduction = employee.getDecMoney(employee.getHolidays();/调用getDecMoney() System.out.println(该员工因请假扣除工资 + deduction + 元);8、class ancestorClass private int a=8; protected int b=15; void f( ) System.out.print(a*b); void g( )System.out.print(ancestorClass Function g has been called!); public class Test extends ancestorClass int c=5;public void f( )System.out.println(b/c);public void testfun( )System.out.println(son function testfun has been called!);public static void main(String args ) ancestorClass sc=new ancestorClass( ); sc.f( ); sc.g( ); sc=new Test( ); (Test)sc).testfun( );9、class Testfloat F;public double getF(float F )F+;return this.F;public static void main(String args )System.out.println(new Test( ).getF(10);10、class putOutData extends Thread public void run( ) for(int i=2;i=10;i+) System.out.print (i+ ); class Testpublic static void main(String args ) throws InterruptedException Thread th=new putOutData( ); th.start( );System.out.print(程序结束啦!);四、简答1、什么是上转型对象?2、什么叫接口回调?3、什么是正则表达式?写出与模式“A135683”匹配的几个字符串。4、程序、线程和进程的关系?5、线程有4种状态?6、FileInputStream流的read()方法和FileReader流的read()方法有何不同?它们的文件输出流分别对应哪个类?7、java的方法重写继承的方法的规则是什么?8、String 和StringBuffer的区别?9、子类继承方法时,可以降低方法的访问权限吗?五、程序设计题1、编写一个方法string3703,要求在一个字符串数组中找出长度最长的一个元素。其中字符串数组是方法的参数,最长的一个元素是方法的返回值。 (6分)参考答案:方法如下: String string3703(Stringa) String maxStr=a0; for(int i=1;ia.length;i+) if(maxStr.length()ai.length() maxStr=ai; return maxStr; 解析完整的程序如下: public class Class3703 static String string3703(Stringa) String maxStr=a0; for(int i=1;iai.length() maxStr=ai; return maxStr; public static void main(String args) String b=asdf,saffdfd,as; System.out.println(string3703(b); 输出结果为:as2、 应用程序,求整数文件intfile1.txt中各行整数的和,并把和存入到另一个文件intfile2.txt中。设整数文件中全是整数,整数序列被分成行,各行整数个数不等且用空格分隔。要求程序将文件中各行整数的和及乘积输出在另一个文件中。 (6分)infile1。Txt Infile2.txt1 2 3 4 10 241 2 3 6 65 6 11 30参考答案:程序如下: import java.io.*; import java.util.*; public class Class3803 public static void main(String args) RandomAccessFile in,out; try in=。 intfile1.txt,/使用Filereader+BufferedReader out=。intfile2.txt/使用FIleWriter +BufferedWriter 自己补充完整 String s; while(s=in.readLine()!=null) StringTokenizer token=new StringTokenizer(s); long s=1; while(token.hasMoreTokens() s*nteger.parseInt(token.nextToken(); out.write (sum); in.close();out.close(); catch(FileNotFoundException e) System.out.println(文件找不到!+e); catch(IOException e) System.out.println(文件读写错!+e); 3、 :例7-12 + P145页作业4a) import java.util.*;b)c) public class Exampled) e) public static void main(String args)f) g) Integer one=new Integer(1),h) two=new Integer(2),i) three=new Integer(3),j) four=new Integer(4),k) five=new Integer(5),l) six=new Integer(6);m) HashSet A=new HashSet(),n) B=new HashSet(),o) tempSet=new HashSet();p) A.add(one);A.add(two);A.add(three);A.add(four);q) B.add(one);B.add(two);B.add(five);B.add(six);r) tempSet=(HashSet)A.clon
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2023年辽阳辅警协警招聘考试真题含答案详解(达标题)
- 2024年宿迁辅警协警招聘考试真题及答案详解(基础+提升)
- 2023年荆州辅警协警招聘考试真题附答案详解(b卷)
- 2023年龙岩辅警招聘考试真题及1套完整答案详解
- 2023年衡阳辅警协警招聘考试真题含答案详解(模拟题)
- 2024年亳州辅警招聘考试题库附答案详解
- 2024年丽水辅警协警招聘考试真题含答案详解(巩固)
- 2023年省属虚拟辅警协警招聘考试真题含答案详解(满分必刷)
- 2023年锡林郭勒盟辅警招聘考试题库及一套参考答案详解
- 晋中师范高等专科学校《公共室内空间设计》2024-2025学年第一学期期末试卷
- 中国分布式调相机行业市场现状分析及竞争格局与投资发展研究报告2024-2029版
- 普通高中英语课程标准(2017年版-2020年修订)词汇表
- 灯光设计调试合同
- (正式版)HGT 5367.6-2024 轨道交通车辆用涂料 第6部分:耐高温电机涂料
- 中国特色大国外交和推动构建人类命运共同体
- 职业生涯规划书成长赛道
- MW农光互补光伏电站项目可行性研究报告
- 农业田间机器人课件
- 旅游政策与法规案例分析题
- 新版物业交割单
- 《汽车运用基础》考试复习题库及答案
评论
0/150
提交评论