欢迎来到天天文库
浏览记录
ID:44087409
大小:101.21 KB
页数:7页
时间:2019-10-18
《华师大面向对象技术与JAVA语言作业》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、作业一.选择题[1]JavaApplication中,以下哪个或哪些main()方法的声明是合法的?BA.publicstaticvoidmain()B.publicstaticvoidmain(String[]strs)C.publicstaticvoidmain(Stringargs)D.staticpublicintmain(String[]args)E.staticvoidmain(String[]args)F.均不正确[2]当编译和运行下列代码时会产生什么情况?C1.publicclassStrEq{2.privateStrEq(){3.St
2、rings=newString(”Bob”);4.Strings2=newString(nBobn);5.if(s==s2){6.System.out.println("Equal");7・}8.else{9.System.ou匸println(”Notequal");10.}11・}12.publicstaticvoidmain(Stringargs[]){13.StrEqs=newStrEqO;14.}15.}A.程序能通过编译并输出”Equal”.B.程序能通过编译并输出nNotEqual"・C.程序在编译时出错。D.程序在运行时出错。[3]有以
3、下代码段:Atry{thrownewEOFException();}catch(IOExceptione){System.out.println(nIOExceptionCaught.11);}这里,EOFException是IOException的子类。假设这段代码是在某个类中,以下哪种说法是正确的?A.代码不能通过编译—B.代码能够运行并显示"IOExceptionCaught."C.throw语句将被忽略,因为没有相应的catch语句与它对应。D.因为throw语句与catch语句不匹配,程序终止。[4]当浏览器窗口被图标化后又重新恢复原大小时会
4、调用Applet的什么方法?(多选)BEB.start()C.stop()D.destory()E.paint()[5]下列哪些类允许你删除磁盘上的一个文件?(多选)ACA.FileB.FilelnputStreamC.FileOutputStreamD.FileReaderE.FileWriter[6]通常,URL由以下哪几个部分组成?(多选)CDEA.协议名B.SocketC.端口号D.主机名E.文件路径名F.页内参照二.编程题1.写一程序,它能接收命令行输入的2个整数,相加后将结果在屏幕上输岀。(注:输入的两个命令行参数分别对应args[0]和a
5、rgs[1],但为String类型,可用Integer类的parselnt方法来将它转换为整数后实现相加。例:Stringstrl;inti;strl=newString(T23”);i=Integer.parselnt(strl);)答:publicvoidadd(Stringa,Stringb){System.out.println("a+b二”+Integer.parselnt(.a)+1nteger.parselnt;2.写一程序,它能接收命令行输入的若干个整数,排序后按从小到大的次序在屏幕上输出。答:publicstaticvoidmain(
6、String[]args)throwsException{inttemp=0;for(intj=0;jn){temp=m;m=n;n=temp;}}for(intj=0;j7、定义如下:classEmployee{Stringname;〃雇员姓名intage;〃年龄chargrade;〃业绩评等,从高到低为A,B,C,D四等。classManagerextendsEmployee{Stringdepartment;//Manager所管辖部门Employeel]subm;〃下属庭员}请在包中定义一个名为TopManager的类,在该类中定义若干Employee和Manager的样本值,然后写一方法,找出所有Manager中其下属雇员平均业绩评等最高的Manager姓名。答:importjava.util.ArrayList;8、importjava.util.List;publicclassTopManager{Empl
7、定义如下:classEmployee{Stringname;〃雇员姓名intage;〃年龄chargrade;〃业绩评等,从高到低为A,B,C,D四等。classManagerextendsEmployee{Stringdepartment;//Manager所管辖部门Employeel]subm;〃下属庭员}请在包中定义一个名为TopManager的类,在该类中定义若干Employee和Manager的样本值,然后写一方法,找出所有Manager中其下属雇员平均业绩评等最高的Manager姓名。答:importjava.util.ArrayList;
8、importjava.util.List;publicclassTopManager{Empl
此文档下载收益归作者所有