J2SE基础试题.doc_第1页
J2SE基础试题.doc_第2页
J2SE基础试题.doc_第3页
J2SE基础试题.doc_第4页
J2SE基础试题.doc_第5页
已阅读5页,还剩2页未读 继续免费阅读

下载本文档

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

文档简介

J2SE基础试题班级:姓名:时间:一、 选择题(没有注明多选,则为单选。每题2分,共20分)1. 以下哪个不是面向对象程序设计(OOP)的特点A. 封装B. 抽象C. 继承D. 多态2. 允许一个类的成员访问同一包中其它类的成员的最受限的修饰符为?A. publicB. protected C. abstractD. private3. 欲构造ArrayList类的一个实例,此类继承了List接口,下列哪个方法是正确的 ?A. ArrayList myList=new Object(); B. List myList=new ArrayList(); C. List myList=new List();D. ArrayList myList=new List(); 4. 如果int A = new int5; 则A1的值为A. nullB. 0C. 1D. 编译出错5所给代码如下:1) class Example2) String str;3) public Example()4) str= example;5) 6) public Example(String s)7) str=s;8) 9) 10) class Demo extends Example11) 12) public class Test13) public void f () 14) Example ex = new Example(Good);15) Demo d = new Demo(Good);16) 17)该代码会在那一行出错?A. line 3B. line 6C. line 10D. line 14E. line 156下面那种描述是正确的?A. 在Java中不允许多重继承,这样可以使程序更加可靠B. 子类继承父类的所有方法 (包括构造方法)C. 一个类可以实现很多接口.D. 当一个类实现一个接口,那么他就必须定义该接口中的所有方法。7. What will be the result of executing the following code? ( )public static void main(String args)char digit=a;for(int i=0; i10; i+)switch(digit)case x:int j=0;System.out.println(j);Default:int j=100;System.out.println(j);int i=j;System.out.println(i);A. 100 will be printed 11 times.B. 100 will be printed 10 times and then there will be a runtime exception.C. The code will not compile because the variable i cannot be declared twice within the main() method.D. The code will not compile because j cannot be resolved to a variable.E. None of these8. 下列的方法能够正常运行1. public void example() 2. try 3. unsafe();4. System.out.println(Test1); 5. 6. catch(SafeException e) 7. System.out.println(Test 2); 8. finallySystem.out.println(Test 3);9. System.out.println(Test 4); 10. 下列哪项不会输出A. Test1B. Test2C. Test3D. Test49. 指出下列哪个方法与方法public void add(int a)不是合理的重载方法。A. public int add(int a) B. public void add(long a) C. public void add(int a,int b) D. public void add(float a) 10. 给出以下定义1. public static void main(Stirng args)2. System.out.println(c+1+”a”);3. ; 程序输出结果为A. c1aB. 197C. c98D. 100a二、 看程序写结果题(每题4分,共20分)1. 程序如下: 1. class Test2. public static void main(String args)3. int i = 0;4. change(i);5. i = i+;6. System.out.println(“i=”+i);7. 8. public static void change(int i)9. i+;10. 11. 程序结果是 0 2. 程序如下: 1. class Test2. public static void main(String args)3. String str = “test”;4. char cList = a,b,c;5. change(str,cList);6. System.out.print(str);7. System.out.print(“ and ”);8. System.out.println(cList);9. 10. public static void change(String str,char cList)11. str = “ok”;12. cList0 = g;13. 14. 程序结果是 3. 程序如下: 1. class Test2. public static void main(String args)3. for(int i=0;i3;i+);4. 5. for(int j=0;j4;j+);6. System.out.print(“*”);7. System.out.println();8. 9. 10. 程序结果是 4. 程序如下: 1. class Test2. public static void main(String args)3. String strA = new String(“aaa”);4. String strB = new String(“aaa”);5. if(strA=strB)6. System.out.println(“equal”);7. else8. System.out.println(“not equal”);9. 10. 程序结果是 5. 程序如下: 1. package test; public class FatherClass 2. public FatherClass() 3. System.out.println(FatherClass Create); 4. 5. 6. package test; 7. import test.FatherClass;8. public class ChildClass extends FatherClass9. public ChildClass()10. System.out.println(ChildClass Create);11. 12. public static void main(String args) 13. FatherClass fc = new FatherClass();14. ChildClass cc = new ChildClass();15. 16. 程序结果是 三、 简答题(每题3分,共30分)1. 简单介绍面向对象的概念2. 简单介绍构造方法的特点及作用3. 请说明List和Set的区别?4. abstract class和interface有什么区别?5. 接口是否可继承接口,抽象类是否可实现(implements)接口,抽象类是否可继承具体类(concrete class)?6. 继承有哪些特点?7. 简要描述JAVA中的几种运算符?8. 介绍一下你对static关键字的理解9. 方法重载和方法重写的概念和区别10. 描述一下GUI编程中AWT事件处理机制四、 编程题(第一题6分,第二题6分,第三题8分,第四题10分,共30分)1. 编写一个Java程序,从键盘输入a,b,c,3个值,输出其中最大的值.2. 打印出

温馨提示

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

评论

0/150

提交评论