新疆大学《JAVA程序设计》2019-2020学年期末考试试卷_第1页
新疆大学《JAVA程序设计》2019-2020学年期末考试试卷_第2页
新疆大学《JAVA程序设计》2019-2020学年期末考试试卷_第3页
新疆大学《JAVA程序设计》2019-2020学年期末考试试卷_第4页
新疆大学《JAVA程序设计》2019-2020学年期末考试试卷_第5页
已阅读5页,还剩4页未读 继续免费阅读

付费下载

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

《JAVA语言设计》试卷B《JAVA语言设计》试卷B一二三四五六A.$millionB.$_milliC.2$_millionD.$2B.若用于比较的数据类型为double型,则不可以用装订线6、下面是有关子类继承父类构造函数的描述,其中正确的是B.子类无条件地继承父类不含参数的构A.大小B.颜色C.名称D.D.类外调用该方法的方式必须是:对象名.方法名(答A表示说法正确.答B表示说法不正确,本题只需指答A表示说法正确.答B表示说法不正确,本题只需指17、使用Thread子类创建线程的优点是可以在子类中增加新的成员变20、对数据库操作时,使用PreparedStatement执行SQL语句,比起21、把编写好的Java源文件保存起来,源文件的装订线classA{A(){System.out.println(“A”);doublef(doublex,doubley){}ClassBextendsA{B(){System.out.println(“B”);doublef(doublex,doubley){}publicclassTest{}returnx*y;}}returnx+y;}publicstaticvoidmain(Stringargs[]){Aobj=newB();System.out.println("Theprogramoutputis"+obj.f(4,6));}}Connectionconn=DBTool.getConnection();try{Stringsql="selectcount(*)frommanagerwhereusername=?andpassword=?";PreparedStatementpst=conn.prepareStatement(sql);pst.setString(1,userName);pst.setString(2,password);ResultSetrs=pst.executeQuery();intcount=0;if(rs.next()){count=rs.getInt(1);}}catch(SQLExceptione){e.printStackTrace();}finally{conn.close();}TreeSet<Integer>set=newTreeSet<Integer>();set.add(2);set.add(5);set.TreeSet<Integer>set=newTreeSet<Integer>();set.add(2);set.add(5);set.add(3);set.add(8);try{ObjectOutputStreambr=newObjectOutputStream(newFileOutputStream("a.txt"));br.writeObject(set);br.close();ObjectInputStreambi=newObjectInputStream(newFileInputStream("a.txt"));TreeSet<Integer>s=(TreeSet)bi.readObject();Iterator<Integer>it=s.iterator();while(it.hasNext()){System.out.println(it.next());}bi.close();}catch(IOExceptione){System.out.println(e.getMessage());}publicclassTestException{publicvoidCreateException()throwsException{thrownewException("newexception");}publicstaticvoidmain(String[]args){TestExceptionte=newTestException();try{System.out.println("trycalledstart");te.CreateException();System.out.println("trycalledend");}catch(Exceptionex){System.out.println("catchcalled");System.out.println(ex.getMessage());}finally{System.out.println("finallycalled");}System.out.print("main()finished");}装订线}34.、publicvoidrun(){DatagramPacketpack=null;DatagramSocketmail_data=null;bytedata[]=newbyte[8192];try{pack=newDatagramPacket(data,data.length);mail_data=newDatagramSocket(888);while(true){mail_data.receive(pack);Stringmessage=newString(pack.getData(),0,pack.getLength());System.out.println("收到数据是:"+message+"\n");}}catch(Exceptione){System.out.println(e.getMessage());}}启动源代码如下:privateStringbland;privateStringtype;publicabstractvoidstart();public【②】(Stringbland,Stringtype){this.bland=bland;this.type=type;}publicStringtoString(){return"品牌:"+bland+";型号:"+type;}}publicclassBMW【③】Car{publicBMW(Stringbland,Stringtype){【④】(bland,type);publicBMW(Stringbland,Stringtype){【④】(bland,type);}publicvoidstart(){System.out.println("启动");}publicstaticvoidmain(Stringargs[]){Carcar=new【⑤】("宝马","X5");System.out.println(car.toString());car.start();}}序,在⑥~⑩处补充相应的内容,使整个程序能够正publicclassJ_Test{privateJFramef;privateJButtonbutton1,button2,button3;publicvoidgo(){f=【⑥】JFrame("Test");f.setLayout(newFlowLayout());button1=newJButton("Ok");button2=newJButton("Open");button3=newJButton("Close");f.add(button1);f.add(button2);f.add(button3);f.setSize(160,106);f.setVisible(【⑧】);}publicstaticvoidmain(String[]args){J_Testt=newJ_Test();t.go();}}ClassMonitor【⑨】ActionListener{publicvoid【⑩】(ActionEvente){System.exit(0);}}①②③④

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论