




已阅读5页,还剩3页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
专业 班级 学号 姓名 温馨提示:端正考风、严肃考纪、诚信参加考试 凡是代考、使用通讯设备作弊、二次作弊,一经发现开除学籍。东华理工大学2012 2013 学年第 1 学期考试试卷 JAVA程序设计 课程 闭卷 课程类别:考查 补考题号一二三四五六七八九总分分数评卷人1 选择题(共35分)1.Choose the invalid identifiers from those listed below. ( ) A. IDoLikeTheLongNameClass B. $byte C. true D. _ok 2. How can you force garbage collection of an object? ( )A. Garbage collection cannot be forced B. Call System.gc(). C. Call System.gc(), passing in a reference to the object to be garbage collected. D. Call Runtime.gc(). E. Set all references to the object to new values(null, for example). 3 Consider the following class: 1. class Test(int i) 2. void test(int i) 3. System.out.println(“I am an int.”); 4. 5. void test(String s) 6. System.out.println(“I am a string.”); 7. 8. 9. public static void main(String args) 10. Test t=new Test(); 11. char ch=“y”; 12. t.test(ch); 13. 14. Which of the statements below is true?( .) A. Line 5 will not compile, because void methods cannot be overridden. B. Line 12 will not compile, because there is no version of test() that rakes a char argument. C. The code will compile but will throw an exception at line 12. D. The code will compile and produce the following output: I am an int. 4. Which of the following lines of code will compile without error? ( ) A. int i=0; if (i) System.out.println(“Hi”); B. boolean b=0; boolean b2=true; if(b=b2) System.out.println(“So true”); C. int i=1; int j=2; if(i=1| j=2) System.out.println(“OK”); D. int i=1; int j=2; if (i=1 &| j=2) System.out.println(“OK”); 5. Which two demonstrate a has a relationship? ( ) A. public interface Person public class Employee extends Person B. public interface Shape public interface Rectandle extends Shape C. public interface Colorable public class Shape implements Colorable D. public class Species public class Animalprivate Species species; 6 True or False: Readers have methods that can read and return floats and doubles. ( ) A. Ture B. False C no answer7 What is result ( ) class Test public static void main(String args) int a=2; System.out.println(a+);A 2 B 3 C 1 D 48 What is result ( ) class Test public static void main(String args) int a=2,b=3; System.out.println(a+b+);A 2 B 3 C 5 D 49 which platform is not belonging to Java developing platform ( )A j2ee B j2me C j2se D jsp10 what expression is incorrect( )A .class file is byte codeB .class file is based on JVMC .class file is run by real CPUD .class file is produced by javac11 what statement is valid ( )A extend is used as implementing hierarchy between both classesB extends is used as implementing hierarchy between both interfaceC implement is used between interface and classD implements is used as implementing hierarchy between both interface12 Which statement is invalid ( )A int a5; B int a =1,2,4 C int a=new int313 Which sentence is right( ) A abstract final class A B abstract private class A C abstract protected class A D abstract class A14 How to compile a Java source code ( ) A javac a.java B java a.java C javac a D javac a.class 15 Set x=1,y=2,z=3, expression y-=z-%+x; what is result ( ) A 1 B 3.5 C 4 D 5二 翻译题20分,每小题5分1)Inheritance is a relatively simple concept, which allows one class to extend another, or to inherit characteristics. When a class is extended a hierarchy is built up with the original class at the top and the classes, which build on the class above it (the class at the top is known as the super-class below). When a class is extended, to create a sub-class, all of the properties (variables and methods) of the original class still exist within the new class along with others, which have been added.2)Polymorphism is the ability of objects to react differently when presented with different information, known as parameters. In a functional programming language the only way to complete two different tasks is to have two functions with different names. Object-oriented languages, which include Java, allow different methods to be run depending on what type of parameters is specified. 3)A Java application resembles programs in most compiled languages. Code in object format resides on the users machine and is executed by a run-time interpreter that normally has to be user installed.4)Keywords cannot be used for anything but their predefined purpose. There are 49 in all, These words each have a special meaning to the Java compiler. A keyword must be separated from other keywords or identifiers by white space, a comment or some other punctation symbol.三 程序阅读题(每题4分,共计20分):The result of following program is:_public class Class1public static void main(String args)int n=6,sum=0;for(int k=1;k=n;k+)if (n%k=0)sum+=k;System.out.println(sum);The result of following program is: _public class Person String name;int age;public Person(String name, int age) = name;this.age = age;public static void main(String args) Person c = new Person(Peter, 17);System.out.println( + is + c.age + years old!);The result of following program is: _public class OverLoadingOrderstatic void print(String s,int i)System.out.println(String: +s+ ,int: +i);static void print(int i,String s)System.out.println(int: +i+, String: +s);public static void main(String arg)print(String first,11);print(99,Int first);The result of following program is: _class MammalClassString name,eyeColor;int age;public MammalClass()name=TheName;eyeColor=Black;age=0;class DogClass extends MammalClassboolean hasTail;public DogClass()name=Chase;eyeColor=Black;age=2;hasTail=true;class ManClass extends MammalClassboolean isMarried;public ManClass()name=Casey;eyeColor=Blue;age=1;isMarried=true;public class L05_07_inheritanceDemopublic static void main(String args)DogClass dog1=new DogClass();ManClass
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 委托内部审计服务合同
- 安全日培训学习课件
- 一号车库租赁合同3篇
- 瑞安注册安全工程师培训课件
- 东莞工程打井方案报价(3篇)
- 店铺改造提升工程方案(3篇)
- 球车安全培训课件
- 乐山鑫金兰农牧科技有限公司年存栏200万羽蛋鸡项目环评报告
- 猫郑振泽课件
- 猫狗体外驱虫知识培训课件
- 医院培训课件:《胰岛素规范化注射》
- 木材加工质量控制与验收考核试卷
- 《布病防控知识》课件
- 低空经济产业标准体系规划研究
- 保育员应掌握的工作技能(完整版)
- 贵州省遵义市(2024年-2025年小学六年级语文)部编版小升初模拟((上下)学期)试卷及答案
- 路灯安装工程项目实施的重点、难点和解决方案
- 2024年中国蚕桑产业发展现状及促进蚕桑产业发展的措施分析
- 《初级会计实务》(第五版) 第三章 流动资产
- ps课件教学课件
- 人教版六年级上册道德与法治第一单元测试卷及答案
评论
0/150
提交评论