JAVA6程序设计实践教程实验指导+课后答案.doc

上传人:文库蛋蛋多 文档编号:2385634 上传时间:2023-02-17 格式:DOC 页数:12 大小:64KB
返回 下载 相关 举报
JAVA6程序设计实践教程实验指导+课后答案.doc_第1页
第1页 / 共12页
JAVA6程序设计实践教程实验指导+课后答案.doc_第2页
第2页 / 共12页
JAVA6程序设计实践教程实验指导+课后答案.doc_第3页
第3页 / 共12页
JAVA6程序设计实践教程实验指导+课后答案.doc_第4页
第4页 / 共12页
JAVA6程序设计实践教程实验指导+课后答案.doc_第5页
第5页 / 共12页
点击查看更多>>
资源描述

《JAVA6程序设计实践教程实验指导+课后答案.doc》由会员分享,可在线阅读,更多相关《JAVA6程序设计实践教程实验指导+课后答案.doc(12页珍藏版)》请在三一办公上搜索。

1、第1章:1.6习题集:一、填空题1多态2java.exe 3jdb.exe 4标准字节码5Java 6独立于平台二、选择题1B2A3B4A5A6C7C8D9C第2章:实验指导:2.5.1第一处需要的代码:yourGuessrealNumber第二处需要的代码:yourGuess=input.nextInt();第三处需要的代码:yourGuessrealNumber第四处需要的代码:yourGuess=input.nextInt();2.5.2第一处需要的代码:iArrayi iArrayj第二处需要的代码:iTemp = iArrayi; iArrayi = iArrayj; iArrayj

