已阅读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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025-2026学年上学期合肥小学数学六年级期末典型卷3
- 浙江国企招聘2025宁波文旅会展集团有限公司招聘16人笔试历年参考题库附带答案详解
- 2025福建福州闽江之心有限责任公司招聘2人笔试历年参考题库附带答案详解
- 2025年福建晋江市坊源生态科技有限公司招聘37人笔试历年参考题库附带答案详解
- 基于人工智能的重症肌无力术后免疫抑制方案预测模型
- 2025四川省煤炭产业集团有限责任公司招聘5人笔试历年参考题库附带答案详解
- 2025内蒙古蒙联石油化工有限公司招聘10人笔试历年参考题库附带答案详解
- 2025中国空空导弹研究院校园招聘笔试历年参考题库附带答案详解
- 2025重庆九洲智造科技有限公司招聘变更工程师等拟录用人员笔试历年参考题库附带答案详解
- 医院管理人才培训方案
- 美团外卖的现状及发展
- 消控设施培训课件
- 学堂在线 工程伦理2.0 章节测试答案
- 2024体彩考试题目及答案大全
- 校园智能零售合作计划:自动售货机服务方案探索
- 综治中心规范化建设授课
- 群众体育管理的概述
- 专题4战略性矿产资源与我国的能源安全(课件)-2024年高考地理一轮复习辑
- 2025年陕西建筑安全员A证考试题库及答案
- 中国建筑企业在海外的法律风险防范
- 体育社会组织发展-深度研究
评论
0/150
提交评论