2、 = iTemp;2.5.3第一处需要的代码:continue lable;第二处需要的代码:System.out.print( +(i+j);2.5.4第一处需要的代码:System.out.print(t);第二处需要的代码:System.out.print(j + * + i + = + (i*j) + t);2.6习题集:一、填空题1i=i+1 sum=sum+1 irealNumber第二处需要的代码:Hello h = new Hello(); h.print();4.5.2第一处需要的代码:public void stop() System.out.println(Network

3、 stop!);第二处需要的代码:public void start() System.out.println(Du du.); 第三处需要的代码:SoundCard sc=new SoundCard(); mb.usePCICard(sc);4.5.3第一处需要的代码:this.userAccount = acc; this.userPassword = pass;第二处需要的代码:public void show() System.out.println(resultMessage); 第三处需要的代码:user.connect();user.show();4.6习题集:一、填空题1jav

4、ac d . Test.java 2package 3public4package com.my.test; public void inPut()System.out.println(n hi,keybroad has be input into then mainbroad!n); public void inPut()System.out.println(n hi,netCardBroad has be input into then mainbroad!n); publicvoid getMainMessage(Extendbroadable ext)ext.inPut();5Cons

5、tants.MAX_COUNT6interface B extends Apublic void printB();二、选择题1C2D3B4C5B6C7C8B9D 10D 11D 12A三、简答(1) 1、接口是类似于类的结构,它只包含常量和抽象方法。在某些情况下,接口类似于抽象类,但是抽象类能够包含常量和抽象方法,还能够包含变量和具体方法。(2) 1、在接口中,数据可以是常量;而抽象类可以有数据字段。2、在接口中方法只有无实现的签名,而抽象类可以有具体的方法。3、因为定义在接口中的所有方法都是抽象方法,Java不要求将抽象修饰符放在4、接口中的方法签名中,但是在抽象类中要将抽象修饰符放在抽象

6、方法之前。(3) 1、可以更好的组织类。2、减少类名的冲突问题,同一包中的类名不能重复,不同包中的类名可以重复;3、对包中的类起了一定的保护作用;(4) 1、直接引用指定的类,如import java.util.Vector;2、引用一个包中的多个类,如import java.awt.*。更确切的说,它并不是引用java.awt中的所有类,而只引用定义为public的类,并且只引用被代码引用的类,所以这种引用方法并不会降低程序的性能;3、*号代替类名,在不能代替包名,如import java.awt.*,只引用java.awt下的类,而不引用java.awt下的包;4、import java.

7、awt.F*,这种使用方法是错误的;5、import语句在所有类定义之前,在package定义之后;6、import只告诉编译器及解释器哪里可以找到类、变量、方法的定义,而并没有将这些定义引入代码中;第5章实验指导:5.6.1第一处需要填写的代码:ist.length()第二处需要填写的代码:st.indexOf(you)5.6.2第一处需要填写的代码:int i=0;ia.length;i+;第二处需要填写的代码:ai=(char)(ait);5.6.3第一处需要填写的代码:nowTime第二处需要填写的代码:matter1.format(nowTime)5.6.4第一处需要填写的代码:in

8、t i=0;i=A&c=Zi+;10i=0;irealNumber第二处需要的代码:NumberFormatException ex 6.4.2第一处需要的代码:catch(IOException e)System.out.println(catch +e.toString(); 第二处需要的代码:catch(NumberFormatException e)System.out.println(catch +e.toString(); 6.5习题集:一、填空题:1Welcome to javaThe finally clause is executed2Welcome to javaThe f

9、inally clause is executed3catch(NumberFormatException e)4仍然执行5ArithmeticException6IOException7数据转换错误异常8statement1,statement2二、选择题 1C2B3C4D5C6B7C第7章实验指导:7.6.1第一处需要填写的代码:panel.setVisible(true);第二处需要填写的代码:group.add(radioButton1); group.add(radioButton2);第三处需要填写的代码:mainPanel.add(panel);7.6.2第一处需要填写的代码:c

10、ommentTabPane = new JTabbedPane();第二处需要填写的代码:tabAddComponent.add(nameLabel);第三处需要填写的代码:queryCom();7.6.3第一处需要填写的代码:System.exit(0);第二处需要填写的代码:new Counter(); 7.6.4第一处需要填写的代码:setVisible(true);第二处需要填写的代码:frame.getContentPane().add(new JTextArea();7.7习题集:一、填空题1btni=new JButton(strnamei); BorderLayout.EAST

11、、BorderLayout.WEST、BorderLayout.SOUTH、BorderLayout.NORTH、BorderLayout.CENTER2frame.setContentPane(new CalculatorPanel().createPane();int y = 0; y 4; y+、button = new JButton(lablesyx);3frame.getContentPane().add(new TreePanel().createComponent();node01.add(node0102); int i = 0; i names.length; i+、pan

12、el.add(new JLabel(namesi);4jframe.setVisible(true); Container contentpane=jframe.getContentPane();text.append(s);5Container contentPanel = frame.getContentPane(); frame.setVisible(true); add(part2(); panel.setVisible(true);6Panel pan=new Panel();二、选择题1D2A3B4B5A6D7C第8章实验指导:8.6.1第一处需要的代码:contentPane.a

13、ddMouseListener(this);contentPane.addMouseMotionListener(this);第二处需要的代码:g.drawLine(startx,starty,endx,endy);8.6.2第一处需要的代码:Container contentPane = f.getContentPane();第二处需要的代码:(e.getActionCommand().equals(按我有声音喔)8.6.3第一处需要的代码:treeModel.insertNodeInto(leafnode,node1,node1.getChildCount();第二处需要的代码:e.get

14、Source()=tree8.6.4第一处需要的代码:b0.addActionListener(new Bt();第二处需要的代码:x=Double.parseDouble(tf1.getText().trim();8.7习题集:一、填空题1程序符号2授权事件模型3actionPerformed(ActionEvent e),itemStateChanged(ItemEvent e)4事件适配器5new WindowAdapter(),System.exit(0);二、选择题 1D 2C 3D 4B 5A 第9章参考答案:实验指导:9.4.1第一处需要填写的代码:g_2d.setStroke(

15、bs);g_2d.setColor(Color.yellow);g_2d.draw(hourLine);第二处需要填写的代码:secondLine.setLine(120,120,(int)pointSXa,(int)pointSYa);9.4.2第一处需要填写的代码:signal.setRed(0);signal.setYellow(1);第二处需要填写的代码:g.setColor(Color.green);习题集:填空题:1Drawstring 2add(p1) 3toString(i)4public void paint(Graphics g)5int count=1;countxpoi

16、nt.length;count+6public void init()选择题:1A2B3B4B第10章实验指导:10.6.1第一处需要填写的代码:tempStr=bufReader.readLine();第二处需要填写的代码:s*=i;10.6.2第一处需要填写的代码:filePrex = null第二处需要填写的代码:int j = 0; j children.length; j+10.6.3第一处需要填写的代码:inStream,outStream第二处需要填写的代码:copyBut,0,copyLen10.6.4第一处需要填写的代码:tempStr=inObj.readLine();习题

17、集:一、填空题:1Hello!I like Java! 2110 110 110 110 1103InputStreamReaderBufferedReaderreadLine()4HelloWorld!5year%4=0&year%100!=0|year%400=06String s=information to Appendn mon!n;二、选择题:1D2A3A4B5D6B7B8D第11章参考答案:实验指导:11.6.1第一处需要填写的代码:Class.forName(DBDRIVER) ;conn = DriverManager.getConnection(DBURL,DBUSER,D

18、BPASSWORD) ;第二处需要填写的代码:conn = getConnection();stmt = conn.createStatement();第三处需要填写的代码:stmt.executeUpdate(insert into t_test values(ew,dgf,dfg);); stmt.executeUpdate(insert into t_test values(dg,df,fdg);); stmt.executeUpdate(insert into t_test values(dfg,dfg,dfg););stmt.executeUpdate(insert into t_t

19、est values(gdf,df,df););第四处需要填写的代码:stmt.executeUpdate(delete from t_test;);11.6.2第一处需要填写的代码:pstmt=conn.prepareStatement(insert into t_grade values(?,?,?););pstmt.setString(1,name);pstmt.setString(2,course);pstmt.setString(3,grade);pstmt.execute();第二处需要填写的代码:rs = stmt.executeQuery(select * from t_gra

20、de);while(rs.next()System.out.print(姓名:+rs.getString(name);System.out.print( 课程:+rs.getString(course);System.out.println( 成绩:+rs.getString(grade);第三处需要填写的代码:try conn.close(); stmt.close(); rs.close(); catch(SQLException e)e.printStackTrace();11.6.3第一处需要填写的代码:conn = getConnection(); stmt = conn.creat

21、eStatement(); stmt.executeUpdate(delete from t_grade where name = +name+);第二处需要填写的代码:pstmt = conn.prepareStatement(update t_grade set course = ?,grade=? where name = +name+); pstmt.setString(1,course); pstmt.setString(2,grade); pstmt.execute();11.7习题集:一、填空题:1建立与数据库的连接、处理结果集2executeUpdate3CallableSta

22、tement4conn.createStatement();、rs.next();5conn.createStatement(ResultSet.Type_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE):、rs.updateRow();二、选择题:1B2A3B4B5C6A7A8C以下是大学体验英语综合教程2(第三版)课后翻译答案Unit11. 任何年满18岁的人都有资格投票。(be eligible to, vote)Answer:Anyone over the age of 18 is eligible to vote.2. 每学期开学前,这些奖学金

23、的申请表格就会由学校发给每一个学生。(apply for, scholarship)Answer:A form to apply for these scholarships is sent by the university to every student before the start of every semester.3. 遵照医生的建议,我决定戒烟。(on the advice of)Answer:On the advice of my doctor, I decided to give up smoking.4. 公园位于县城的正中央。(be located in)Answer

24、:The park is located right in the center of town.5. 这所大学提供了我们所需的所有材料和设备。(facilities)Answer:The university provides all the materials and facilities we desire.1. 他们花了多年的时间寻找内心的平静,但是收效甚微。(search for)Answer:They spent many years searching for peace of mind, but with little success.2. 这种新药的成功研制已经使许多疾病的治

25、疗发生了根本性的变革。(revolutionize)Answer:The successful development of the new drug has revolutionized the treatment of many diseases.3. 由于这个国家的经济不景气,这家公司濒于破产。(on the edge of)Answer:The company is on the edge of bankruptcy due to the economic depression in the country.4. 大学毕业后他成为了一名护士。他认为护士这一职业可能很有发展前途。(rew

26、arding)Answer:He became a nurse after college. He thought nursing could be a very rewarding career.5. 他像往常一样在文件上签了名。(just as)Answer:He signed his name on the paper just as he has always done it.Unit21. 警察们正忙着填写关于这场事故的各种表格。(fill out)Answer:The policemen are busy fi lling out forms about the accident.

27、2. 我想在还车之前把油箱加满。(fill up, fuel tank)Answer:I want to fi ll up the fuel tank before returning the car.3. 如果你要投诉,最好遵循正确的程序。(follow the procedure)Answer:If you want to make a complaint, youd better follow the correct procedure.4. 要不是约翰帮忙,我们绝不会这么快就完成实验。(without)Answer:We couldnt have fi nished the exper

28、iment so soon without Johns help.5. 暴风雨之后,岸边的人们焦急地搜索湖面以期发现小船的踪迹。(scan for)Answer:After the storm, the people on the shore anxiously scanned the lake for any sign of the boat.1. 这个国家不大,但是在国际事务中它却发挥着重要作用。(play a role)Answer:This country is not big, but it plays an important role in international affai

29、rs.2. 正是在我叔叔的帮助下,我得以克服困难,按时完成了任务。(it is . that)Answer:It was with the help of my uncle that I overcame the difficulty and completed the assignment in time.3. 毕业时他决定留在北京,而他最好的朋友却选择了去西藏。(while)Answer:While he decided to stay in Beijing upon graduation, his best friend chose to go to Tibet.4. 在这次校园英语演讲

30、比赛中,我们班的玛丽获得了第三名。(come in)Answer:In this Campus English Speaking Contest, Mary from our class came in third.5. 你应该知道学习弹钢琴需要有时间,有金钱,还要有毅力。(as well as)Answer:You should know that it takes time, money as well as perseverance to learn to play the piano.Unit31. 我发现量入为出地过日子越来越难了。(increasingly)Answer:I fin

31、d it increasingly difficult to live within my income.2. 现代政治家们都试图以电视讲话来影响普通百姓。(reach out)Answer:Modern politicians try to reach out to ordinary people in their TV speeches.3. 应该帮助学生对人生采取积极的态度。(adopt)Answer:Pupils should be helped to adopt a positive attitude to life.4. 希望全班同学参加这些讨论。(participate in)A

32、nswer:Everyone in the class is expected to participate in these discussions.5. 如果你犯了罪就必须受到惩罚。(crime)Answer:If you commit a crime you must expect to be punished.1.儿子的死让老妇人变得麻木痴呆了。(numb)Answer:The old woman was numbed by her sons death.2.身处所有这些烦恼之中,他依然能保持乐观。(in the midst)Answer:In the midst of all tro

33、ubles, he managed to remain cheerful.3. 虽有困难,他们还是设法坚持试验下去。(carry on)Answer:They managed to carry on their experiments in spite of the difficulties.4.我们必须淘汰不合格的申请人。(weed out)Answer:We have to weed out unqualified applicants.5. 医生要他减少抽烟。(cut down on)Answer:The doctor told him to cut down on smoking.Un

34、it41.她在公共汽车站一直等到末班车进站。(come in)Answer:She waited at the bus stop until the last bus came in.2.如果我们能帮得上忙,尽管和我们联系。(contact)Answer:If there is any way we can be of assistance, please do not hesitate to contact us.3 .他需要多少船务人员才能使他的游艇航行?(crew, yacht)Answer:How many crew does he need to sail his yacht?4 .

35、虽然她的新书没有上一本好,但是我还是喜欢它。(not quite as)Answer:I enjoyed her new book though its not quite as good as her last one.5 .我从未遇到过如此善良的人。(never before)Answer:Never before have I met such a kind person.1.公共汽车放慢速度并停下,让那位乘客上车。(slow down)Answer:The bus slowed down and stopped to allow the passenger to get on boar

36、d.2.许多车子都驶过去了,可是没有一辆愿意让我们搭便车。(roll by)Answer:Many vehicles rolled by, but no one offered us a ride.3 .请勿践踏草地。(get off)Answer:Please get off the grass.4.他按妻子的吩咐,一下班就去了市场。(make ones way)Answer:He made his way to the marketplace right after work, as his wife had asked him to do.5 .值得庆幸的是,史蒂夫 (Steve) 从自

37、行车上摔下来时没有摔断骨头。(luckily)Answer:Luckily, Steve didnt break any bones when he fell off his bike.Unit51. 我们得把感情放在一边,从专业的角度来对待这件事。(from a professional standpoint)Answer:We have to put aside our emotions and take it from a professional standpoint.2. 这部戏非常精彩,我很快就沉浸于激动人心的剧情之中。(lose oneself in)Answer:The pla

38、y was so wonderful that I soon lost myself in the excitement of it.3 .她没有什么爱好除非你把看电视也算是一种爱好。(unless)Answer:She hasnt got any hobbies unless you call watching TV a hobby.4. 他说他是直接从市长本人那里得到这个信息的。(first-hand)Answer:He said that he had got the information first-hand from the Mayor himself.5 .既然你不能回答这个问题,我们最好问问别人。(since)Answer:Since you cant answer the question, perhaps wed better ask someone else.1. 由于公共汽

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 建筑/施工/环境 > 项目建议


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号